oipage 1.7.0-alpha.1 → 1.7.0-alpha.3
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 +5 -0
- package/bin/website-plugins/intercept/getPackage.js +18 -0
- package/bin/website-plugins/intercept/oipage-vislite-intercept.js +2 -5
- package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +2 -5
- package/nodejs/animation/index.js +12 -4
- 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.js +64 -64
- package/nodejs/throttle/index.js +1 -1
- package/package.json +3 -3
- package/types/index.d.ts +37 -0
- package/web/XMLHttpRequest/index.js +1 -1
- package/web/animation/index.js +12 -4
- 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/CHANGELOG
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { readFileSync } = require("fs");
|
|
2
|
+
const { join } = require("path");
|
|
3
|
+
const { existsSync } = require("fs");
|
|
4
|
+
|
|
5
|
+
module.exports = function (filpath) {
|
|
6
|
+
|
|
7
|
+
let node_modulesPath = join(__dirname, "../../../node_modules");
|
|
8
|
+
|
|
9
|
+
while (!existsSync(join(node_modulesPath, filpath)) && node_modulesPath != join(node_modulesPath, "../")) {
|
|
10
|
+
node_modulesPath = join(node_modulesPath, "../");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let source = readFileSync(join(node_modulesPath, filpath), {
|
|
14
|
+
encoding: "utf8"
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return source;
|
|
18
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const { readFileSync } = require("fs");
|
|
2
|
-
const { join } = require("path");
|
|
3
1
|
const headFactory = require("./head.js");
|
|
2
|
+
const getPackage = require("./getPackage.js");
|
|
4
3
|
|
|
5
4
|
const head = headFactory();
|
|
6
5
|
|
|
@@ -20,9 +19,7 @@ module.exports = {
|
|
|
20
19
|
|
|
21
20
|
response.writeHead(200, head);
|
|
22
21
|
|
|
23
|
-
let source =
|
|
24
|
-
encoding: "utf8"
|
|
25
|
-
});
|
|
22
|
+
let source =getPackage("vislite/lib/index.umd.min.js");
|
|
26
23
|
|
|
27
24
|
response.write(`let module = { exports: {} };
|
|
28
25
|
let exports = module.exports;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const { readFileSync } = require("fs");
|
|
2
|
-
const { join } = require("path");
|
|
3
1
|
const headFactory = require("./head.js");
|
|
2
|
+
const getPackage = require("./getPackage.js");
|
|
4
3
|
|
|
5
4
|
const head = headFactory();
|
|
6
5
|
|
|
@@ -20,9 +19,7 @@ module.exports = {
|
|
|
20
19
|
|
|
21
20
|
response.writeHead(200, head);
|
|
22
21
|
|
|
23
|
-
let source =
|
|
24
|
-
encoding: "utf8"
|
|
25
|
-
});
|
|
22
|
+
let source = getPackage("zipaper/dist/Zipaper.min.js");
|
|
26
23
|
|
|
27
24
|
response.write(`let module = { exports: {} };
|
|
28
25
|
let exports = module.exports;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* animation of OIPage v1.7.0-alpha.
|
|
2
|
+
* animation of OIPage v1.7.0-alpha.3
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -16,7 +16,7 @@ var $timerId;
|
|
|
16
16
|
* @param {number} duration 动画时长,可选
|
|
17
17
|
* @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
|
|
18
18
|
*
|
|
19
|
-
* @returns {
|
|
19
|
+
* @returns {object} 返回一个对象,包含一个stop方法,用于在动画结束前结束动画
|
|
20
20
|
*/
|
|
21
21
|
function animation(doback, duration, callback) {
|
|
22
22
|
if (arguments.length < 2) duration = 400;
|
|
@@ -43,7 +43,14 @@ function animation(doback, duration, callback) {
|
|
|
43
43
|
//开启唯一的定时器timerId
|
|
44
44
|
"start": function () {
|
|
45
45
|
if (!$timerId) {
|
|
46
|
-
|
|
46
|
+
if (!globalThis.requestAnimationFrame) {
|
|
47
|
+
$timerId = setInterval(clock.tick, $interval);
|
|
48
|
+
} else {
|
|
49
|
+
$timerId = globalThis.requestAnimationFrame(function step() {
|
|
50
|
+
clock.tick();
|
|
51
|
+
if ($timerId) $timerId = globalThis.requestAnimationFrame(step);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
47
54
|
}
|
|
48
55
|
},
|
|
49
56
|
|
|
@@ -81,7 +88,8 @@ function animation(doback, duration, callback) {
|
|
|
81
88
|
//停止定时器,重置timerId=null
|
|
82
89
|
"stop": function () {
|
|
83
90
|
if ($timerId) {
|
|
84
|
-
clearInterval($timerId);
|
|
91
|
+
if (!globalThis.requestAnimationFrame) clearInterval($timerId);
|
|
92
|
+
else globalThis.cancelAnimationFrame($timerId);
|
|
85
93
|
$timerId = null;
|
|
86
94
|
}
|
|
87
95
|
}
|
package/nodejs/cmdlog/index.js
CHANGED
package/nodejs/disk/index.js
CHANGED
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.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* remote of OIPage v1.7.0-alpha.
|
|
2
|
+
* remote of OIPage v1.7.0-alpha.3
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
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
|
-
};
|
|
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
69
|
|
|
70
70
|
exports.get = get;
|
|
71
71
|
exports.post = post;
|
package/nodejs/throttle/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oipage",
|
|
3
|
-
"version": "1.7.0-alpha.
|
|
3
|
+
"version": "1.7.0-alpha.3",
|
|
4
4
|
"description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
+
"typings": "./types/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"dev": "node ./build/index.js watch",
|
|
8
|
+
"dev": "node ./bin/run run \"node ./build/index.js watch\" \"node ./bin/run serve --config ./oipage.config.js\"",
|
|
8
9
|
"build": "node ./build/index.js",
|
|
9
|
-
"serve": "node ./bin/run serve --config ./oipage.config.js",
|
|
10
10
|
"bug:issue5": "node ./bin/run run \"node ./bin/run serve\"",
|
|
11
11
|
"bug:issue4": "node ./bin/run run \"node ./test/logform/index.spec.js\""
|
|
12
12
|
},
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// OIPage 模块定义 (程序自动生成,请勿修改)
|
|
2
|
+
import "../nodejs/animation/index";
|
|
3
|
+
declare module "oipage/nodejs/animation/index.js" {}
|
|
4
|
+
import "../nodejs/cmdlog/index";
|
|
5
|
+
declare module "oipage/nodejs/cmdlog/index.js" {}
|
|
6
|
+
import "../nodejs/disk/index";
|
|
7
|
+
declare module "oipage/nodejs/disk/index.js" {}
|
|
8
|
+
import "../nodejs/format/index";
|
|
9
|
+
declare module "oipage/nodejs/format/index.js" {}
|
|
10
|
+
import "../nodejs/json/index";
|
|
11
|
+
declare module "oipage/nodejs/json/index.js" {}
|
|
12
|
+
import "../nodejs/logform/index";
|
|
13
|
+
declare module "oipage/nodejs/logform/index.js" {}
|
|
14
|
+
import "../nodejs/reader/index";
|
|
15
|
+
declare module "oipage/nodejs/reader/index.js" {}
|
|
16
|
+
import "../nodejs/remote/index";
|
|
17
|
+
declare module "oipage/nodejs/remote/index.js" {}
|
|
18
|
+
import "../nodejs/throttle/index";
|
|
19
|
+
declare module "oipage/nodejs/throttle/index.js" {}
|
|
20
|
+
import "../web/animation/index";
|
|
21
|
+
declare module "oipage/web/animation/index.js" {}
|
|
22
|
+
import "../web/format/index";
|
|
23
|
+
declare module "oipage/web/format/index.js" {}
|
|
24
|
+
import "../web/json/index";
|
|
25
|
+
declare module "oipage/web/json/index.js" {}
|
|
26
|
+
import "../web/onReady/index";
|
|
27
|
+
declare module "oipage/web/onReady/index.js" {}
|
|
28
|
+
import "../web/performChunk/index";
|
|
29
|
+
declare module "oipage/web/performChunk/index.js" {}
|
|
30
|
+
import "../web/reader/index";
|
|
31
|
+
declare module "oipage/web/reader/index.js" {}
|
|
32
|
+
import "../web/style/index";
|
|
33
|
+
declare module "oipage/web/style/index.js" {}
|
|
34
|
+
import "../web/throttle/index";
|
|
35
|
+
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* animation of OIPage v1.7.0-alpha.
|
|
2
|
+
* animation of OIPage v1.7.0-alpha.3
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -16,7 +16,7 @@ var $timerId;
|
|
|
16
16
|
* @param {number} duration 动画时长,可选
|
|
17
17
|
* @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
|
|
18
18
|
*
|
|
19
|
-
* @returns {
|
|
19
|
+
* @returns {object} 返回一个对象,包含一个stop方法,用于在动画结束前结束动画
|
|
20
20
|
*/
|
|
21
21
|
export function animation(doback, duration, callback) {
|
|
22
22
|
if (arguments.length < 2) duration = 400;
|
|
@@ -43,7 +43,14 @@ export function animation(doback, duration, callback) {
|
|
|
43
43
|
//开启唯一的定时器timerId
|
|
44
44
|
"start": function () {
|
|
45
45
|
if (!$timerId) {
|
|
46
|
-
|
|
46
|
+
if (!globalThis.requestAnimationFrame) {
|
|
47
|
+
$timerId = setInterval(clock.tick, $interval);
|
|
48
|
+
} else {
|
|
49
|
+
$timerId = globalThis.requestAnimationFrame(function step() {
|
|
50
|
+
clock.tick();
|
|
51
|
+
if ($timerId) $timerId = globalThis.requestAnimationFrame(step);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
47
54
|
}
|
|
48
55
|
},
|
|
49
56
|
|
|
@@ -81,7 +88,8 @@ export function animation(doback, duration, callback) {
|
|
|
81
88
|
//停止定时器,重置timerId=null
|
|
82
89
|
"stop": function () {
|
|
83
90
|
if ($timerId) {
|
|
84
|
-
clearInterval($timerId);
|
|
91
|
+
if (!globalThis.requestAnimationFrame) clearInterval($timerId);
|
|
92
|
+
else globalThis.cancelAnimationFrame($timerId);
|
|
85
93
|
$timerId = null;
|
|
86
94
|
}
|
|
87
95
|
}
|
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