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.
Files changed (96) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +144 -137
  4. package/LICENSE +20 -20
  5. package/README.md +95 -95
  6. package/bin/WebSocket/decodeWsFrame.js +43 -43
  7. package/bin/WebSocket/encodeWsFrame.js +28 -28
  8. package/bin/WebSocket/headersToJSON.js +26 -26
  9. package/bin/WebSocket/index.js +80 -80
  10. package/bin/data/mineTypes.json +104 -104
  11. package/bin/disk.js +42 -42
  12. package/bin/help.js +43 -43
  13. package/bin/intercept.js +15 -15
  14. package/bin/network.js +21 -21
  15. package/bin/run +115 -115
  16. package/bin/serve.d.ts +55 -55
  17. package/bin/serve.js +158 -158
  18. package/bin/template/404.html +186 -186
  19. package/bin/tools/deleteEmptyFolder.js +23 -23
  20. package/bin/tools/format.js +75 -75
  21. package/bin/tools/network.js +42 -42
  22. package/bin/tools/resolve404.js +83 -83
  23. package/bin/tools/resolveImport.js +88 -88
  24. package/bin/website-htmls/components/ui-select-file/index.html +7 -7
  25. package/bin/website-htmls/components/ui-select-file/index.js +37 -37
  26. package/bin/website-htmls/components/ui-select-file/index.scss +44 -44
  27. package/bin/website-htmls/dialogs/imageSize/index.html +54 -54
  28. package/bin/website-htmls/dialogs/imageSize/index.js +53 -53
  29. package/bin/website-htmls/dialogs/imageSize/index.scss +138 -138
  30. package/bin/website-htmls/dialogs/index.js +52 -52
  31. package/bin/website-htmls/images/addFile.svg +1 -1
  32. package/bin/website-htmls/images/img-to-pdf.svg +1 -1
  33. package/bin/website-htmls/index.html +17 -17
  34. package/bin/website-htmls/main.js +13 -13
  35. package/bin/website-htmls/pages/App/index.html +6 -6
  36. package/bin/website-htmls/pages/App/index.js +22 -22
  37. package/bin/website-htmls/pages/App/index.scss +43 -43
  38. package/bin/website-htmls/pages/appStore/index.html +24 -24
  39. package/bin/website-htmls/pages/appStore/index.js +19 -19
  40. package/bin/website-htmls/pages/appStore/index.scss +41 -41
  41. package/bin/website-htmls/pages/chart/index.html +8 -8
  42. package/bin/website-htmls/pages/chart/index.js +72 -72
  43. package/bin/website-htmls/pages/chart/index.scss +72 -72
  44. package/bin/website-htmls/pages/image-editor/index.html +27 -27
  45. package/bin/website-htmls/pages/image-editor/index.js +106 -106
  46. package/bin/website-htmls/pages/image-editor/index.scss +45 -45
  47. package/bin/website-htmls/pages/img-to-pdf/index.html +3 -3
  48. package/bin/website-htmls/pages/img-to-pdf/index.js +44 -44
  49. package/bin/website-htmls/pages/img-to-pdf/index.scss +4 -4
  50. package/bin/website-htmls/router.config.js +19 -19
  51. package/bin/website-htmls/styles/normalize.css +94 -94
  52. package/bin/website-plugins/intercept/chart.js +33 -33
  53. package/bin/website-plugins/intercept/head.js +8 -8
  54. package/bin/website-plugins/intercept/index.js +8 -8
  55. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +33 -33
  56. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +39 -39
  57. package/bin/website-plugins/loader/index.js +11 -11
  58. package/bin/website-plugins/loader/oipage-html-loader.js +7 -7
  59. package/bin/website-plugins/loader/oipage-scss-loader.js +149 -149
  60. package/nodejs/animation/index.d.ts +19 -19
  61. package/nodejs/animation/index.js +104 -104
  62. package/nodejs/cmdlog/index.d.ts +20 -20
  63. package/nodejs/cmdlog/index.js +75 -75
  64. package/nodejs/disk/index.d.ts +47 -47
  65. package/nodejs/disk/index.js +165 -165
  66. package/nodejs/format/index.d.ts +29 -29
  67. package/nodejs/format/index.js +107 -107
  68. package/nodejs/json/index.d.ts +9 -9
  69. package/nodejs/json/index.js +206 -206
  70. package/nodejs/logform/index.d.ts +18 -18
  71. package/nodejs/logform/index.js +94 -94
  72. package/nodejs/reader/index.d.ts +32 -32
  73. package/nodejs/reader/index.js +20 -20
  74. package/nodejs/remote/index.d.ts +32 -0
  75. package/nodejs/remote/index.js +71 -0
  76. package/nodejs/throttle/index.d.ts +30 -30
  77. package/nodejs/throttle/index.js +50 -50
  78. package/package.json +43 -43
  79. package/web/XMLHttpRequest/index.d.ts +17 -17
  80. package/web/XMLHttpRequest/index.js +60 -60
  81. package/web/animation/index.d.ts +19 -19
  82. package/web/animation/index.js +104 -104
  83. package/web/format/index.d.ts +29 -29
  84. package/web/format/index.js +107 -107
  85. package/web/json/index.d.ts +9 -9
  86. package/web/json/index.js +206 -206
  87. package/web/onReady/index.d.ts +7 -7
  88. package/web/onReady/index.js +8 -8
  89. package/web/performChunk/index.d.ts +4 -4
  90. package/web/performChunk/index.js +19 -19
  91. package/web/reader/index.d.ts +32 -32
  92. package/web/reader/index.js +20 -20
  93. package/web/style/index.d.ts +21 -21
  94. package/web/style/index.js +19 -19
  95. package/web/throttle/index.d.ts +30 -30
  96. package/web/throttle/index.js +50 -50
@@ -1,110 +1,110 @@
1
1
  /*!
2
- * animation of OIPage v1.6.0
2
+ * animation of OIPage v1.7.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- //当前正在运动的动画的tick函数堆栈
7
- var $timers = [];
8
- //唯一定时器的定时间隔
9
- var $interval = 13;
10
- //定时器ID
11
- var $timerId;
12
-
13
- /**
14
- * 动画轮播
15
- * @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
16
- * @param {number} duration 动画时长,可选
17
- * @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
18
- *
19
- * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
20
- */
21
- function animation(doback, duration, callback) {
22
- if (arguments.length < 2) duration = 400;
23
- if (arguments.length < 3) callback = function () { };
24
-
25
- var clock = {
26
- //把tick函数推入堆栈
27
- "timer": function (tick, duration, callback) {
28
- if (!tick) {
29
- throw new Error('Tick is required!');
30
- }
31
- var id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
32
- $timers.push({
33
- "id": id,
34
- "createTime": new Date(),
35
- "tick": tick,
36
- "duration": duration,
37
- "callback": callback
38
- });
39
- clock.start();
40
- return id;
41
- },
42
-
43
- //开启唯一的定时器timerId
44
- "start": function () {
45
- if (!$timerId) {
46
- $timerId = setInterval(clock.tick, $interval);
47
- }
48
- },
49
-
50
- //被定时器调用,遍历timers堆栈
51
- "tick": function () {
52
- var createTime, flag, tick, callback, timer, duration, passTime, timers = $timers;
53
-
54
- $timers = [];
55
- $timers.length = 0;
56
-
57
- for (flag = 0; flag < timers.length; flag++) {
58
- //初始化数据
59
- timer = timers[flag];
60
- createTime = timer.createTime;
61
- tick = timer.tick;
62
- duration = timer.duration;
63
- callback = timer.callback;
64
-
65
- //执行
66
- passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
67
- passTime = passTime > 1 ? 1 : passTime;
68
- tick(passTime);
69
- if (passTime < 1 && timer.id) {
70
- //动画没有结束再添加
71
- $timers.push(timer);
72
- } else {
73
- callback(passTime);
74
- }
75
- }
76
- if ($timers.length <= 0) {
77
- clock.stop();
78
- }
79
- },
80
-
81
- //停止定时器,重置timerId=null
82
- "stop": function () {
83
- if ($timerId) {
84
- clearInterval($timerId);
85
- $timerId = null;
86
- }
87
- }
88
- };
89
-
90
- var id = clock.timer(function (deep) {
91
- //其中deep为0-1,表示改变的程度
92
- doback(deep);
93
- }, duration, callback);
94
-
95
- return {
96
- // 一个函数
97
- // 用于在动画结束前结束动画
98
- stop: function () {
99
- var i;
100
- for (i in $timers) {
101
- if ($timers[i].id == id) {
102
- $timers[i].id = void 0;
103
- return;
104
- }
105
- }
106
- }
107
- };
108
-
6
+ //当前正在运动的动画的tick函数堆栈
7
+ var $timers = [];
8
+ //唯一定时器的定时间隔
9
+ var $interval = 13;
10
+ //定时器ID
11
+ var $timerId;
12
+
13
+ /**
14
+ * 动画轮播
15
+ * @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
16
+ * @param {number} duration 动画时长,可选
17
+ * @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
18
+ *
19
+ * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
20
+ */
21
+ function animation(doback, duration, callback) {
22
+ if (arguments.length < 2) duration = 400;
23
+ if (arguments.length < 3) callback = function () { };
24
+
25
+ var clock = {
26
+ //把tick函数推入堆栈
27
+ "timer": function (tick, duration, callback) {
28
+ if (!tick) {
29
+ throw new Error('Tick is required!');
30
+ }
31
+ var id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
32
+ $timers.push({
33
+ "id": id,
34
+ "createTime": new Date(),
35
+ "tick": tick,
36
+ "duration": duration,
37
+ "callback": callback
38
+ });
39
+ clock.start();
40
+ return id;
41
+ },
42
+
43
+ //开启唯一的定时器timerId
44
+ "start": function () {
45
+ if (!$timerId) {
46
+ $timerId = setInterval(clock.tick, $interval);
47
+ }
48
+ },
49
+
50
+ //被定时器调用,遍历timers堆栈
51
+ "tick": function () {
52
+ var createTime, flag, tick, callback, timer, duration, passTime, timers = $timers;
53
+
54
+ $timers = [];
55
+ $timers.length = 0;
56
+
57
+ for (flag = 0; flag < timers.length; flag++) {
58
+ //初始化数据
59
+ timer = timers[flag];
60
+ createTime = timer.createTime;
61
+ tick = timer.tick;
62
+ duration = timer.duration;
63
+ callback = timer.callback;
64
+
65
+ //执行
66
+ passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
67
+ passTime = passTime > 1 ? 1 : passTime;
68
+ tick(passTime);
69
+ if (passTime < 1 && timer.id) {
70
+ //动画没有结束再添加
71
+ $timers.push(timer);
72
+ } else {
73
+ callback(passTime);
74
+ }
75
+ }
76
+ if ($timers.length <= 0) {
77
+ clock.stop();
78
+ }
79
+ },
80
+
81
+ //停止定时器,重置timerId=null
82
+ "stop": function () {
83
+ if ($timerId) {
84
+ clearInterval($timerId);
85
+ $timerId = null;
86
+ }
87
+ }
88
+ };
89
+
90
+ var id = clock.timer(function (deep) {
91
+ //其中deep为0-1,表示改变的程度
92
+ doback(deep);
93
+ }, duration, callback);
94
+
95
+ return {
96
+ // 一个函数
97
+ // 用于在动画结束前结束动画
98
+ stop: function () {
99
+ var i;
100
+ for (i in $timers) {
101
+ if ($timers[i].id == id) {
102
+ $timers[i].id = void 0;
103
+ return;
104
+ }
105
+ }
106
+ }
107
+ };
108
+
109
109
  }
110
110
  exports.animation = animation;
@@ -1,20 +1,20 @@
1
- /**
2
- * 单行打印
3
- * @param stream 打印的内容
4
- */
5
- export interface linelogType {
6
- (stream: string): void
7
- }
8
-
9
- export let linelog: linelogType
10
-
11
- /**
12
- * 进度打印
13
- * @param percentum 进度0-100
14
- * @param stream 说明文字,可选
15
- */
16
- export interface deeplogType {
17
- (percentum: number, stream?: string): void
18
- }
19
-
20
- export let deeplog: deeplogType
1
+ /**
2
+ * 单行打印
3
+ * @param stream 打印的内容
4
+ */
5
+ export interface linelogType {
6
+ (stream: string): void
7
+ }
8
+
9
+ export let linelog: linelogType
10
+
11
+ /**
12
+ * 进度打印
13
+ * @param percentum 进度0-100
14
+ * @param stream 说明文字,可选
15
+ */
16
+ export interface deeplogType {
17
+ (percentum: number, stream?: string): void
18
+ }
19
+
20
+ export let deeplog: deeplogType
@@ -1,82 +1,82 @@
1
1
  /*!
2
- * cmdlog of OIPage v1.6.0
2
+ * cmdlog of OIPage v1.7.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- // 预定义的常量
7
- const MOVE_LEFT = Buffer.from('1b5b3130303044', 'hex').toString();
8
- const MOVE_UP = Buffer.from('1b5b3141', 'hex').toString();
9
- const CLEAR_LINE = Buffer.from('1b5b304b', 'hex').toString();
10
-
11
- // 计算字符串长度的方法
12
- const stringwidth = function (str) {
13
- return str.length;
14
- };
15
-
16
- /**
17
- * 不换行打印
18
- * @param {string} stream 打印的内容
19
- */
20
- let linelog = (function (stream) {
21
-
22
- // 用来记录前置有多少行需要回退
23
- let prevLineCount = 0;
24
-
25
- // 返回实际同行打印的方法
26
- return function (nextStr) {
27
- if (arguments.length == 0) {
28
- prevLineCount = 0;
29
- return;
30
- }
31
- let txt = "";
32
-
33
- // 清除屏幕
34
- for (let i = 0; i < prevLineCount; i++) {
35
- txt += MOVE_LEFT + CLEAR_LINE + (i < prevLineCount - 1 ? MOVE_UP : '');
36
- }
37
-
38
- // 写入屏幕
39
- stream.write(txt + nextStr);
40
-
41
- // 重新计算需要回滚多少行
42
- let prevLines = nextStr.split('\n');
43
- prevLineCount = 0;
44
- for (let i = 0; i < prevLines.length; i++) {
45
- // 因为有时候文字过多,因此拿总长度除以一行长度得出真实的行数
46
- prevLineCount += (Math.ceil(stringwidth(prevLines[i]) / stream.columns) || 1);
47
- }
48
-
49
- };
50
- })(process.stdout);
51
-
52
- /**
53
- * 进度打印
54
- *
55
- * @param {number} percentum 进度0-100
56
- * @param {string} stream 说明文字,可选
57
- */
58
- function deeplog (percentum, stream) {
59
- if (arguments.length == 0) {
60
- linelog();
61
- return;
62
- }
63
-
64
- if (arguments.length <= 1) stream = "";
65
-
66
- let txt = "",
67
- i = 0;
68
-
69
- // 补充已经有的进度
70
- for (; i <= percentum && i <= 100; i += 5) {
71
- txt += "█";
72
- }
73
-
74
- // 补充余下的空白
75
- for (; i <= 100; i += 5) {
76
- txt += "░";
77
- }
78
-
79
- linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
6
+ // 预定义的常量
7
+ const MOVE_LEFT = Buffer.from('1b5b3130303044', 'hex').toString();
8
+ const MOVE_UP = Buffer.from('1b5b3141', 'hex').toString();
9
+ const CLEAR_LINE = Buffer.from('1b5b304b', 'hex').toString();
10
+
11
+ // 计算字符串长度的方法
12
+ const stringwidth = function (str) {
13
+ return str.length;
14
+ };
15
+
16
+ /**
17
+ * 不换行打印
18
+ * @param {string} stream 打印的内容
19
+ */
20
+ let linelog = (function (stream) {
21
+
22
+ // 用来记录前置有多少行需要回退
23
+ let prevLineCount = 0;
24
+
25
+ // 返回实际同行打印的方法
26
+ return function (nextStr) {
27
+ if (arguments.length == 0) {
28
+ prevLineCount = 0;
29
+ return;
30
+ }
31
+ let txt = "";
32
+
33
+ // 清除屏幕
34
+ for (let i = 0; i < prevLineCount; i++) {
35
+ txt += MOVE_LEFT + CLEAR_LINE + (i < prevLineCount - 1 ? MOVE_UP : '');
36
+ }
37
+
38
+ // 写入屏幕
39
+ stream.write(txt + nextStr);
40
+
41
+ // 重新计算需要回滚多少行
42
+ let prevLines = nextStr.split('\n');
43
+ prevLineCount = 0;
44
+ for (let i = 0; i < prevLines.length; i++) {
45
+ // 因为有时候文字过多,因此拿总长度除以一行长度得出真实的行数
46
+ prevLineCount += (Math.ceil(stringwidth(prevLines[i]) / stream.columns) || 1);
47
+ }
48
+
49
+ };
50
+ })(process.stdout);
51
+
52
+ /**
53
+ * 进度打印
54
+ *
55
+ * @param {number} percentum 进度0-100
56
+ * @param {string} stream 说明文字,可选
57
+ */
58
+ function deeplog (percentum, stream) {
59
+ if (arguments.length == 0) {
60
+ linelog();
61
+ return;
62
+ }
63
+
64
+ if (arguments.length <= 1) stream = "";
65
+
66
+ let txt = "",
67
+ i = 0;
68
+
69
+ // 补充已经有的进度
70
+ for (; i <= percentum && i <= 100; i += 5) {
71
+ txt += "█";
72
+ }
73
+
74
+ // 补充余下的空白
75
+ for (; i <= 100; i += 5) {
76
+ txt += "░";
77
+ }
78
+
79
+ linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
80
80
  }
81
81
  exports.linelog = linelog;
82
82
  exports.deeplog = deeplog;
@@ -1,48 +1,48 @@
1
- /**
2
- * 删除文件或文件夹
3
- */
4
- export interface deleteDiskType {
5
- (diskPath: string): void
6
- }
7
-
8
- export let deleteDisk: deleteDiskType
9
-
10
- /**
11
- * 复制文件或文件夹
12
- */
13
- export interface copyDiskType {
14
- (sourcePath: string, targetPath: string, isForce?: boolean): void
15
- }
16
-
17
- export let copyDisk: copyDiskType
18
-
19
- /**
20
- * 移动文件或文件夹
21
- */
22
- export interface moveDiskType {
23
- (sourcePath: string, targetPath: string, isForce?: boolean): void
24
- }
25
-
26
- export let moveDisk: moveDiskType
27
-
28
- /**
29
- * 遍历当前文件或文件夹中所有文件
30
- */
31
- export interface listDiskType {
32
- (sourcePath: string, callback: (fileInfo: {
33
- name: string
34
- path: string
35
- folder: string
36
- }) => void): void
37
- }
38
-
39
- export let listDisk: listDiskType
40
-
41
- /**
42
- * 创建文件或文件夹的链接
43
- */
44
- export interface linkDiskType {
45
- (sourcePath: string, targetPath: string): void
46
- }
47
-
1
+ /**
2
+ * 删除文件或文件夹
3
+ */
4
+ export interface deleteDiskType {
5
+ (diskPath: string): void
6
+ }
7
+
8
+ export let deleteDisk: deleteDiskType
9
+
10
+ /**
11
+ * 复制文件或文件夹
12
+ */
13
+ export interface copyDiskType {
14
+ (sourcePath: string, targetPath: string, isForce?: boolean): void
15
+ }
16
+
17
+ export let copyDisk: copyDiskType
18
+
19
+ /**
20
+ * 移动文件或文件夹
21
+ */
22
+ export interface moveDiskType {
23
+ (sourcePath: string, targetPath: string, isForce?: boolean): void
24
+ }
25
+
26
+ export let moveDisk: moveDiskType
27
+
28
+ /**
29
+ * 遍历当前文件或文件夹中所有文件
30
+ */
31
+ export interface listDiskType {
32
+ (sourcePath: string, callback: (fileInfo: {
33
+ name: string
34
+ path: string
35
+ folder: string
36
+ }) => void): void
37
+ }
38
+
39
+ export let listDisk: listDiskType
40
+
41
+ /**
42
+ * 创建文件或文件夹的链接
43
+ */
44
+ export interface linkDiskType {
45
+ (sourcePath: string, targetPath: string): void
46
+ }
47
+
48
48
  export let linkDisk: linkDiskType