oipage 0.3.0 → 0.3.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 (45) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +62 -56
  4. package/LICENSE +20 -20
  5. package/README.md +122 -122
  6. package/bin/options.js +73 -73
  7. package/bin/run +208 -208
  8. package/browserjs/getStyle/index.d.ts +10 -10
  9. package/browserjs/getStyle/index.js +12 -12
  10. package/browserjs/index.d.ts +12 -12
  11. package/browserjs/index.js +8 -8
  12. package/browserjs/onReady/index.d.ts +7 -7
  13. package/browserjs/onReady/index.js +7 -7
  14. package/browserjs/setStyle/index.d.ts +9 -9
  15. package/browserjs/setStyle/index.js +4 -4
  16. package/corejs/animation/index.d.ts +11 -11
  17. package/corejs/animation/index.js +101 -101
  18. package/corejs/index.d.ts +9 -9
  19. package/corejs/index.js +6 -6
  20. package/corejs/throttle/index.d.ts +30 -30
  21. package/corejs/throttle/index.js +49 -49
  22. package/nodejs/core/file.js +162 -162
  23. package/nodejs/core/image.js +4 -4
  24. package/nodejs/core/log.js +89 -89
  25. package/nodejs/core/network.js +39 -39
  26. package/nodejs/core/options.js +48 -48
  27. package/nodejs/core/remote.js +60 -60
  28. package/nodejs/core/responseFileList.js +27 -27
  29. package/nodejs/core/server.js +198 -189
  30. package/nodejs/data/404.js +51 -51
  31. package/nodejs/data/mime.types.js +111 -111
  32. package/nodejs/form/common.js +2 -2
  33. package/nodejs/form/index.js +79 -79
  34. package/nodejs/form/select.js +9 -9
  35. package/nodejs/index.js +57 -57
  36. package/nodejs/loader/simpleScss.js +247 -247
  37. package/nodejs/loader/xhtml.js +520 -520
  38. package/nodejs/reader/plain.js +20 -20
  39. package/package.json +33 -33
  40. package/stylecss/index.css +3 -3
  41. package/stylecss/normalize.css +93 -93
  42. package/stylecss/rasterize.css +317 -317
  43. package/stylecss/skeleton.css +16 -16
  44. package/types/get-options.d.ts +5 -5
  45. package/types/index.d.ts +186 -186
@@ -1,163 +1,163 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- // 删除文件或文件夹
5
- function deleteSync(target) {
6
-
7
- // 如果文件夹不存在,直接返回即可
8
- if (!fs.existsSync(target)) return;
9
-
10
- // 如果是文件,直接删除即可
11
- if (!fs.lstatSync(target).isDirectory()) {
12
- fs.unlinkSync(target);
13
- } else {
14
-
15
- // 读取子文件
16
- const subFiles = fs.readdirSync(target);
17
-
18
- subFiles.forEach(function (file) {
19
-
20
- // 调用这个方法,删除子文件或文件夹
21
- const curPath = path.join(target, "./" + file);
22
- deleteSync(curPath);
23
-
24
- });
25
-
26
- // 等子文件或文件夹删除完毕以后,删除本文件夹
27
- fs.rmdirSync(target);
28
- }
29
-
30
- };
31
-
32
- // 复制文件或文件夹
33
- function copySync(source, target) {
34
-
35
- // 如果是文件,直接复制即可
36
- if (!fs.lstatSync(source).isDirectory()) {
37
- if (!fs.existsSync(path.join(target, "../"))) fs.mkdirSync(path.join(target, "../"), { recursive: true });
38
-
39
- fs.copyFileSync(source, target);
40
- } else {
41
-
42
- // 读取子文件
43
- const subFiles = fs.readdirSync(source);
44
-
45
- // 如果文件夹不存在,创建
46
- if (!fs.existsSync(target)) {
47
- fs.mkdirSync(target, { recursive: true });
48
- }
49
-
50
- // 复制子文件或文件夹
51
- subFiles.forEach(function (file) {
52
- copySync(path.join(source, "./" + file), path.join(target, "./" + file));
53
- });
54
-
55
- }
56
- };
57
-
58
- // 移动文件或文件夹
59
- function moveSync(source, target) {
60
-
61
- // 如果是文件,直接剪切即可
62
- if (!fs.lstatSync(source).isDirectory()) {
63
- if (!fs.existsSync(path.join(target, "../"))) fs.mkdirSync(path.join(target, "../"), { recursive: true });
64
-
65
- fs.copyFileSync(source, target);
66
- fs.unlinkSync(source);
67
- } else {
68
-
69
- // 读取子文件
70
- const subFiles = fs.readdirSync(source);
71
-
72
- // 如果文件夹不存在,创建
73
- if (!fs.existsSync(target)) {
74
- fs.mkdirSync(target, { recursive: true });
75
- }
76
-
77
- // 移动子文件或文件夹
78
- subFiles.forEach(function (file) {
79
- moveSync(path.join(source, "./" + file), path.join(target, "./" + file));
80
- });
81
-
82
- // 移动完子文件或文件夹以后(移动完毕也意味着子文件或文件夹被删除了)
83
- fs.rmdirSync(source);
84
- }
85
- }
86
-
87
- // 遍历文件或文件夹中所有文件
88
- function listFileSync(source, callback) {
89
- // 文件夹
90
- if (fs.lstatSync(source).isDirectory()) {
91
-
92
- // 读取子内容
93
- const subItems = fs.readdirSync(source);
94
- subItems.forEach(function (item) {
95
- listFileSync(path.join(source, "./" + item), callback);
96
- });
97
- }
98
-
99
- // 文件
100
- else {
101
- let folder = path.join(source, "../");
102
-
103
- callback({
104
- "name": source.replace(folder, ""),
105
- "path": source,
106
- "folder": folder
107
- });
108
- }
109
- }
110
-
111
- // 遍历文件夹中所有文件夹
112
- function listFolderSync(source, callback) {
113
- if (fs.lstatSync(source).isDirectory()) {
114
- (function doIt(source) {
115
-
116
- // 读取子内容
117
- const subItems = fs.readdirSync(source);
118
- subItems.forEach(function (item) {
119
- let itemPath = path.join(source, "./" + item);
120
-
121
- // 如果是文件夹
122
- if (fs.lstatSync(itemPath).isDirectory()) {
123
-
124
- let notDeep = callback({
125
- "name": item,
126
- "path": itemPath
127
- });
128
-
129
- // 深入
130
- if (!notDeep) {
131
- doIt(itemPath);
132
- }
133
-
134
- }
135
- });
136
-
137
- })(source);
138
- }
139
- }
140
-
141
- // 获取文件或文件夹的全路径
142
- function fullPathSync(pathString, contextPath) {
143
- if (/^\//.test(pathString) || /^[A-Za-z]:\\/.test(pathString)) {
144
- // 如果传递的就是全路径
145
- return pathString;
146
- }
147
-
148
- if (arguments.length <= 1) {
149
- // 默认把当前命令行作为上下文路径
150
- contextPath = process.cwd();
151
- }
152
-
153
- // 拼全路径
154
- return path.join(contextPath, pathString);
155
- }
156
-
157
- // 导出
158
- exports.deleteSync = deleteSync;
159
- exports.copySync = copySync;
160
- exports.moveSync = moveSync;
161
- exports.listFileSync = listFileSync;
162
- exports.listFolderSync = listFolderSync;
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ // 删除文件或文件夹
5
+ function deleteSync(target) {
6
+
7
+ // 如果文件夹不存在,直接返回即可
8
+ if (!fs.existsSync(target)) return;
9
+
10
+ // 如果是文件,直接删除即可
11
+ if (!fs.lstatSync(target).isDirectory()) {
12
+ fs.unlinkSync(target);
13
+ } else {
14
+
15
+ // 读取子文件
16
+ const subFiles = fs.readdirSync(target);
17
+
18
+ subFiles.forEach(function (file) {
19
+
20
+ // 调用这个方法,删除子文件或文件夹
21
+ const curPath = path.join(target, "./" + file);
22
+ deleteSync(curPath);
23
+
24
+ });
25
+
26
+ // 等子文件或文件夹删除完毕以后,删除本文件夹
27
+ fs.rmdirSync(target);
28
+ }
29
+
30
+ };
31
+
32
+ // 复制文件或文件夹
33
+ function copySync(source, target) {
34
+
35
+ // 如果是文件,直接复制即可
36
+ if (!fs.lstatSync(source).isDirectory()) {
37
+ if (!fs.existsSync(path.join(target, "../"))) fs.mkdirSync(path.join(target, "../"), { recursive: true });
38
+
39
+ fs.copyFileSync(source, target);
40
+ } else {
41
+
42
+ // 读取子文件
43
+ const subFiles = fs.readdirSync(source);
44
+
45
+ // 如果文件夹不存在,创建
46
+ if (!fs.existsSync(target)) {
47
+ fs.mkdirSync(target, { recursive: true });
48
+ }
49
+
50
+ // 复制子文件或文件夹
51
+ subFiles.forEach(function (file) {
52
+ copySync(path.join(source, "./" + file), path.join(target, "./" + file));
53
+ });
54
+
55
+ }
56
+ };
57
+
58
+ // 移动文件或文件夹
59
+ function moveSync(source, target) {
60
+
61
+ // 如果是文件,直接剪切即可
62
+ if (!fs.lstatSync(source).isDirectory()) {
63
+ if (!fs.existsSync(path.join(target, "../"))) fs.mkdirSync(path.join(target, "../"), { recursive: true });
64
+
65
+ fs.copyFileSync(source, target);
66
+ fs.unlinkSync(source);
67
+ } else {
68
+
69
+ // 读取子文件
70
+ const subFiles = fs.readdirSync(source);
71
+
72
+ // 如果文件夹不存在,创建
73
+ if (!fs.existsSync(target)) {
74
+ fs.mkdirSync(target, { recursive: true });
75
+ }
76
+
77
+ // 移动子文件或文件夹
78
+ subFiles.forEach(function (file) {
79
+ moveSync(path.join(source, "./" + file), path.join(target, "./" + file));
80
+ });
81
+
82
+ // 移动完子文件或文件夹以后(移动完毕也意味着子文件或文件夹被删除了)
83
+ fs.rmdirSync(source);
84
+ }
85
+ }
86
+
87
+ // 遍历文件或文件夹中所有文件
88
+ function listFileSync(source, callback) {
89
+ // 文件夹
90
+ if (fs.lstatSync(source).isDirectory()) {
91
+
92
+ // 读取子内容
93
+ const subItems = fs.readdirSync(source);
94
+ subItems.forEach(function (item) {
95
+ listFileSync(path.join(source, "./" + item), callback);
96
+ });
97
+ }
98
+
99
+ // 文件
100
+ else {
101
+ let folder = path.join(source, "../");
102
+
103
+ callback({
104
+ "name": source.replace(folder, ""),
105
+ "path": source,
106
+ "folder": folder
107
+ });
108
+ }
109
+ }
110
+
111
+ // 遍历文件夹中所有文件夹
112
+ function listFolderSync(source, callback) {
113
+ if (fs.lstatSync(source).isDirectory()) {
114
+ (function doIt(source) {
115
+
116
+ // 读取子内容
117
+ const subItems = fs.readdirSync(source);
118
+ subItems.forEach(function (item) {
119
+ let itemPath = path.join(source, "./" + item);
120
+
121
+ // 如果是文件夹
122
+ if (fs.lstatSync(itemPath).isDirectory()) {
123
+
124
+ let notDeep = callback({
125
+ "name": item,
126
+ "path": itemPath
127
+ });
128
+
129
+ // 深入
130
+ if (!notDeep) {
131
+ doIt(itemPath);
132
+ }
133
+
134
+ }
135
+ });
136
+
137
+ })(source);
138
+ }
139
+ }
140
+
141
+ // 获取文件或文件夹的全路径
142
+ function fullPathSync(pathString, contextPath) {
143
+ if (/^\//.test(pathString) || /^[A-Za-z]:\\/.test(pathString)) {
144
+ // 如果传递的就是全路径
145
+ return pathString;
146
+ }
147
+
148
+ if (arguments.length <= 1) {
149
+ // 默认把当前命令行作为上下文路径
150
+ contextPath = process.cwd();
151
+ }
152
+
153
+ // 拼全路径
154
+ return path.join(contextPath, pathString);
155
+ }
156
+
157
+ // 导出
158
+ exports.deleteSync = deleteSync;
159
+ exports.copySync = copySync;
160
+ exports.moveSync = moveSync;
161
+ exports.listFileSync = listFileSync;
162
+ exports.listFolderSync = listFolderSync;
163
163
  exports.fullPathSync = fullPathSync;
@@ -1,5 +1,5 @@
1
- const fs = require('fs');
2
-
3
- exports.toBase64 = function (filepath) {
4
- return "data:image/png;base64," + fs.readFileSync(filepath).toString('base64');
1
+ const fs = require('fs');
2
+
3
+ exports.toBase64 = function (filepath) {
4
+ return "data:image/png;base64," + fs.readFileSync(filepath).toString('base64');
5
5
  };
@@ -1,90 +1,90 @@
1
- // 日志
2
- exports.log = function (txt) {
3
- console.log("\x1B[32m" + txt + "\x1B[39m");
4
- };
5
-
6
- // 警告
7
- exports.warn = function (txt) {
8
- console.log("\x1B[33m" + txt + "\x1B[39m");
9
- };
10
-
11
- // 错误
12
- exports.error = function (txt) {
13
- console.log("\x1B[35m" + txt + "\x1B[39m");
14
- };
15
-
16
-
17
- // 计算字符串长度的方法
18
- const stringwidth = function (str) {
19
- return str.length;
20
- };
21
-
22
- // 预定义的常量
23
- const MOVE_LEFT = Buffer.from('1b5b3130303044', 'hex').toString();
24
- const MOVE_UP = Buffer.from('1b5b3141', 'hex').toString();
25
- const CLEAR_LINE = Buffer.from('1b5b304b', 'hex').toString();
26
-
27
- // 不换行打印
28
- const linelog = (function (stream) {
29
-
30
- // 用来记录前置有多少行需要回退
31
- let prevLineCount = 0;
32
-
33
- // 返回实际同行打印的方法
34
- return function (nextStr) {
35
- if (arguments.length == 0) {
36
- prevLineCount = 0;
37
- return;
38
- }
39
- let txt = "";
40
-
41
- // 清除屏幕
42
- for (let i = 0; i < prevLineCount; i++) {
43
- txt += MOVE_LEFT + CLEAR_LINE + (i < prevLineCount - 1 ? MOVE_UP : '');
44
- }
45
-
46
- // 写入屏幕
47
- stream.write(txt + nextStr);
48
-
49
- // 重新计算需要回滚多少行
50
- let prevLines = nextStr.split('\n');
51
- prevLineCount = 0;
52
- for (let i = 0; i < prevLines.length; i++) {
53
- // 因为有时候文字过多,因此拿总长度除以一行长度得出真实的行数
54
- prevLineCount += (Math.ceil(stringwidth(prevLines[i]) / stream.columns) || 1);
55
- }
56
-
57
- };
58
- })(process.stdout);
59
-
60
- exports.linelog = linelog;
61
-
62
- /**
63
- * 进度打印
64
- *
65
- * @param {number} percentum 进度0-100
66
- * @param {string} stream 说明文字,可选择
67
- */
68
- exports.deeplog = function (percentum, stream) {
69
- if (arguments.length == 0) {
70
- linelog();
71
- return;
72
- }
73
-
74
- if (arguments.length <= 1) stream = "";
75
-
76
- let txt = "",
77
- i = 0;
78
-
79
- // 补充已经有的进度
80
- for (; i <= percentum && i <= 100; i += 5) {
81
- txt += "█";
82
- }
83
-
84
- // 补充余下的空白
85
- for (; i <= 100; i += 5) {
86
- txt += "░";
87
- }
88
-
89
- linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
1
+ // 日志
2
+ exports.log = function (txt) {
3
+ console.log("\x1B[32m" + txt + "\x1B[39m");
4
+ };
5
+
6
+ // 警告
7
+ exports.warn = function (txt) {
8
+ console.log("\x1B[33m" + txt + "\x1B[39m");
9
+ };
10
+
11
+ // 错误
12
+ exports.error = function (txt) {
13
+ console.log("\x1B[35m" + txt + "\x1B[39m");
14
+ };
15
+
16
+
17
+ // 计算字符串长度的方法
18
+ const stringwidth = function (str) {
19
+ return str.length;
20
+ };
21
+
22
+ // 预定义的常量
23
+ const MOVE_LEFT = Buffer.from('1b5b3130303044', 'hex').toString();
24
+ const MOVE_UP = Buffer.from('1b5b3141', 'hex').toString();
25
+ const CLEAR_LINE = Buffer.from('1b5b304b', 'hex').toString();
26
+
27
+ // 不换行打印
28
+ const linelog = (function (stream) {
29
+
30
+ // 用来记录前置有多少行需要回退
31
+ let prevLineCount = 0;
32
+
33
+ // 返回实际同行打印的方法
34
+ return function (nextStr) {
35
+ if (arguments.length == 0) {
36
+ prevLineCount = 0;
37
+ return;
38
+ }
39
+ let txt = "";
40
+
41
+ // 清除屏幕
42
+ for (let i = 0; i < prevLineCount; i++) {
43
+ txt += MOVE_LEFT + CLEAR_LINE + (i < prevLineCount - 1 ? MOVE_UP : '');
44
+ }
45
+
46
+ // 写入屏幕
47
+ stream.write(txt + nextStr);
48
+
49
+ // 重新计算需要回滚多少行
50
+ let prevLines = nextStr.split('\n');
51
+ prevLineCount = 0;
52
+ for (let i = 0; i < prevLines.length; i++) {
53
+ // 因为有时候文字过多,因此拿总长度除以一行长度得出真实的行数
54
+ prevLineCount += (Math.ceil(stringwidth(prevLines[i]) / stream.columns) || 1);
55
+ }
56
+
57
+ };
58
+ })(process.stdout);
59
+
60
+ exports.linelog = linelog;
61
+
62
+ /**
63
+ * 进度打印
64
+ *
65
+ * @param {number} percentum 进度0-100
66
+ * @param {string} stream 说明文字,可选择
67
+ */
68
+ exports.deeplog = function (percentum, stream) {
69
+ if (arguments.length == 0) {
70
+ linelog();
71
+ return;
72
+ }
73
+
74
+ if (arguments.length <= 1) stream = "";
75
+
76
+ let txt = "",
77
+ i = 0;
78
+
79
+ // 补充已经有的进度
80
+ for (; i <= percentum && i <= 100; i += 5) {
81
+ txt += "█";
82
+ }
83
+
84
+ // 补充余下的空白
85
+ for (; i <= 100; i += 5) {
86
+ txt += "░";
87
+ }
88
+
89
+ linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
90
90
  };
@@ -1,40 +1,40 @@
1
- module.exports = function () {
2
-
3
- let infomation = {
4
- IPv4: [],
5
- IPv6: []
6
- };
7
-
8
- let networks = require('os').networkInterfaces()
9
-
10
- let IPv4Had = {}, IPv6Had = {}
11
-
12
- for (let typeName in networks) {
13
- let network = networks[typeName]
14
- for (let index = 0; index < network.length; index++) {
15
- if (network[index].mac != "00:00:00:00:00:00") {
16
- if (network[index].family == 'IPv4' && network[index].address != '127.0.0.1') {
17
- if (!IPv4Had[network[index].mac]) {
18
- infomation.IPv4.push({
19
- address: network[index].address,
20
- mac: network[index].mac
21
- });
22
-
23
- IPv4Had[network[index].mac] = true
24
- }
25
- } else if (network[index].family == 'IPv6' && network[index].address != '::1') {
26
- if (!IPv6Had[network[index].mac]) {
27
- infomation.IPv6.push({
28
- address: network[index].address,
29
- mac: network[index].mac
30
- });
31
-
32
- IPv6Had[network[index].mac] = true
33
- }
34
- }
35
- }
36
- }
37
- }
38
-
39
- return infomation;
1
+ module.exports = function () {
2
+
3
+ let infomation = {
4
+ IPv4: [],
5
+ IPv6: []
6
+ };
7
+
8
+ let networks = require('os').networkInterfaces()
9
+
10
+ let IPv4Had = {}, IPv6Had = {}
11
+
12
+ for (let typeName in networks) {
13
+ let network = networks[typeName]
14
+ for (let index = 0; index < network.length; index++) {
15
+ if (network[index].mac != "00:00:00:00:00:00") {
16
+ if (network[index].family == 'IPv4' && network[index].address != '127.0.0.1') {
17
+ if (!IPv4Had[network[index].mac]) {
18
+ infomation.IPv4.push({
19
+ address: network[index].address,
20
+ mac: network[index].mac
21
+ });
22
+
23
+ IPv4Had[network[index].mac] = true
24
+ }
25
+ } else if (network[index].family == 'IPv6' && network[index].address != '::1') {
26
+ if (!IPv6Had[network[index].mac]) {
27
+ infomation.IPv6.push({
28
+ address: network[index].address,
29
+ mac: network[index].mac
30
+ });
31
+
32
+ IPv6Had[network[index].mac] = true
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ return infomation;
40
40
  };