oipage 1.6.0 → 1.7.0-alpha.1
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/.github/FUNDING.yml +11 -11
- package/AUTHORS.txt +6 -6
- package/CHANGELOG +144 -137
- package/LICENSE +20 -20
- package/README.md +95 -95
- package/bin/WebSocket/decodeWsFrame.js +43 -43
- package/bin/WebSocket/encodeWsFrame.js +28 -28
- package/bin/WebSocket/headersToJSON.js +26 -26
- package/bin/WebSocket/index.js +80 -80
- package/bin/data/mineTypes.json +104 -104
- package/bin/disk.js +42 -42
- package/bin/help.js +43 -43
- package/bin/intercept.js +15 -15
- package/bin/network.js +21 -21
- package/bin/run +115 -115
- package/bin/serve.d.ts +55 -55
- package/bin/serve.js +158 -158
- package/bin/template/404.html +186 -186
- package/bin/tools/deleteEmptyFolder.js +23 -23
- package/bin/tools/format.js +75 -75
- package/bin/tools/network.js +42 -42
- package/bin/tools/resolve404.js +83 -83
- package/bin/tools/resolveImport.js +88 -88
- package/bin/website-htmls/components/ui-select-file/index.html +7 -7
- package/bin/website-htmls/components/ui-select-file/index.js +37 -37
- package/bin/website-htmls/components/ui-select-file/index.scss +44 -44
- package/bin/website-htmls/dialogs/imageSize/index.html +54 -54
- package/bin/website-htmls/dialogs/imageSize/index.js +53 -53
- package/bin/website-htmls/dialogs/imageSize/index.scss +138 -138
- package/bin/website-htmls/dialogs/index.js +52 -52
- package/bin/website-htmls/images/addFile.svg +1 -1
- package/bin/website-htmls/images/img-to-pdf.svg +1 -1
- package/bin/website-htmls/index.html +17 -17
- package/bin/website-htmls/main.js +13 -13
- package/bin/website-htmls/pages/App/index.html +6 -6
- package/bin/website-htmls/pages/App/index.js +22 -22
- package/bin/website-htmls/pages/App/index.scss +43 -43
- package/bin/website-htmls/pages/appStore/index.html +24 -24
- package/bin/website-htmls/pages/appStore/index.js +19 -19
- package/bin/website-htmls/pages/appStore/index.scss +41 -41
- package/bin/website-htmls/pages/chart/index.html +8 -8
- package/bin/website-htmls/pages/chart/index.js +72 -72
- package/bin/website-htmls/pages/chart/index.scss +72 -72
- package/bin/website-htmls/pages/image-editor/index.html +27 -27
- package/bin/website-htmls/pages/image-editor/index.js +106 -106
- package/bin/website-htmls/pages/image-editor/index.scss +45 -45
- package/bin/website-htmls/pages/img-to-pdf/index.html +3 -3
- package/bin/website-htmls/pages/img-to-pdf/index.js +44 -44
- package/bin/website-htmls/pages/img-to-pdf/index.scss +4 -4
- package/bin/website-htmls/router.config.js +19 -19
- package/bin/website-htmls/styles/normalize.css +94 -94
- package/bin/website-plugins/intercept/chart.js +33 -33
- package/bin/website-plugins/intercept/head.js +8 -8
- package/bin/website-plugins/intercept/index.js +8 -8
- package/bin/website-plugins/intercept/oipage-vislite-intercept.js +33 -33
- package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +39 -39
- package/bin/website-plugins/loader/index.js +11 -11
- package/bin/website-plugins/loader/oipage-html-loader.js +7 -7
- package/bin/website-plugins/loader/oipage-scss-loader.js +149 -149
- package/nodejs/animation/index.d.ts +19 -19
- package/nodejs/animation/index.js +104 -104
- package/nodejs/cmdlog/index.d.ts +20 -20
- package/nodejs/cmdlog/index.js +75 -75
- package/nodejs/disk/index.d.ts +47 -47
- package/nodejs/disk/index.js +165 -165
- package/nodejs/format/index.d.ts +29 -29
- package/nodejs/format/index.js +107 -107
- package/nodejs/json/index.d.ts +9 -9
- package/nodejs/json/index.js +206 -206
- package/nodejs/logform/index.d.ts +18 -18
- package/nodejs/logform/index.js +94 -94
- package/nodejs/reader/index.d.ts +32 -32
- package/nodejs/reader/index.js +20 -20
- package/nodejs/remote/index.d.ts +32 -0
- package/nodejs/remote/index.js +71 -0
- package/nodejs/throttle/index.d.ts +30 -30
- package/nodejs/throttle/index.js +50 -50
- package/package.json +43 -43
- package/web/XMLHttpRequest/index.d.ts +17 -17
- package/web/XMLHttpRequest/index.js +60 -60
- package/web/animation/index.d.ts +19 -19
- package/web/animation/index.js +104 -104
- package/web/format/index.d.ts +29 -29
- package/web/format/index.js +107 -107
- package/web/json/index.d.ts +9 -9
- package/web/json/index.js +206 -206
- package/web/onReady/index.d.ts +7 -7
- package/web/onReady/index.js +8 -8
- package/web/performChunk/index.d.ts +4 -4
- package/web/performChunk/index.js +19 -19
- package/web/reader/index.d.ts +32 -32
- package/web/reader/index.js +20 -20
- package/web/style/index.d.ts +21 -21
- package/web/style/index.js +19 -19
- package/web/throttle/index.d.ts +30 -30
- package/web/throttle/index.js +50 -50
package/nodejs/reader/index.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 文本分析读取器
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export interface readerInstanceType {
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 当前字符位置
|
|
9
|
-
*/
|
|
10
|
-
index: number
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 当前字符内容
|
|
14
|
-
*/
|
|
15
|
-
value: string
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 读取下一个字符
|
|
19
|
-
*/
|
|
20
|
-
readNext(): string
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 获取往后count个值
|
|
24
|
-
* @param count
|
|
25
|
-
*/
|
|
26
|
-
getNextN(count: number): string
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface readerType {
|
|
30
|
-
(plain: string): readerInstanceType
|
|
31
|
-
}
|
|
32
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 文本分析读取器
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface readerInstanceType {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 当前字符位置
|
|
9
|
+
*/
|
|
10
|
+
index: number
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 当前字符内容
|
|
14
|
+
*/
|
|
15
|
+
value: string
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 读取下一个字符
|
|
19
|
+
*/
|
|
20
|
+
readNext(): string
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 获取往后count个值
|
|
24
|
+
* @param count
|
|
25
|
+
*/
|
|
26
|
+
getNextN(count: number): string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface readerType {
|
|
30
|
+
(plain: string): readerInstanceType
|
|
31
|
+
}
|
|
32
|
+
|
|
33
33
|
export let reader: readerType
|
package/nodejs/reader/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* reader of OIPage v1.
|
|
2
|
+
* reader of OIPage v1.7.0-alpha.1
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
function reader(plain) {
|
|
7
|
-
|
|
8
|
-
let handler = {
|
|
9
|
-
index: -1,
|
|
10
|
-
value: null
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// 读取下一个字符
|
|
14
|
-
handler.readNext = function () {
|
|
15
|
-
handler.value = handler.index++ < plain.length - 1 ? plain[handler.index] : null;
|
|
16
|
-
return handler.value;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// 获取往后num个值
|
|
20
|
-
handler.getNextN = function (num) {
|
|
21
|
-
return plain.substring(handler.index, num + handler.index > plain.length ? plain.length : num + handler.index);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return handler;
|
|
6
|
+
function reader(plain) {
|
|
7
|
+
|
|
8
|
+
let handler = {
|
|
9
|
+
index: -1,
|
|
10
|
+
value: null
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// 读取下一个字符
|
|
14
|
+
handler.readNext = function () {
|
|
15
|
+
handler.value = handler.index++ < plain.length - 1 ? plain[handler.index] : null;
|
|
16
|
+
return handler.value;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// 获取往后num个值
|
|
20
|
+
handler.getNextN = function (num) {
|
|
21
|
+
return plain.substring(handler.index, num + handler.index > plain.length ? plain.length : num + handler.index);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return handler;
|
|
25
25
|
}
|
|
26
26
|
exports.reader = reader;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
interface resType {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 响应体
|
|
5
|
+
*/
|
|
6
|
+
data: string
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 响应头
|
|
10
|
+
*/
|
|
11
|
+
headers: {
|
|
12
|
+
[key: string]: any
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface getType {
|
|
17
|
+
(url: string, headers?: {
|
|
18
|
+
[key: string]: any
|
|
19
|
+
}): Promise<resType>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export let get: getType
|
|
23
|
+
|
|
24
|
+
export interface postType {
|
|
25
|
+
(url: string, headers?: {
|
|
26
|
+
[key: string]: any
|
|
27
|
+
}, params?: {
|
|
28
|
+
[key: string]: any
|
|
29
|
+
}): Promise<resType>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export let post: postType
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* remote of OIPage v1.7.0-alpha.1
|
|
3
|
+
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const https = require('https');
|
|
7
|
+
const http = require('http');
|
|
8
|
+
|
|
9
|
+
let doResolve = (res, resolve) => {
|
|
10
|
+
res.setEncoding('utf8');
|
|
11
|
+
|
|
12
|
+
let data = "";
|
|
13
|
+
res.on('data', (chunk) => {
|
|
14
|
+
data += chunk;
|
|
15
|
+
});
|
|
16
|
+
res.on('end', () => {
|
|
17
|
+
resolve({
|
|
18
|
+
data: data.toString('utf8'),
|
|
19
|
+
headers: res.headers
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// GET请求
|
|
25
|
+
function get(url, headers = {}) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
|
|
28
|
+
let handler = /^https/.test(url) ? https : http;
|
|
29
|
+
|
|
30
|
+
// https://nodejs.org/download/release/v16.8.0/docs/api/http.html#http_http_get_options_callback
|
|
31
|
+
handler.get(url, {
|
|
32
|
+
headers
|
|
33
|
+
}, res => {
|
|
34
|
+
doResolve(res, resolve)
|
|
35
|
+
}).on('error', (e) => {
|
|
36
|
+
reject(e);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// POST请求
|
|
42
|
+
function post(url, headers = {}, params = {}) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
|
|
45
|
+
let handler = /^https/.test(url) ? https : http;
|
|
46
|
+
|
|
47
|
+
let execArray = /https*:\/\/([^\/]+)(.+)?/.exec(url);
|
|
48
|
+
let hostport = execArray[1].split(":");
|
|
49
|
+
|
|
50
|
+
// https://nodejs.org/download/release/v16.8.0/docs/api/http.html#http_http_request_options_callback
|
|
51
|
+
const req = handler.request({
|
|
52
|
+
hostname: hostport[0],
|
|
53
|
+
port: hostport[1] || 80,
|
|
54
|
+
path: execArray[2] || "/",
|
|
55
|
+
method: "POST",
|
|
56
|
+
headers
|
|
57
|
+
}, (res) => {
|
|
58
|
+
doResolve(res, resolve);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
req.write(JSON.stringify(params));
|
|
62
|
+
|
|
63
|
+
req.on('error', (e) => {
|
|
64
|
+
reject(e);
|
|
65
|
+
});
|
|
66
|
+
req.end();
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.get = get;
|
|
71
|
+
exports.post = post;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export type throttleOpportunityType = "begin" | "end" | "wide"
|
|
2
|
-
|
|
3
|
-
export interface throttleOptionType {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 节流时长
|
|
7
|
-
*/
|
|
8
|
-
time?: number
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 是否持续节流
|
|
12
|
-
*/
|
|
13
|
-
keep?: boolean
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 执行时机
|
|
17
|
-
*
|
|
18
|
-
* begin(开始触发)、end(结束触发)、wide(第一次开始触发,其余结束触发)
|
|
19
|
-
*/
|
|
20
|
-
opportunity?: throttleOpportunityType
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 节流函数
|
|
26
|
-
*/
|
|
27
|
-
export interface throttleType {
|
|
28
|
-
(callback: Function, option?: throttleOptionType): Function
|
|
29
|
-
}
|
|
30
|
-
|
|
1
|
+
export type throttleOpportunityType = "begin" | "end" | "wide"
|
|
2
|
+
|
|
3
|
+
export interface throttleOptionType {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 节流时长
|
|
7
|
+
*/
|
|
8
|
+
time?: number
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 是否持续节流
|
|
12
|
+
*/
|
|
13
|
+
keep?: boolean
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 执行时机
|
|
17
|
+
*
|
|
18
|
+
* begin(开始触发)、end(结束触发)、wide(第一次开始触发,其余结束触发)
|
|
19
|
+
*/
|
|
20
|
+
opportunity?: throttleOpportunityType
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 节流函数
|
|
26
|
+
*/
|
|
27
|
+
export interface throttleType {
|
|
28
|
+
(callback: Function, option?: throttleOptionType): Function
|
|
29
|
+
}
|
|
30
|
+
|
|
31
31
|
export let throttle: throttleType
|
package/nodejs/throttle/index.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* throttle of OIPage v1.
|
|
2
|
+
* throttle of OIPage v1.7.0-alpha.1
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
function throttle(callback, _option) {
|
|
7
|
-
|
|
8
|
-
// 缺省值
|
|
9
|
-
var option = {
|
|
10
|
-
time: 200,
|
|
11
|
-
keep: false,
|
|
12
|
-
opportunity: "end"
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// 校对
|
|
16
|
-
if (_option) {
|
|
17
|
-
for (var key in _option) {
|
|
18
|
-
option[key] = _option[key];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var hadInterval = false, hadClick = false, oneClick = false, arg;
|
|
23
|
-
return function () {
|
|
24
|
-
const _this = this;
|
|
25
|
-
arg = arguments;
|
|
26
|
-
|
|
27
|
-
// 如果前置任务都完成了
|
|
28
|
-
if (!hadInterval) {
|
|
29
|
-
if (option.opportunity != 'end') {
|
|
30
|
-
callback.apply(_this, arg);
|
|
31
|
-
}
|
|
32
|
-
hadInterval = true;
|
|
33
|
-
|
|
34
|
-
var interval = setInterval(() => {
|
|
35
|
-
if (hadClick) {
|
|
36
|
-
if (!option.keep) {
|
|
37
|
-
callback.apply(_this, arg);
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
if (option.opportunity != 'begin') {
|
|
41
|
-
if (oneClick || option.opportunity == 'end') callback.apply(_this, arg);
|
|
42
|
-
}
|
|
43
|
-
hadInterval = false;
|
|
44
|
-
oneClick = false;
|
|
45
|
-
clearInterval(interval);
|
|
46
|
-
}
|
|
47
|
-
hadClick = false;
|
|
48
|
-
}, option.time);
|
|
49
|
-
} else {
|
|
50
|
-
hadClick = true;
|
|
51
|
-
oneClick = true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
};
|
|
6
|
+
function throttle(callback, _option) {
|
|
7
|
+
|
|
8
|
+
// 缺省值
|
|
9
|
+
var option = {
|
|
10
|
+
time: 200,
|
|
11
|
+
keep: false,
|
|
12
|
+
opportunity: "end"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// 校对
|
|
16
|
+
if (_option) {
|
|
17
|
+
for (var key in _option) {
|
|
18
|
+
option[key] = _option[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var hadInterval = false, hadClick = false, oneClick = false, arg;
|
|
23
|
+
return function () {
|
|
24
|
+
const _this = this;
|
|
25
|
+
arg = arguments;
|
|
26
|
+
|
|
27
|
+
// 如果前置任务都完成了
|
|
28
|
+
if (!hadInterval) {
|
|
29
|
+
if (option.opportunity != 'end') {
|
|
30
|
+
callback.apply(_this, arg);
|
|
31
|
+
}
|
|
32
|
+
hadInterval = true;
|
|
33
|
+
|
|
34
|
+
var interval = setInterval(() => {
|
|
35
|
+
if (hadClick) {
|
|
36
|
+
if (!option.keep) {
|
|
37
|
+
callback.apply(_this, arg);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
if (option.opportunity != 'begin') {
|
|
41
|
+
if (oneClick || option.opportunity == 'end') callback.apply(_this, arg);
|
|
42
|
+
}
|
|
43
|
+
hadInterval = false;
|
|
44
|
+
oneClick = false;
|
|
45
|
+
clearInterval(interval);
|
|
46
|
+
}
|
|
47
|
+
hadClick = false;
|
|
48
|
+
}, option.time);
|
|
49
|
+
} else {
|
|
50
|
+
hadClick = true;
|
|
51
|
+
oneClick = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
};
|
|
55
55
|
}
|
|
56
56
|
exports.throttle = throttle;
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "oipage",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
|
|
5
|
-
"sideEffects": false,
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "node ./build/index.js watch",
|
|
8
|
-
"build": "node ./build/index.js",
|
|
9
|
-
"serve": "node ./bin/run serve --config ./oipage.config.js",
|
|
10
|
-
"bug:issue5": "node ./bin/run run \"node ./bin/run serve\"",
|
|
11
|
-
"bug:issue4": "node ./bin/run run \"node ./test/logform/index.spec.js\""
|
|
12
|
-
},
|
|
13
|
-
"bin": {
|
|
14
|
-
"oipage-cli": "bin/run"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/oi-contrib/OIPage.git"
|
|
19
|
-
},
|
|
20
|
-
"keywords": [
|
|
21
|
-
"dev",
|
|
22
|
-
"server",
|
|
23
|
-
"style",
|
|
24
|
-
"css",
|
|
25
|
-
"nodejs",
|
|
26
|
-
"core",
|
|
27
|
-
"oipage",
|
|
28
|
-
"browser"
|
|
29
|
-
],
|
|
30
|
-
"author": {
|
|
31
|
-
"name": "zxl20070701",
|
|
32
|
-
"url": "https://zxl20070701.github.io/notebook/home.html"
|
|
33
|
-
},
|
|
34
|
-
"license": "MIT",
|
|
35
|
-
"bugs": {
|
|
36
|
-
"url": "https://github.com/oi-contrib/OIPage/issues"
|
|
37
|
-
},
|
|
38
|
-
"homepage": "https://oi-contrib.github.io/OIPage",
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"vislite": "^1.5.0",
|
|
41
|
-
"xhtml-to-json": "^0.1.0",
|
|
42
|
-
"zipaper": "^0.2.0"
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "oipage",
|
|
3
|
+
"version": "1.7.0-alpha.1",
|
|
4
|
+
"description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "node ./build/index.js watch",
|
|
8
|
+
"build": "node ./build/index.js",
|
|
9
|
+
"serve": "node ./bin/run serve --config ./oipage.config.js",
|
|
10
|
+
"bug:issue5": "node ./bin/run run \"node ./bin/run serve\"",
|
|
11
|
+
"bug:issue4": "node ./bin/run run \"node ./test/logform/index.spec.js\""
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"oipage-cli": "bin/run"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/oi-contrib/OIPage.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"dev",
|
|
22
|
+
"server",
|
|
23
|
+
"style",
|
|
24
|
+
"css",
|
|
25
|
+
"nodejs",
|
|
26
|
+
"core",
|
|
27
|
+
"oipage",
|
|
28
|
+
"browser"
|
|
29
|
+
],
|
|
30
|
+
"author": {
|
|
31
|
+
"name": "zxl20070701",
|
|
32
|
+
"url": "https://zxl20070701.github.io/notebook/home.html"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/oi-contrib/OIPage/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://oi-contrib.github.io/OIPage",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"vislite": "^1.5.0",
|
|
41
|
+
"xhtml-to-json": "^0.1.0",
|
|
42
|
+
"zipaper": "^0.2.0"
|
|
43
|
+
}
|
|
44
44
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export interface callbackType {
|
|
2
|
-
(type: "send" | "send@error" | "open" | "error" | "timeout" | "end", params: {
|
|
3
|
-
[key: string]: any
|
|
4
|
-
}): void
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface callbackFactoryType {
|
|
8
|
-
(): callbackType
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* XHR拦截
|
|
13
|
-
*/
|
|
14
|
-
export interface XHRInterceptType {
|
|
15
|
-
(callbackFactory: callbackFactoryType): void
|
|
16
|
-
}
|
|
17
|
-
|
|
1
|
+
export interface callbackType {
|
|
2
|
+
(type: "send" | "send@error" | "open" | "error" | "timeout" | "end", params: {
|
|
3
|
+
[key: string]: any
|
|
4
|
+
}): void
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface callbackFactoryType {
|
|
8
|
+
(): callbackType
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* XHR拦截
|
|
13
|
+
*/
|
|
14
|
+
export interface XHRInterceptType {
|
|
15
|
+
(callbackFactory: callbackFactoryType): void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
18
|
export let XHRIntercept: XHRInterceptType
|
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* XMLHttpRequest of OIPage v1.
|
|
2
|
+
* XMLHttpRequest of OIPage v1.7.0-alpha.1
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function XHRIntercept(callbackFactory) {
|
|
7
|
-
|
|
8
|
-
// 原生的请求方法
|
|
9
|
-
var { open, send } = window.XMLHttpRequest.prototype;
|
|
10
|
-
|
|
11
|
-
window.XMLHttpRequest.prototype.open = function (method, url) {
|
|
12
|
-
this.callback = callbackFactory();
|
|
13
|
-
|
|
14
|
-
// 响应
|
|
15
|
-
let { ontimeout, onerror, onloadend } = this;
|
|
16
|
-
|
|
17
|
-
this.onloadend = function () {
|
|
18
|
-
if (onloadend) { onloadend.apply(this, arguments); }
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (this.readyState == 4) {
|
|
22
|
-
let response = "";
|
|
23
|
-
try { response = JSON.parse(this.response); } catch (e) { response = this.response; }
|
|
24
|
-
|
|
25
|
-
this.callback("end", {
|
|
26
|
-
url: this.responseURL,
|
|
27
|
-
status: this.status,
|
|
28
|
-
statusText: this.statusText,
|
|
29
|
-
response: response,
|
|
30
|
-
responseText: this.responseText
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
this.ontimeout = function () {
|
|
36
|
-
if (ontimeout) { ontimeout.apply(this, arguments); }
|
|
37
|
-
this.callback("timeout", {});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
this.onerror = function () {
|
|
41
|
-
if (onerror) { onerror.apply(this, arguments); }
|
|
42
|
-
this.callback("error", {});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
open.apply(this, arguments);
|
|
46
|
-
this.callback("open", {
|
|
47
|
-
method: method,
|
|
48
|
-
url: url
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// 拦截发送
|
|
53
|
-
window.XMLHttpRequest.prototype.send = function (data) {
|
|
54
|
-
try {
|
|
55
|
-
send.apply(this, arguments);
|
|
56
|
-
this.callback("send", {
|
|
57
|
-
data: data
|
|
58
|
-
});
|
|
59
|
-
} catch (error) {
|
|
60
|
-
this.callback("send@error", {
|
|
61
|
-
error: error
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
6
|
+
export function XHRIntercept(callbackFactory) {
|
|
7
|
+
|
|
8
|
+
// 原生的请求方法
|
|
9
|
+
var { open, send } = window.XMLHttpRequest.prototype;
|
|
10
|
+
|
|
11
|
+
window.XMLHttpRequest.prototype.open = function (method, url) {
|
|
12
|
+
this.callback = callbackFactory();
|
|
13
|
+
|
|
14
|
+
// 响应
|
|
15
|
+
let { ontimeout, onerror, onloadend } = this;
|
|
16
|
+
|
|
17
|
+
this.onloadend = function () {
|
|
18
|
+
if (onloadend) { onloadend.apply(this, arguments); }
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if (this.readyState == 4) {
|
|
22
|
+
let response = "";
|
|
23
|
+
try { response = JSON.parse(this.response); } catch (e) { response = this.response; }
|
|
24
|
+
|
|
25
|
+
this.callback("end", {
|
|
26
|
+
url: this.responseURL,
|
|
27
|
+
status: this.status,
|
|
28
|
+
statusText: this.statusText,
|
|
29
|
+
response: response,
|
|
30
|
+
responseText: this.responseText
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
this.ontimeout = function () {
|
|
36
|
+
if (ontimeout) { ontimeout.apply(this, arguments); }
|
|
37
|
+
this.callback("timeout", {});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
this.onerror = function () {
|
|
41
|
+
if (onerror) { onerror.apply(this, arguments); }
|
|
42
|
+
this.callback("error", {});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
open.apply(this, arguments);
|
|
46
|
+
this.callback("open", {
|
|
47
|
+
method: method,
|
|
48
|
+
url: url
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// 拦截发送
|
|
53
|
+
window.XMLHttpRequest.prototype.send = function (data) {
|
|
54
|
+
try {
|
|
55
|
+
send.apply(this, arguments);
|
|
56
|
+
this.callback("send", {
|
|
57
|
+
data: data
|
|
58
|
+
});
|
|
59
|
+
} catch (error) {
|
|
60
|
+
this.callback("send@error", {
|
|
61
|
+
error: error
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
65
|
}
|
package/web/animation/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
interface animationResult {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 一个函数,调用该函数,可以提前结束动画
|
|
5
|
-
*/
|
|
6
|
-
stop(): void
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface animationFun {
|
|
10
|
-
(deep: number): void
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 轮询动画
|
|
15
|
-
*/
|
|
16
|
-
export interface animationType {
|
|
17
|
-
(doback: animationFun, duration?: number, callback?: animationFun): animationResult
|
|
18
|
-
}
|
|
19
|
-
|
|
1
|
+
interface animationResult {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 一个函数,调用该函数,可以提前结束动画
|
|
5
|
+
*/
|
|
6
|
+
stop(): void
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface animationFun {
|
|
10
|
+
(deep: number): void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 轮询动画
|
|
15
|
+
*/
|
|
16
|
+
export interface animationType {
|
|
17
|
+
(doback: animationFun, duration?: number, callback?: animationFun): animationResult
|
|
18
|
+
}
|
|
19
|
+
|
|
20
20
|
export let animation: animationType
|