oipage 1.7.0-alpha.2 → 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 CHANGED
@@ -1,148 +1,149 @@
1
- v1.0.0:
2
- date:2025-02-13
3
- changes:
4
- - 原v0.x的功能将独立一个分支继续维护:https://github.com/oi-contrib/OIPage/blob/v0.x/CHANGELOG
5
- (v0.x保持对零碎方法这种形式的支持和维护,此版本开始将作为一个框架或一个系统的工具箱以提供更高效的使用方式,这是一次彻底的非兼容改造)
6
- - 初始化版本(v1.x)
7
- 1、API功能(浏览器)
8
- * animation 动画
9
- * getStyle 获取节点样式
10
- * setStyle 设置节点样式
11
- * onReady 加载完毕执行
12
- * throttle 节流函数
13
- 2、API功能(Node.js)
14
- * animation 动画
15
- * deeplog 进度打印
16
- * linglog 单行打印
17
- * throttle 节流函数
18
- 3、命令(oipage-cli)
19
- * serve 开发服务器
20
- v1.1.0:
21
- date:2025-02-18
22
- changes:
23
- - 修复bug
24
- 1、通过路径类型判断以修复开发服务器无法设置绝对路径问题
25
- - 优化改造
26
- 1、使用流读取以使开发服务器支持大文件下载
27
- (同时添加下载进度可查)
28
- - 新增功能
29
- 1、API功能(Node.js)
30
- * disk 磁盘相关操作
31
- (包括:deleteDisk、copyDisk)
32
- * logform 表单输入
33
- 2、命令(oipage-cli)
34
- * dist 磁盘操作
35
- * run 运行多命令
36
- v1.2.0:
37
- date:2025-02-25
38
- changes:
39
- - 优化改造
40
- 1、优化npm包目录结构等
41
- - 新增功能
42
- 1、开发服务器
43
- * 添加配置文件
44
- (oipage-cli serve --config ./oipage.config.js)
45
- * 新增对node_modules包引入支持
46
- v1.2.1:
47
- date:2025-03-06
48
- changes:
49
- - 修复bug
50
- 1、开发服务器
51
- * 修复路径不存在时未正确同步修改浏览器地址问题
52
- v1.3.0:(已废弃,请用1.3.1代替)
53
- date:2025-05-18
54
- changes:
55
- - 修复bug
56
- 1、开发服务器
57
- * 修复服务器根路径判断错误导致node_modules包查找错误问题
58
- 2、修复animation动画types类型定义错误问题
59
- - 新增功能
60
- 1、API功能(浏览器)
61
- * reader 文本分析读取器
62
- * performChunk 空闲执行分片函数
63
- * strToJson JSON字符串解析
64
- 2、API功能(Node.js)
65
- * reader 文本分析读取器
66
- * strToJson JSON字符串解析
67
- 3、开发服务器
68
- * 新增 devServer.intercept 请求拦截
69
- * 新增对 if-modified-since和last-modified 之304协商缓存的支持
70
- v1.3.1:
71
- date:2025-05-23
72
- changes:
73
- - 修复bug
74
- 1、开发服务器
75
- * 由于是否入口判断导致import语句未正确解析
76
- * 修复 Last-Modified 格式不规范导致的运行报错
77
- v1.4.0:
78
- date:2025-09-02
79
- changes:
80
- - 修复bug
81
- 1、修复logform运行报错
82
- - 新增功能
83
- 1、API功能(浏览器)
84
- * dateFormat 日期格式化
85
- * numberFormat 数字格式化
86
- * XHRIntercept XHR拦截
87
- 2、API功能(Node.js)
88
- * dateFormat 日期格式化
89
- * numberFormat 数字格式化
90
- 3、开发服务器
91
- * 新增 serve.d.ts 以支持作为API在TypeScript中环境
92
- (仅对内使用,未正式对外暴露API相关文档)
93
- * 添加304是否启用开关
94
- * 应用市场(website内置网站)
95
- v1.4.1:
96
- date:2025-09-02
97
- changes:
98
- - 修复bug
99
- 1、修复开发服务器大文件丢失文件大小问题
100
- v1.5.0:
101
- date:2025-11-13
102
- changes:
103
- - 修复bug
104
- 1、修复404网站在手机浏览器显示高问题
105
- 2、服务器响应类型由 Content-type 改为 Content-Type
106
- 3、修复dateFormat第二个参数无法缺省报错
107
- 4、修复numberFormat不支持负数问题
108
- - 优化改造
109
- 1、优化run命令日志打印
110
- - 新增功能
111
- 1、开发服务器 / 应用市场
112
- * 群聊天
113
- * 图片编辑器
114
- * 图片转PDF
115
- 2、API功能(Node.js)
116
- * disk 磁盘相关操作
117
- (包括:moveDisk、listDisk)
118
- v1.6.0:
119
- date:2025-12-14
120
- changes:
121
- - 修复bug
122
- 1、修复logform在run下无法正常使用问题
123
- (关联issue: https://github.com/oi-contrib/OIPage/issues/4 )
124
- 2、修复服务器错误修改XHR等请求数据问题
125
- - 优化改造
126
- 1、命令行帮助打印更可读
127
- - 新增功能
128
- 1、命令(oipage-cli)
129
- * disk
130
- --link 创建磁盘链接
131
- --delempty 删除空文件夹
132
- * network 网络相关
133
- * run 支持动态参数
134
- (关联issue: https://github.com/oi-contrib/OIPage/issues/5 )
135
- 2、API功能(Node.js)
136
- * disk 磁盘相关操作
137
- (包括:linkDisk)
138
- v1.7.0:
139
- date:
140
- changes:
141
- - 优化改造
142
- 1、types定义模块,方便使用时代码提示
143
- - 修复bug
144
- 1、修复特色情况下 “应用市场” 依赖查找错误问题
145
- - 新增功能
146
- 1、API功能(Node.js)
147
- * remote HTTP请求
1
+ v1.0.0:
2
+ date:2025-02-13
3
+ changes:
4
+ - 原v0.x的功能将独立一个分支继续维护:https://github.com/oi-contrib/OIPage/blob/v0.x/CHANGELOG
5
+ (v0.x保持对零碎方法这种形式的支持和维护,此版本开始将作为一个框架或一个系统的工具箱以提供更高效的使用方式,这是一次彻底的非兼容改造)
6
+ - 初始化版本(v1.x)
7
+ 1、API功能(浏览器)
8
+ * animation 动画
9
+ * getStyle 获取节点样式
10
+ * setStyle 设置节点样式
11
+ * onReady 加载完毕执行
12
+ * throttle 节流函数
13
+ 2、API功能(Node.js)
14
+ * animation 动画
15
+ * deeplog 进度打印
16
+ * linglog 单行打印
17
+ * throttle 节流函数
18
+ 3、命令(oipage-cli)
19
+ * serve 开发服务器
20
+ v1.1.0:
21
+ date:2025-02-18
22
+ changes:
23
+ - 修复bug
24
+ 1、通过路径类型判断以修复开发服务器无法设置绝对路径问题
25
+ - 优化改造
26
+ 1、使用流读取以使开发服务器支持大文件下载
27
+ (同时添加下载进度可查)
28
+ - 新增功能
29
+ 1、API功能(Node.js)
30
+ * disk 磁盘相关操作
31
+ (包括:deleteDisk、copyDisk)
32
+ * logform 表单输入
33
+ 2、命令(oipage-cli)
34
+ * dist 磁盘操作
35
+ * run 运行多命令
36
+ v1.2.0:
37
+ date:2025-02-25
38
+ changes:
39
+ - 优化改造
40
+ 1、优化npm包目录结构等
41
+ - 新增功能
42
+ 1、开发服务器
43
+ * 添加配置文件
44
+ (oipage-cli serve --config ./oipage.config.js)
45
+ * 新增对node_modules包引入支持
46
+ v1.2.1:
47
+ date:2025-03-06
48
+ changes:
49
+ - 修复bug
50
+ 1、开发服务器
51
+ * 修复路径不存在时未正确同步修改浏览器地址问题
52
+ v1.3.0:(已废弃,请用1.3.1代替)
53
+ date:2025-05-18
54
+ changes:
55
+ - 修复bug
56
+ 1、开发服务器
57
+ * 修复服务器根路径判断错误导致node_modules包查找错误问题
58
+ 2、修复animation动画types类型定义错误问题
59
+ - 新增功能
60
+ 1、API功能(浏览器)
61
+ * reader 文本分析读取器
62
+ * performChunk 空闲执行分片函数
63
+ * strToJson JSON字符串解析
64
+ 2、API功能(Node.js)
65
+ * reader 文本分析读取器
66
+ * strToJson JSON字符串解析
67
+ 3、开发服务器
68
+ * 新增 devServer.intercept 请求拦截
69
+ * 新增对 if-modified-since和last-modified 之304协商缓存的支持
70
+ v1.3.1:
71
+ date:2025-05-23
72
+ changes:
73
+ - 修复bug
74
+ 1、开发服务器
75
+ * 由于是否入口判断导致import语句未正确解析
76
+ * 修复 Last-Modified 格式不规范导致的运行报错
77
+ v1.4.0:
78
+ date:2025-09-02
79
+ changes:
80
+ - 修复bug
81
+ 1、修复logform运行报错
82
+ - 新增功能
83
+ 1、API功能(浏览器)
84
+ * dateFormat 日期格式化
85
+ * numberFormat 数字格式化
86
+ * XHRIntercept XHR拦截
87
+ 2、API功能(Node.js)
88
+ * dateFormat 日期格式化
89
+ * numberFormat 数字格式化
90
+ 3、开发服务器
91
+ * 新增 serve.d.ts 以支持作为API在TypeScript中环境
92
+ (仅对内使用,未正式对外暴露API相关文档)
93
+ * 添加304是否启用开关
94
+ * 应用市场(website内置网站)
95
+ v1.4.1:
96
+ date:2025-09-02
97
+ changes:
98
+ - 修复bug
99
+ 1、修复开发服务器大文件丢失文件大小问题
100
+ v1.5.0:
101
+ date:2025-11-13
102
+ changes:
103
+ - 修复bug
104
+ 1、修复404网站在手机浏览器显示高问题
105
+ 2、服务器响应类型由 Content-type 改为 Content-Type
106
+ 3、修复dateFormat第二个参数无法缺省报错
107
+ 4、修复numberFormat不支持负数问题
108
+ - 优化改造
109
+ 1、优化run命令日志打印
110
+ - 新增功能
111
+ 1、开发服务器 / 应用市场
112
+ * 群聊天
113
+ * 图片编辑器
114
+ * 图片转PDF
115
+ 2、API功能(Node.js)
116
+ * disk 磁盘相关操作
117
+ (包括:moveDisk、listDisk)
118
+ v1.6.0:
119
+ date:2025-12-14
120
+ changes:
121
+ - 修复bug
122
+ 1、修复logform在run下无法正常使用问题
123
+ (关联issue: https://github.com/oi-contrib/OIPage/issues/4 )
124
+ 2、修复服务器错误修改XHR等请求数据问题
125
+ - 优化改造
126
+ 1、命令行帮助打印更可读
127
+ - 新增功能
128
+ 1、命令(oipage-cli)
129
+ * disk
130
+ --link 创建磁盘链接
131
+ --delempty 删除空文件夹
132
+ * network 网络相关
133
+ * run 支持动态参数
134
+ (关联issue: https://github.com/oi-contrib/OIPage/issues/5 )
135
+ 2、API功能(Node.js)
136
+ * disk 磁盘相关操作
137
+ (包括:linkDisk)
138
+ v1.7.0:
139
+ date:
140
+ changes:
141
+ - 优化改造
142
+ 1、types定义模块,方便使用时代码提示
143
+ 2、使用requestAnimationFrame改造animation
144
+ - 修复bug
145
+ 1、修复特殊情况下 “应用市场” 依赖查找错误问题
146
+ - 新增功能
147
+ 1、API功能(Node.js)
148
+ * remote HTTP请求
148
149
  (包括:get、post)
@@ -1,18 +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;
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
18
  };
@@ -1,31 +1,31 @@
1
- const headFactory = require("./head.js");
2
- const getPackage = require("./getPackage.js");
3
-
4
- const head = headFactory();
5
-
6
- // VISLite库
7
- module.exports = {
8
- test: /^vislite$/,
9
- handler(request, response) {
10
- head["Content-Type"] = "application/javascript;charset=utf-8";
11
- head["ETag"] = "VISLite@v" + require("vislite/package.json").version;
12
-
13
- if (request.headers["if-none-match"] === head["ETag"]) {
14
- response.writeHead('304', head);
15
- response.end();
16
- console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Cache File: VISLite\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
17
- return;
18
- }
19
-
20
- response.writeHead(200, head);
21
-
22
- let source =getPackage("vislite/lib/index.umd.min.js");
23
-
24
- response.write(`let module = { exports: {} };
25
- let exports = module.exports;
26
- ${source}
27
- export let Canvas = module.exports.Canvas;
28
- `);
29
- response.end();
30
- }
1
+ const headFactory = require("./head.js");
2
+ const getPackage = require("./getPackage.js");
3
+
4
+ const head = headFactory();
5
+
6
+ // VISLite库
7
+ module.exports = {
8
+ test: /^vislite$/,
9
+ handler(request, response) {
10
+ head["Content-Type"] = "application/javascript;charset=utf-8";
11
+ head["ETag"] = "VISLite@v" + require("vislite/package.json").version;
12
+
13
+ if (request.headers["if-none-match"] === head["ETag"]) {
14
+ response.writeHead('304', head);
15
+ response.end();
16
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Cache File: VISLite\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
17
+ return;
18
+ }
19
+
20
+ response.writeHead(200, head);
21
+
22
+ let source =getPackage("vislite/lib/index.umd.min.js");
23
+
24
+ response.write(`let module = { exports: {} };
25
+ let exports = module.exports;
26
+ ${source}
27
+ export let Canvas = module.exports.Canvas;
28
+ `);
29
+ response.end();
30
+ }
31
31
  };
@@ -1,37 +1,37 @@
1
- const headFactory = require("./head.js");
2
- const getPackage = require("./getPackage.js");
3
-
4
- const head = headFactory();
5
-
6
- // Zipaper框架
7
- module.exports = {
8
- test: /^zipaper$/,
9
- handler(request, response) {
10
- head["Content-Type"] = "application/javascript;charset=utf-8";
11
- head["ETag"] = "Zipaper@v" + require("zipaper/package.json").version;
12
-
13
- if (request.headers["if-none-match"] === head["ETag"]) {
14
- response.writeHead('304', head);
15
- response.end();
16
- console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Cache File: Zipaper\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
17
- return;
18
- }
19
-
20
- response.writeHead(200, head);
21
-
22
- let source = getPackage("zipaper/dist/Zipaper.min.js");
23
-
24
- response.write(`let module = { exports: {} };
25
- let exports = module.exports;
26
- ${source}
27
- export let createApp = exports.createApp;
28
- export let defineDirective = exports.defineDirective;
29
- export let defineElement = exports.defineElement;
30
- export let defineRouter = exports.defineRouter;
31
- export let ref = exports.ref;
32
- export let reactive = exports.reactive;
33
- export let watcher = exports.watcher;
34
- `);
35
- response.end();
36
- }
1
+ const headFactory = require("./head.js");
2
+ const getPackage = require("./getPackage.js");
3
+
4
+ const head = headFactory();
5
+
6
+ // Zipaper框架
7
+ module.exports = {
8
+ test: /^zipaper$/,
9
+ handler(request, response) {
10
+ head["Content-Type"] = "application/javascript;charset=utf-8";
11
+ head["ETag"] = "Zipaper@v" + require("zipaper/package.json").version;
12
+
13
+ if (request.headers["if-none-match"] === head["ETag"]) {
14
+ response.writeHead('304', head);
15
+ response.end();
16
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Cache File: Zipaper\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
17
+ return;
18
+ }
19
+
20
+ response.writeHead(200, head);
21
+
22
+ let source = getPackage("zipaper/dist/Zipaper.min.js");
23
+
24
+ response.write(`let module = { exports: {} };
25
+ let exports = module.exports;
26
+ ${source}
27
+ export let createApp = exports.createApp;
28
+ export let defineDirective = exports.defineDirective;
29
+ export let defineElement = exports.defineElement;
30
+ export let defineRouter = exports.defineRouter;
31
+ export let ref = exports.ref;
32
+ export let reactive = exports.reactive;
33
+ export let watcher = exports.watcher;
34
+ `);
35
+ response.end();
36
+ }
37
37
  };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.7.0-alpha.2
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 {function} 返回一个函数,调用该函数,可以提前结束动画
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
- $timerId = setInterval(clock.tick, $interval);
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
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * cmdlog of OIPage v1.7.0-alpha.2
2
+ * cmdlog of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * disk of OIPage v1.7.0-alpha.2
2
+ * disk of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * format of OIPage v1.7.0-alpha.2
2
+ * format of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * json of OIPage v1.7.0-alpha.2
2
+ * json of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  const {reader} = require("../reader/index.js");
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * logform of OIPage v1.7.0-alpha.2
2
+ * logform of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  const {linelog} = require("../cmdlog/index.js");
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * reader of OIPage v1.7.0-alpha.2
2
+ * reader of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,71 +1,71 @@
1
1
  /*!
2
- * remote of OIPage v1.7.0-alpha.2
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;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.7.0-alpha.2
2
+ * throttle of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,45 +1,44 @@
1
- {
2
- "name": "oipage",
3
- "version": "1.7.0-alpha.2",
4
- "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
- "sideEffects": false,
6
- "typings": "./types/index.d.ts",
7
- "scripts": {
8
- "dev": "node ./build/index.js watch",
9
- "build": "node ./build/index.js",
10
- "serve": "node ./bin/run serve --config ./oipage.config.js",
11
- "bug:issue5": "node ./bin/run run \"node ./bin/run serve\"",
12
- "bug:issue4": "node ./bin/run run \"node ./test/logform/index.spec.js\""
13
- },
14
- "bin": {
15
- "oipage-cli": "bin/run"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/oi-contrib/OIPage.git"
20
- },
21
- "keywords": [
22
- "dev",
23
- "server",
24
- "style",
25
- "css",
26
- "nodejs",
27
- "core",
28
- "oipage",
29
- "browser"
30
- ],
31
- "author": {
32
- "name": "zxl20070701",
33
- "url": "https://zxl20070701.github.io/notebook/home.html"
34
- },
35
- "license": "MIT",
36
- "bugs": {
37
- "url": "https://github.com/oi-contrib/OIPage/issues"
38
- },
39
- "homepage": "https://oi-contrib.github.io/OIPage",
40
- "dependencies": {
41
- "vislite": "^1.5.0",
42
- "xhtml-to-json": "^0.1.0",
43
- "zipaper": "^0.2.0"
44
- }
1
+ {
2
+ "name": "oipage",
3
+ "version": "1.7.0-alpha.3",
4
+ "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
+ "sideEffects": false,
6
+ "typings": "./types/index.d.ts",
7
+ "scripts": {
8
+ "dev": "node ./bin/run run \"node ./build/index.js watch\" \"node ./bin/run serve --config ./oipage.config.js\"",
9
+ "build": "node ./build/index.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
+ }
45
44
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * XMLHttpRequest of OIPage v1.7.0-alpha.2
2
+ * XMLHttpRequest of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.7.0-alpha.2
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 {function} 返回一个函数,调用该函数,可以提前结束动画
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
- $timerId = setInterval(clock.tick, $interval);
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
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * format of OIPage v1.7.0-alpha.2
2
+ * format of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
package/web/json/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * json of OIPage v1.7.0-alpha.2
2
+ * json of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  import {reader} from "../reader/index.js";
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * onReady of OIPage v1.7.0-alpha.2
2
+ * onReady of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * performChunk of OIPage v1.7.0-alpha.2
2
+ * performChunk of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * reader of OIPage v1.7.0-alpha.2
2
+ * reader of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * style of OIPage v1.7.0-alpha.2
2
+ * style of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.7.0-alpha.2
2
+ * throttle of OIPage v1.7.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5