oipage 1.7.0-alpha.5 → 1.7.0-alpha.7
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/CHANGELOG +159 -159
- package/bin/help.js +1 -0
- package/bin/proxy.js +75 -79
- package/bin/run +129 -128
- package/bin/serve.js +179 -179
- package/nodejs/animation/index.js +1 -1
- package/nodejs/cmdlog/index.js +1 -1
- package/nodejs/disk/index.js +1 -1
- package/nodejs/format/index.js +1 -1
- package/nodejs/json/index.js +1 -1
- package/nodejs/logform/index.js +1 -1
- package/nodejs/reader/index.js +1 -1
- package/nodejs/remote/index.d.ts +2 -0
- package/nodejs/remote/index.js +35 -5
- package/nodejs/throttle/index.js +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +2 -2
- package/web/XMLHttpRequest/index.js +1 -1
- package/web/animation/index.js +1 -1
- package/web/format/index.js +1 -1
- package/web/json/index.js +1 -1
- package/web/onReady/index.js +1 -1
- package/web/performChunk/index.js +1 -1
- package/web/reader/index.js +1 -1
- package/web/style/index.js +1 -1
- package/web/throttle/index.js +1 -1
package/nodejs/format/index.js
CHANGED
package/nodejs/json/index.js
CHANGED
package/nodejs/logform/index.js
CHANGED
package/nodejs/reader/index.js
CHANGED
package/nodejs/remote/index.d.ts
CHANGED
package/nodejs/remote/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* remote of OIPage v1.7.0-alpha.
|
|
2
|
+
* remote of OIPage v1.7.0-alpha.7
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -21,17 +21,47 @@ function remote(method, url, headers, param) {
|
|
|
21
21
|
method,
|
|
22
22
|
headers
|
|
23
23
|
}, (res) => {
|
|
24
|
-
res.setEncoding("utf8");
|
|
25
24
|
|
|
26
|
-
let
|
|
25
|
+
let _temp = (res.headers["content-type"] + "").split(";");
|
|
26
|
+
|
|
27
|
+
// 数据类型
|
|
28
|
+
let contentType = _temp[0];
|
|
29
|
+
|
|
30
|
+
// 数据编码
|
|
31
|
+
let contentEncoding = "";
|
|
32
|
+
if (_temp[1]) contentEncoding = _temp[1].replace("charset=", "")
|
|
33
|
+
else res.setEncoding("binary"); // 二进制
|
|
34
|
+
|
|
35
|
+
const chunks = []; // 用于存储接收到的数据块
|
|
36
|
+
let size = 0; // 用于跟踪接收到的数据总量
|
|
37
|
+
|
|
27
38
|
res.on('data', (chunk) => {
|
|
28
|
-
|
|
39
|
+
chunks.push(chunk); // 将接收到的数据块添加到数组中
|
|
40
|
+
size += chunk.length; // 更新已接收的数据总量
|
|
29
41
|
});
|
|
42
|
+
|
|
30
43
|
res.on('end', () => {
|
|
44
|
+
let data = Buffer.concat(chunks, size); // 将所有数据块合并为一个Buffer
|
|
45
|
+
let type = "binary"
|
|
46
|
+
|
|
47
|
+
// 如果有编码,认为是文本
|
|
48
|
+
if (contentEncoding) {
|
|
49
|
+
data = data.toString('utf8');
|
|
50
|
+
type = "string";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// JSON文件
|
|
54
|
+
if (contentType === "application/json") {
|
|
55
|
+
try {
|
|
56
|
+
data = JSON.parse(data);
|
|
57
|
+
type = "json";
|
|
58
|
+
} catch (e) { }
|
|
59
|
+
}
|
|
31
60
|
|
|
32
61
|
resolve({
|
|
33
62
|
status: res.statusCode,
|
|
34
|
-
|
|
63
|
+
type,
|
|
64
|
+
data,
|
|
35
65
|
headers: res.headers
|
|
36
66
|
});
|
|
37
67
|
});
|
package/nodejs/throttle/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oipage",
|
|
3
|
-
"version": "1.7.0-alpha.
|
|
3
|
+
"version": "1.7.0-alpha.7",
|
|
4
4
|
"description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dev": "node ./bin/run run \"node ./build/index.js watch\" \"npm run serve\"",
|
|
9
9
|
"build": "node ./build/index.js",
|
|
10
10
|
"serve": "node ./bin/run serve --config ./oipage.config.js",
|
|
11
|
-
"dev:issue10": "node ./bin/run serve --proxy /
|
|
11
|
+
"dev:issue10": "node ./bin/run serve --proxy /proxydemo http://127.0.0.1:8080/docs -p 20000",
|
|
12
12
|
"bug:issue5": "node ./bin/run run \"node ./bin/run serve\"",
|
|
13
13
|
"bug:issue4": "node ./bin/run run \"node ./test/logform/index.spec.js\""
|
|
14
14
|
},
|
package/types/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ import "../nodejs/remote/index";
|
|
|
17
17
|
declare module "oipage/nodejs/remote/index.js" {}
|
|
18
18
|
import "../nodejs/throttle/index";
|
|
19
19
|
declare module "oipage/nodejs/throttle/index.js" {}
|
|
20
|
+
import "../web/XMLHttpRequest/index";
|
|
21
|
+
declare module "oipage/web/XMLHttpRequest/index.js" {}
|
|
20
22
|
import "../web/animation/index";
|
|
21
23
|
declare module "oipage/web/animation/index.js" {}
|
|
22
24
|
import "../web/format/index";
|
|
@@ -33,5 +35,3 @@ import "../web/style/index";
|
|
|
33
35
|
declare module "oipage/web/style/index.js" {}
|
|
34
36
|
import "../web/throttle/index";
|
|
35
37
|
declare module "oipage/web/throttle/index.js" {}
|
|
36
|
-
import "../web/XMLHttpRequest/index";
|
|
37
|
-
declare module "oipage/web/XMLHttpRequest/index.js" {}
|
package/web/animation/index.js
CHANGED
package/web/format/index.js
CHANGED
package/web/json/index.js
CHANGED
package/web/onReady/index.js
CHANGED
package/web/reader/index.js
CHANGED
package/web/style/index.js
CHANGED
package/web/throttle/index.js
CHANGED