oipage 1.4.0-alpha.0 → 1.4.0

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 (71) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +94 -83
  4. package/LICENSE +20 -20
  5. package/README.md +80 -80
  6. package/bin/data/mineTypes.json +104 -104
  7. package/bin/disk.js +31 -31
  8. package/bin/help.js +25 -24
  9. package/bin/intercept.js +15 -15
  10. package/bin/run +98 -96
  11. package/bin/serve.d.ts +56 -55
  12. package/bin/serve.js +147 -131
  13. package/bin/template/404.html +183 -171
  14. package/bin/tools/format.js +75 -75
  15. package/bin/tools/network.js +42 -42
  16. package/bin/tools/resolve404.js +83 -83
  17. package/bin/tools/resolveImport.js +88 -88
  18. package/bin/website-htmls/dialogs/index.js +43 -0
  19. package/bin/website-htmls/index.html +18 -0
  20. package/bin/website-htmls/logo.png +0 -0
  21. package/bin/website-htmls/main.js +10 -0
  22. package/bin/website-htmls/pages/App/index.html +4 -0
  23. package/bin/website-htmls/pages/App/index.js +23 -0
  24. package/bin/website-htmls/pages/App/index.scss +43 -0
  25. package/bin/website-htmls/pages/appStore/index.html +6 -0
  26. package/bin/website-htmls/pages/appStore/index.js +18 -0
  27. package/bin/website-htmls/pages/appStore/index.scss +27 -0
  28. package/bin/website-htmls/router.config.js +11 -0
  29. package/bin/website-htmls/styles/common.css +3 -0
  30. package/bin/website-htmls/styles/normalize.css +95 -0
  31. package/bin/website-plugins/intercept/head.js +9 -0
  32. package/bin/website-plugins/intercept/index.js +5 -0
  33. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +40 -0
  34. package/bin/website-plugins/loader/index.js +12 -0
  35. package/bin/website-plugins/loader/oipage-html-loader.js +8 -0
  36. package/bin/website-plugins/loader/oipage-scss-loader.js +150 -0
  37. package/nodejs/animation/index.d.ts +19 -19
  38. package/nodejs/animation/index.js +104 -104
  39. package/nodejs/cmdlog/index.d.ts +20 -20
  40. package/nodejs/cmdlog/index.js +75 -75
  41. package/nodejs/disk/index.d.ts +16 -16
  42. package/nodejs/disk/index.js +78 -78
  43. package/nodejs/format/index.d.ts +29 -0
  44. package/nodejs/format/index.js +114 -0
  45. package/nodejs/json/index.d.ts +9 -9
  46. package/nodejs/json/index.js +206 -206
  47. package/nodejs/logform/index.d.ts +18 -18
  48. package/nodejs/logform/index.js +94 -94
  49. package/nodejs/reader/index.d.ts +32 -32
  50. package/nodejs/reader/index.js +20 -20
  51. package/nodejs/throttle/index.d.ts +30 -30
  52. package/nodejs/throttle/index.js +50 -50
  53. package/package.json +42 -40
  54. package/web/XMLHttpRequest/index.d.ts +18 -0
  55. package/web/XMLHttpRequest/index.js +65 -0
  56. package/web/animation/index.d.ts +19 -19
  57. package/web/animation/index.js +104 -104
  58. package/web/format/index.d.ts +29 -0
  59. package/web/format/index.js +112 -0
  60. package/web/json/index.d.ts +9 -9
  61. package/web/json/index.js +206 -206
  62. package/web/onReady/index.d.ts +7 -7
  63. package/web/onReady/index.js +8 -8
  64. package/web/performChunk/index.d.ts +4 -4
  65. package/web/performChunk/index.js +19 -19
  66. package/web/reader/index.d.ts +32 -32
  67. package/web/reader/index.js +20 -20
  68. package/web/style/index.d.ts +21 -21
  69. package/web/style/index.js +19 -19
  70. package/web/throttle/index.d.ts +30 -30
  71. package/web/throttle/index.js +50 -50
package/bin/disk.js CHANGED
@@ -1,32 +1,32 @@
1
- const { deleteDisk, copyDisk } = require("../nodejs/disk");
2
-
3
- module.exports = function (config) {
4
- let isForce = false;
5
-
6
- // 判断是否开启强制执行
7
- for (let i = 0; i < config.value.length; i++) {
8
- if (config.value[i].name === "--force") isForce = true;
9
- }
10
-
11
- // 执行一个个任务
12
- for (let i = 0; i < config.value.length; i++) {
13
-
14
- // 删除文件或文件夹
15
- if (config.value[i].name === "--delete") {
16
- for (let j = 0; j < config.value[i].value.length; j++) {
17
- deleteDisk(config.value[i].value[j]);
18
- }
19
- }
20
-
21
- // 移动文件或文件夹
22
- else if (config.value[i].name === "--move") {
23
- copyDisk(config.value[i].value[0], config.value[i].value[1], isForce);
24
- deleteDisk(config.value[i].value[0]);
25
- }
26
-
27
- // 复制文件或文件夹
28
- else if (config.value[i].name === "--copy") {
29
- copyDisk(config.value[i].value[0], config.value[i].value[1], isForce);
30
- }
31
- }
1
+ const { deleteDisk, copyDisk } = require("../nodejs/disk");
2
+
3
+ module.exports = function (config) {
4
+ let isForce = false;
5
+
6
+ // 判断是否开启强制执行
7
+ for (let i = 0; i < config.value.length; i++) {
8
+ if (config.value[i].name === "--force") isForce = true;
9
+ }
10
+
11
+ // 执行一个个任务
12
+ for (let i = 0; i < config.value.length; i++) {
13
+
14
+ // 删除文件或文件夹
15
+ if (config.value[i].name === "--delete") {
16
+ for (let j = 0; j < config.value[i].value.length; j++) {
17
+ deleteDisk(config.value[i].value[j]);
18
+ }
19
+ }
20
+
21
+ // 移动文件或文件夹
22
+ else if (config.value[i].name === "--move") {
23
+ copyDisk(config.value[i].value[0], config.value[i].value[1], isForce);
24
+ deleteDisk(config.value[i].value[0]);
25
+ }
26
+
27
+ // 复制文件或文件夹
28
+ else if (config.value[i].name === "--copy") {
29
+ copyDisk(config.value[i].value[0], config.value[i].value[1], isForce);
30
+ }
31
+ }
32
32
  };
package/bin/help.js CHANGED
@@ -1,25 +1,26 @@
1
- const packageValue = require("../package.json");
2
-
3
- module.exports = function () {
4
- console.log(`\x1b[36m
5
- OIPage@v${packageValue.version}
6
-
7
- 可以使用的命令如下:
8
-
9
- 【1】oipage-cli serve 开发服务器
10
- --port|-p 端口号
11
- --baseUrl 服务器根目录
12
- --config|-c 设置配置文件
13
-
14
- 【2】oipage-cli disk 磁盘操作
15
- --force|-f 强制执行
16
- --delete|-d 删除文件或文件夹
17
- --move|m 移动文件或文件夹
18
- --copy|-c 复制文件或文件夹
19
-
20
- 【3】oipage-cli run "任务一" "任务二" ... 运行多命令
21
-
22
- Powered by https://github.com/zxl20070701
23
- \x1b[0m`);
24
-
1
+ const packageValue = require("../package.json");
2
+
3
+ module.exports = function () {
4
+ console.log(`\x1b[36m
5
+ OIPage@v${packageValue.version}
6
+
7
+ 可以使用的命令如下:
8
+
9
+ 【1】oipage-cli serve 开发服务器
10
+ --port|-p 端口号
11
+ --baseUrl 服务器根目录
12
+ --config|-c 设置配置文件
13
+ --cache 是否启用304(默认true表示开启)
14
+
15
+ 【2】oipage-cli disk 磁盘操作
16
+ --force|-f 强制执行
17
+ --delete|-d 删除文件或文件夹
18
+ --move|m 移动文件或文件夹
19
+ --copy|-c 复制文件或文件夹
20
+
21
+ 【3】oipage-cli run "任务一" "任务二" ... 运行多命令
22
+
23
+ Powered by https://github.com/zxl20070701
24
+ \x1b[0m`);
25
+
25
26
  };
package/bin/intercept.js CHANGED
@@ -1,16 +1,16 @@
1
- exports.doIntercept = function (url, intercept, request, response) {
2
- for (let item of intercept) {
3
- if (item.test.test(url)) {
4
- item.handler(request, response);
5
- return true;
6
- }
7
- }
8
- }
9
-
10
- exports.testIntercept = function (url, intercept) {
11
- for (let item of intercept) {
12
- if (item.test.test(url)) {
13
- return true;
14
- }
15
- }
1
+ exports.doIntercept = function (url, intercept, request, response) {
2
+ for (let item of intercept) {
3
+ if (item.test.test(url)) {
4
+ item.handler(request, response);
5
+ return true;
6
+ }
7
+ }
8
+ }
9
+
10
+ exports.testIntercept = function (url, intercept) {
11
+ for (let item of intercept) {
12
+ if (item.test.test(url)) {
13
+ return true;
14
+ }
15
+ }
16
16
  }
package/bin/run CHANGED
@@ -1,97 +1,99 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
4
-
5
- process.title = 'OIPage';
6
-
7
- const { exec } = require('child_process');
8
- const { join } = require("path");
9
- const { existsSync, lstatSync } = require("fs");
10
- const { mergeOption } = require("vislite");
11
- const { formatArgv } = require("./tools/format.js");
12
-
13
- // 开发服务器
14
- if (process.argv[2] === "serve") {
15
-
16
- let argvObj = formatArgv(process.argv, {
17
- "-p": "--port",
18
- "-c": "--config"
19
- });
20
-
21
- let config = {
22
- devServer: {
23
- port: 8080,
24
- baseUrl: "./",
25
- intercept: []
26
- },
27
- module: {
28
- rules: []
29
- }
30
- };
31
-
32
- // 如果设置了配置文件
33
- if (argvObj["--config"]) {
34
- let configPath = join(process.cwd(), argvObj["--config"][0] || "./oipage.config.js");
35
- if (existsSync(configPath) && !lstatSync(configPath).isDirectory()) {
36
- let configValue = require(configPath);
37
- mergeOption(config, configValue);
38
- } else {
39
- console.log("\x1b[0m\x1b[31m" + configPath + "\x1b[0m");
40
- throw new Error("OIPage: The configuration file does not exist or is not a file.");
41
- }
42
- }
43
-
44
- if ((argvObj["--port"] || [])[0]) config.devServer.port = (argvObj["--port"] || [])[0];
45
- if ((argvObj["--baseUrl"] || [])[0]) config.devServer.baseUrl = (argvObj["--baseUrl"] || [])[0];
46
-
47
- require("./serve.js")(config);
48
- }
49
-
50
- // 磁盘操作
51
- else if (process.argv[2] === "disk") {
52
-
53
- let argvObj = formatArgv(process.argv, {
54
- "-f": "--force",
55
- "-d": "--delete",
56
- "-m": "--move",
57
- "-c": "--copy"
58
- }, true);
59
-
60
- require("./disk.js")(argvObj);
61
- }
62
-
63
- // 运行多命令
64
- else if (process.argv[2] === "run") {
65
-
66
- let argvObj = formatArgv(process.argv, {});
67
-
68
- for (let index = 0; index < argvObj.args.length; index++) {
69
- const child = exec(argvObj.args[index]);
70
-
71
- // 监听子线程的stdout
72
- child.stdout.on('data', (data) => {
73
- console.log(`[${index + 1}] log:${data}`);
74
- });
75
-
76
- // 监听子线程的stderr
77
- child.stderr.on('data', (data) => {
78
- console.error(`[${index + 1}] error:${data}`);
79
- });
80
-
81
- // 子线程结束处理
82
- child.on('close', (code) => {
83
- console.log(`[${index + 1}] 子线程结束,退出码 ${code}`);
84
- });
85
-
86
- // 子线程出错处理
87
- child.on('error', (error) => {
88
- console.error(`[${index + 1}] 子线程错误: ${error.message}`);
89
- });
90
- }
91
-
92
- }
93
-
94
- // 默认,帮助
95
- else {
96
- require("./help.js")();
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ process.title = 'OIPage';
6
+
7
+ const { exec } = require('child_process');
8
+ const { join } = require("path");
9
+ const { existsSync, lstatSync } = require("fs");
10
+ const { mergeOption } = require("vislite");
11
+ const { formatArgv } = require("./tools/format.js");
12
+
13
+ // 开发服务器
14
+ if (process.argv[2] === "serve") {
15
+
16
+ let argvObj = formatArgv(process.argv, {
17
+ "-p": "--port",
18
+ "-c": "--config"
19
+ });
20
+
21
+ let config = {
22
+ devServer: {
23
+ port: 8080,
24
+ baseUrl: "./",
25
+ cache: true,
26
+ intercept: []
27
+ },
28
+ module: {
29
+ rules: []
30
+ }
31
+ };
32
+
33
+ // 如果设置了配置文件
34
+ if (argvObj["--config"]) {
35
+ let configPath = join(process.cwd(), argvObj["--config"][0] || "./oipage.config.js");
36
+ if (existsSync(configPath) && !lstatSync(configPath).isDirectory()) {
37
+ let configValue = require(configPath);
38
+ mergeOption(config, configValue);
39
+ } else {
40
+ console.log("\x1b[0m\x1b[31m" + configPath + "\x1b[0m");
41
+ throw new Error("OIPage: The configuration file does not exist or is not a file.");
42
+ }
43
+ }
44
+
45
+ if ((argvObj["--port"] || [])[0]) config.devServer.port = (argvObj["--port"] || [])[0];
46
+ if ((argvObj["--baseUrl"] || [])[0]) config.devServer.baseUrl = (argvObj["--baseUrl"] || [])[0];
47
+ if ((argvObj["--cache"] || [])[0]) config.devServer.cache = (argvObj["--cache"] || [])[0] === "true";
48
+
49
+ require("./serve.js")(config);
50
+ }
51
+
52
+ // 磁盘操作
53
+ else if (process.argv[2] === "disk") {
54
+
55
+ let argvObj = formatArgv(process.argv, {
56
+ "-f": "--force",
57
+ "-d": "--delete",
58
+ "-m": "--move",
59
+ "-c": "--copy"
60
+ }, true);
61
+
62
+ require("./disk.js")(argvObj);
63
+ }
64
+
65
+ // 运行多命令
66
+ else if (process.argv[2] === "run") {
67
+
68
+ let argvObj = formatArgv(process.argv, {});
69
+
70
+ for (let index = 0; index < argvObj.args.length; index++) {
71
+ const child = exec(argvObj.args[index]);
72
+
73
+ // 监听子线程的stdout
74
+ child.stdout.on('data', (data) => {
75
+ console.log(`[${index + 1}] log:${data}`);
76
+ });
77
+
78
+ // 监听子线程的stderr
79
+ child.stderr.on('data', (data) => {
80
+ console.error(`[${index + 1}] error:${data}`);
81
+ });
82
+
83
+ // 子线程结束处理
84
+ child.on('close', (code) => {
85
+ console.log(`[${index + 1}] 子线程结束,退出码 ${code}`);
86
+ });
87
+
88
+ // 子线程出错处理
89
+ child.on('error', (error) => {
90
+ console.error(`[${index + 1}] 子线程错误: ${error.message}`);
91
+ });
92
+ }
93
+
94
+ }
95
+
96
+ // 默认,帮助
97
+ else {
98
+ require("./help.js")();
97
99
  }
package/bin/serve.d.ts CHANGED
@@ -1,55 +1,56 @@
1
-
2
- interface DevServerType {
3
-
4
- /**
5
- * 服务器端口号
6
- */
7
- port?: number
8
-
9
- /**
10
- * 服务器根路径
11
- */
12
- baseUrl?: string
13
- }
14
-
15
- interface InterceptType {
16
- test: RegExp
17
- handler(request: any, response: any): void
18
- }
19
-
20
- interface LoaderType {
21
- (source: string): string
22
- }
23
-
24
- interface ConfigType {
25
-
26
- /**
27
- * 服务器名称
28
- */
29
- name?: string
30
-
31
- /**
32
- * 服务器版本
33
- */
34
- version?: string
35
-
36
- /**
37
- * 服务器运行配置
38
- */
39
- devServer?: DevServerType
40
-
41
- intercept?: Array<InterceptType>
42
-
43
- module?: {
44
- rules: Array<{
45
- test: RegExp
46
- use: LoaderType
47
- }>
48
- }
49
- }
50
-
51
- interface ServeType {
52
- (config: ConfigType): void
53
- }
54
-
55
- export default ServeType
1
+
2
+ interface DevServerType {
3
+
4
+ /**
5
+ * 服务器端口号
6
+ */
7
+ port: number
8
+
9
+ /**
10
+ * 服务器根路径
11
+ */
12
+ baseUrl: string
13
+
14
+ /**
15
+ * 是否开启304缓存,默认开启
16
+ */
17
+ cache: boolean
18
+ }
19
+
20
+ interface InterceptType {
21
+ test: RegExp
22
+ handler(request: any, response: any): void
23
+ }
24
+
25
+ interface LoaderType {
26
+ (source: string): string
27
+ }
28
+
29
+ interface ConfigType {
30
+
31
+ /**
32
+ * 服务器名称
33
+ */
34
+ name?: string
35
+
36
+ /**
37
+ * 服务器版本
38
+ */
39
+ version?: string
40
+
41
+ /**
42
+ * 服务器运行配置
43
+ */
44
+ devServer: DevServerType
45
+
46
+ intercept?: Array<InterceptType>
47
+
48
+ module?: {
49
+ rules: Array<{
50
+ test: RegExp
51
+ use: LoaderType
52
+ }>
53
+ }
54
+ }
55
+
56
+ export default function (config?: ConfigType): void