oipage 1.7.0 → 1.8.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 (101) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +9 -1
  4. package/LICENSE +20 -20
  5. package/README.md +1 -9
  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 +3 -0
  13. package/bin/intercept.js +15 -15
  14. package/bin/network.js +21 -21
  15. package/bin/run +5 -3
  16. package/bin/serve.d.ts +7 -0
  17. package/bin/serve.js +9 -1
  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/openBrowser.js +26 -0
  23. package/bin/tools/resolve404.js +83 -83
  24. package/bin/tools/resolveImport.js +88 -88
  25. package/bin/website-htmls/components/ui-select-file/index.html +7 -7
  26. package/bin/website-htmls/components/ui-select-file/index.js +37 -37
  27. package/bin/website-htmls/components/ui-select-file/index.scss +44 -44
  28. package/bin/website-htmls/dialogs/imageSize/index.html +54 -54
  29. package/bin/website-htmls/dialogs/imageSize/index.js +53 -53
  30. package/bin/website-htmls/dialogs/imageSize/index.scss +138 -138
  31. package/bin/website-htmls/dialogs/index.js +52 -52
  32. package/bin/website-htmls/images/addFile.svg +1 -1
  33. package/bin/website-htmls/images/img-to-pdf.svg +1 -1
  34. package/bin/website-htmls/index.html +17 -17
  35. package/bin/website-htmls/main.js +13 -13
  36. package/bin/website-htmls/pages/App/index.html +6 -6
  37. package/bin/website-htmls/pages/App/index.js +22 -22
  38. package/bin/website-htmls/pages/App/index.scss +43 -43
  39. package/bin/website-htmls/pages/appStore/index.html +5 -24
  40. package/bin/website-htmls/pages/appStore/index.js +19 -19
  41. package/bin/website-htmls/pages/appStore/index.scss +6 -4
  42. package/bin/website-htmls/pages/chart/index.html +8 -8
  43. package/bin/website-htmls/pages/chart/index.js +72 -72
  44. package/bin/website-htmls/pages/chart/index.scss +73 -72
  45. package/bin/website-htmls/pages/home/index.html +22 -0
  46. package/bin/website-htmls/pages/home/index.js +20 -0
  47. package/bin/website-htmls/pages/home/index.scss +29 -0
  48. package/bin/website-htmls/pages/image-editor/index.html +27 -27
  49. package/bin/website-htmls/pages/image-editor/index.js +106 -106
  50. package/bin/website-htmls/pages/image-editor/index.scss +47 -45
  51. package/bin/website-htmls/pages/img-to-pdf/index.html +3 -3
  52. package/bin/website-htmls/pages/img-to-pdf/index.js +44 -44
  53. package/bin/website-htmls/pages/img-to-pdf/index.scss +4 -4
  54. package/bin/website-htmls/router.config.js +26 -19
  55. package/bin/website-htmls/styles/normalize.css +94 -94
  56. package/bin/website-plugins/intercept/chart.js +33 -33
  57. package/bin/website-plugins/intercept/getPackage.js +17 -17
  58. package/bin/website-plugins/intercept/head.js +8 -8
  59. package/bin/website-plugins/intercept/index.js +8 -8
  60. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +30 -30
  61. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +36 -36
  62. package/bin/website-plugins/loader/index.js +11 -11
  63. package/bin/website-plugins/loader/oipage-html-loader.js +7 -7
  64. package/bin/website-plugins/loader/oipage-scss-loader.js +149 -149
  65. package/nodejs/animation/index.d.ts +19 -19
  66. package/nodejs/animation/index.js +120 -112
  67. package/nodejs/cmdlog/index.d.ts +20 -20
  68. package/nodejs/cmdlog/index.js +75 -75
  69. package/nodejs/disk/index.d.ts +47 -47
  70. package/nodejs/disk/index.js +165 -165
  71. package/nodejs/format/index.d.ts +29 -29
  72. package/nodejs/format/index.js +107 -107
  73. package/nodejs/json/index.d.ts +9 -9
  74. package/nodejs/json/index.js +206 -206
  75. package/nodejs/logform/index.d.ts +18 -18
  76. package/nodejs/logform/index.js +94 -94
  77. package/nodejs/reader/index.d.ts +32 -32
  78. package/nodejs/reader/index.js +20 -20
  79. package/nodejs/throttle/index.d.ts +30 -30
  80. package/nodejs/throttle/index.js +50 -50
  81. package/package.json +1 -1
  82. package/web/XMLHttpRequest/index.d.ts +17 -17
  83. package/web/XMLHttpRequest/index.js +60 -60
  84. package/web/animation/index.d.ts +19 -19
  85. package/web/animation/index.js +120 -112
  86. package/web/format/index.d.ts +29 -29
  87. package/web/format/index.js +107 -107
  88. package/web/json/index.d.ts +9 -9
  89. package/web/json/index.js +206 -206
  90. package/web/onReady/index.d.ts +7 -7
  91. package/web/onReady/index.js +8 -8
  92. package/web/performChunk/index.d.ts +4 -4
  93. package/web/performChunk/index.js +19 -19
  94. package/web/reader/index.d.ts +32 -32
  95. package/web/reader/index.js +20 -20
  96. package/web/style/index.d.ts +21 -21
  97. package/web/style/index.js +19 -19
  98. package/web/throttle/index.d.ts +30 -30
  99. package/web/throttle/index.js +50 -50
  100. package/snipping/chart.png +0 -0
  101. package/snipping/image-editor.png +0 -0
@@ -1,19 +1,19 @@
1
- export interface inputType {
2
- type: string
3
- label: string
4
- }
5
-
6
- export interface selectType extends inputType {
7
- value: Array<string>
8
- }
9
-
10
- /**
11
- * 表单输入
12
- * @param form 表单内容
13
- * @returns 返回一个结果数组
14
- */
15
- export interface logformType {
16
- (config: Array<inputType | selectType>): Promise<Array<string | number>>
17
- }
18
-
1
+ export interface inputType {
2
+ type: string
3
+ label: string
4
+ }
5
+
6
+ export interface selectType extends inputType {
7
+ value: Array<string>
8
+ }
9
+
10
+ /**
11
+ * 表单输入
12
+ * @param form 表单内容
13
+ * @returns 返回一个结果数组
14
+ */
15
+ export interface logformType {
16
+ (config: Array<inputType | selectType>): Promise<Array<string | number>>
17
+ }
18
+
19
19
  export let deeplog: logformType
@@ -1,100 +1,100 @@
1
1
  /*!
2
- * logform of OIPage v1.7.0
2
+ * logform of OIPage v1.8.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  const {linelog} = require("../cmdlog/index.js");
6
- let getTitle = function (title) {
7
- return "➤ " + title;
8
- };
9
-
10
- let closeForm = function (rl) {
11
- process.removeAllListeners("keypress");
12
- rl.close();
13
- };
14
-
15
- let selectView = (title, list, index) => {
16
- let txtArray = [];
17
- for (let i = 0; i < list.length; i++) {
18
- txtArray.push(" " + (i == index ? "●" : "○") + " " + list[i]);
19
- }
20
-
21
- linelog(`${title}\n${txtArray.join("\n")}\n`);
22
- };
23
-
24
- function logform(config) {
25
- const rl = require("readline").createInterface({
26
- input: process.stdin,
27
- output: process.stdout
28
- });
29
-
30
- return new Promise(function (resolve, reject) {
31
- let result = [], keyback = () => { };
32
-
33
- console.log("");
34
-
35
- process.stdin.on("keypress", (_str, key) => {
36
- keyback(key.name);
37
- });
38
-
39
- let getResult = (index) => {
40
- if (index >= config.length) {
41
- closeForm(rl);
42
- resolve(result);
43
- } else {
44
- let item = config[index];
45
-
46
- // 文本输入
47
- if (item.type == "input") {
48
-
49
- rl.question(getTitle(item.label), (answer) => {
50
- result.push(answer);
51
- setTimeout(() => {
52
- console.log("");
53
- getResult(index + 1);
54
- }, 50);
55
- });
56
-
57
- }
58
-
59
- // 列表选择
60
- else if (item.type == "select") {
61
- let title = getTitle(item.label);
62
-
63
- let selectIndex = 0;
64
- selectView(title, item.value, selectIndex);
65
- keyback = (keyname) => {
66
- if (keyname == "return") {
67
- result.push(selectIndex);
68
- keyback = () => { };
69
- linelog();
70
- setTimeout(() => {
71
- getResult(index + 1);
72
- }, 50);
73
- } else {
74
- if (keyname == "left" || keyname == "up") {
75
- if (selectIndex > 0) selectIndex -= 1;
76
- else selectIndex = item.value.length - 1;
77
- } else if (keyname == "right" || keyname == "down") {
78
- if (selectIndex < item.value.length - 1) selectIndex += 1;
79
- else selectIndex = 0;
80
- } else {
81
- return;
82
- }
83
- selectView(title, item.value, selectIndex);
84
- }
85
- };
86
-
87
- }
88
-
89
- // 非法类型
90
- else {
91
- closeForm();
92
- reject(new Error("Illegal type!"));
93
- }
94
- }
95
-
96
- };
97
- getResult(0);
98
- });
6
+ let getTitle = function (title) {
7
+ return "➤ " + title;
8
+ };
9
+
10
+ let closeForm = function (rl) {
11
+ process.removeAllListeners("keypress");
12
+ rl.close();
13
+ };
14
+
15
+ let selectView = (title, list, index) => {
16
+ let txtArray = [];
17
+ for (let i = 0; i < list.length; i++) {
18
+ txtArray.push(" " + (i == index ? "●" : "○") + " " + list[i]);
19
+ }
20
+
21
+ linelog(`${title}\n${txtArray.join("\n")}\n`);
22
+ };
23
+
24
+ function logform(config) {
25
+ const rl = require("readline").createInterface({
26
+ input: process.stdin,
27
+ output: process.stdout
28
+ });
29
+
30
+ return new Promise(function (resolve, reject) {
31
+ let result = [], keyback = () => { };
32
+
33
+ console.log("");
34
+
35
+ process.stdin.on("keypress", (_str, key) => {
36
+ keyback(key.name);
37
+ });
38
+
39
+ let getResult = (index) => {
40
+ if (index >= config.length) {
41
+ closeForm(rl);
42
+ resolve(result);
43
+ } else {
44
+ let item = config[index];
45
+
46
+ // 文本输入
47
+ if (item.type == "input") {
48
+
49
+ rl.question(getTitle(item.label), (answer) => {
50
+ result.push(answer);
51
+ setTimeout(() => {
52
+ console.log("");
53
+ getResult(index + 1);
54
+ }, 50);
55
+ });
56
+
57
+ }
58
+
59
+ // 列表选择
60
+ else if (item.type == "select") {
61
+ let title = getTitle(item.label);
62
+
63
+ let selectIndex = 0;
64
+ selectView(title, item.value, selectIndex);
65
+ keyback = (keyname) => {
66
+ if (keyname == "return") {
67
+ result.push(selectIndex);
68
+ keyback = () => { };
69
+ linelog();
70
+ setTimeout(() => {
71
+ getResult(index + 1);
72
+ }, 50);
73
+ } else {
74
+ if (keyname == "left" || keyname == "up") {
75
+ if (selectIndex > 0) selectIndex -= 1;
76
+ else selectIndex = item.value.length - 1;
77
+ } else if (keyname == "right" || keyname == "down") {
78
+ if (selectIndex < item.value.length - 1) selectIndex += 1;
79
+ else selectIndex = 0;
80
+ } else {
81
+ return;
82
+ }
83
+ selectView(title, item.value, selectIndex);
84
+ }
85
+ };
86
+
87
+ }
88
+
89
+ // 非法类型
90
+ else {
91
+ closeForm();
92
+ reject(new Error("Illegal type!"));
93
+ }
94
+ }
95
+
96
+ };
97
+ getResult(0);
98
+ });
99
99
  }
100
100
  exports.logform = logform;
@@ -1,33 +1,33 @@
1
- /**
2
- * 文本分析读取器
3
- */
4
-
5
- export interface readerInstanceType {
6
-
7
- /**
8
- * 当前字符位置
9
- */
10
- index: number
11
-
12
- /**
13
- * 当前字符内容
14
- */
15
- value: string
16
-
17
- /**
18
- * 读取下一个字符
19
- */
20
- readNext(): string
21
-
22
- /**
23
- * 获取往后count个值
24
- * @param count
25
- */
26
- getNextN(count: number): string
27
- }
28
-
29
- export interface readerType {
30
- (plain: string): readerInstanceType
31
- }
32
-
1
+ /**
2
+ * 文本分析读取器
3
+ */
4
+
5
+ export interface readerInstanceType {
6
+
7
+ /**
8
+ * 当前字符位置
9
+ */
10
+ index: number
11
+
12
+ /**
13
+ * 当前字符内容
14
+ */
15
+ value: string
16
+
17
+ /**
18
+ * 读取下一个字符
19
+ */
20
+ readNext(): string
21
+
22
+ /**
23
+ * 获取往后count个值
24
+ * @param count
25
+ */
26
+ getNextN(count: number): string
27
+ }
28
+
29
+ export interface readerType {
30
+ (plain: string): readerInstanceType
31
+ }
32
+
33
33
  export let reader: readerType
@@ -1,26 +1,26 @@
1
1
  /*!
2
- * reader of OIPage v1.7.0
2
+ * reader of OIPage v1.8.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- function reader(plain) {
7
-
8
- let handler = {
9
- index: -1,
10
- value: null
11
- };
12
-
13
- // 读取下一个字符
14
- handler.readNext = function () {
15
- handler.value = handler.index++ < plain.length - 1 ? plain[handler.index] : null;
16
- return handler.value;
17
- };
18
-
19
- // 获取往后num个值
20
- handler.getNextN = function (num) {
21
- return plain.substring(handler.index, num + handler.index > plain.length ? plain.length : num + handler.index);
22
- };
23
-
24
- return handler;
6
+ function reader(plain) {
7
+
8
+ let handler = {
9
+ index: -1,
10
+ value: null
11
+ };
12
+
13
+ // 读取下一个字符
14
+ handler.readNext = function () {
15
+ handler.value = handler.index++ < plain.length - 1 ? plain[handler.index] : null;
16
+ return handler.value;
17
+ };
18
+
19
+ // 获取往后num个值
20
+ handler.getNextN = function (num) {
21
+ return plain.substring(handler.index, num + handler.index > plain.length ? plain.length : num + handler.index);
22
+ };
23
+
24
+ return handler;
25
25
  }
26
26
  exports.reader = reader;
@@ -1,31 +1,31 @@
1
- export type throttleOpportunityType = "begin" | "end" | "wide"
2
-
3
- export interface throttleOptionType {
4
-
5
- /**
6
- * 节流时长
7
- */
8
- time?: number
9
-
10
- /**
11
- * 是否持续节流
12
- */
13
- keep?: boolean
14
-
15
- /**
16
- * 执行时机
17
- *
18
- * begin(开始触发)、end(结束触发)、wide(第一次开始触发,其余结束触发)
19
- */
20
- opportunity?: throttleOpportunityType
21
-
22
- }
23
-
24
- /**
25
- * 节流函数
26
- */
27
- export interface throttleType {
28
- (callback: Function, option?: throttleOptionType): Function
29
- }
30
-
1
+ export type throttleOpportunityType = "begin" | "end" | "wide"
2
+
3
+ export interface throttleOptionType {
4
+
5
+ /**
6
+ * 节流时长
7
+ */
8
+ time?: number
9
+
10
+ /**
11
+ * 是否持续节流
12
+ */
13
+ keep?: boolean
14
+
15
+ /**
16
+ * 执行时机
17
+ *
18
+ * begin(开始触发)、end(结束触发)、wide(第一次开始触发,其余结束触发)
19
+ */
20
+ opportunity?: throttleOpportunityType
21
+
22
+ }
23
+
24
+ /**
25
+ * 节流函数
26
+ */
27
+ export interface throttleType {
28
+ (callback: Function, option?: throttleOptionType): Function
29
+ }
30
+
31
31
  export let throttle: throttleType
@@ -1,56 +1,56 @@
1
1
  /*!
2
- * throttle of OIPage v1.7.0
2
+ * throttle of OIPage v1.8.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- function throttle(callback, _option) {
7
-
8
- // 缺省值
9
- var option = {
10
- time: 200,
11
- keep: false,
12
- opportunity: "end"
13
- };
14
-
15
- // 校对
16
- if (_option) {
17
- for (var key in _option) {
18
- option[key] = _option[key];
19
- }
20
- }
21
-
22
- var hadInterval = false, hadClick = false, oneClick = false, arg;
23
- return function () {
24
- const _this = this;
25
- arg = arguments;
26
-
27
- // 如果前置任务都完成了
28
- if (!hadInterval) {
29
- if (option.opportunity != 'end') {
30
- callback.apply(_this, arg);
31
- }
32
- hadInterval = true;
33
-
34
- var interval = setInterval(() => {
35
- if (hadClick) {
36
- if (!option.keep) {
37
- callback.apply(_this, arg);
38
- }
39
- } else {
40
- if (option.opportunity != 'begin') {
41
- if (oneClick || option.opportunity == 'end') callback.apply(_this, arg);
42
- }
43
- hadInterval = false;
44
- oneClick = false;
45
- clearInterval(interval);
46
- }
47
- hadClick = false;
48
- }, option.time);
49
- } else {
50
- hadClick = true;
51
- oneClick = true;
52
- }
53
-
54
- };
6
+ function throttle(callback, _option) {
7
+
8
+ // 缺省值
9
+ var option = {
10
+ time: 200,
11
+ keep: false,
12
+ opportunity: "end"
13
+ };
14
+
15
+ // 校对
16
+ if (_option) {
17
+ for (var key in _option) {
18
+ option[key] = _option[key];
19
+ }
20
+ }
21
+
22
+ var hadInterval = false, hadClick = false, oneClick = false, arg;
23
+ return function () {
24
+ const _this = this;
25
+ arg = arguments;
26
+
27
+ // 如果前置任务都完成了
28
+ if (!hadInterval) {
29
+ if (option.opportunity != 'end') {
30
+ callback.apply(_this, arg);
31
+ }
32
+ hadInterval = true;
33
+
34
+ var interval = setInterval(() => {
35
+ if (hadClick) {
36
+ if (!option.keep) {
37
+ callback.apply(_this, arg);
38
+ }
39
+ } else {
40
+ if (option.opportunity != 'begin') {
41
+ if (oneClick || option.opportunity == 'end') callback.apply(_this, arg);
42
+ }
43
+ hadInterval = false;
44
+ oneClick = false;
45
+ clearInterval(interval);
46
+ }
47
+ hadClick = false;
48
+ }, option.time);
49
+ } else {
50
+ hadClick = true;
51
+ oneClick = true;
52
+ }
53
+
54
+ };
55
55
  }
56
56
  exports.throttle = throttle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oipage",
3
- "version": "1.7.0",
3
+ "version": "1.8.0-alpha.1",
4
4
  "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
5
  "sideEffects": false,
6
6
  "typings": "./types/index.d.ts",
@@ -1,18 +1,18 @@
1
- export interface callbackType {
2
- (type: "send" | "send@error" | "open" | "error" | "timeout" | "end", params: {
3
- [key: string]: any
4
- }): void
5
- }
6
-
7
- export interface callbackFactoryType {
8
- (): callbackType
9
- }
10
-
11
- /**
12
- * XHR拦截
13
- */
14
- export interface XHRInterceptType {
15
- (callbackFactory: callbackFactoryType): void
16
- }
17
-
1
+ export interface callbackType {
2
+ (type: "send" | "send@error" | "open" | "error" | "timeout" | "end", params: {
3
+ [key: string]: any
4
+ }): void
5
+ }
6
+
7
+ export interface callbackFactoryType {
8
+ (): callbackType
9
+ }
10
+
11
+ /**
12
+ * XHR拦截
13
+ */
14
+ export interface XHRInterceptType {
15
+ (callbackFactory: callbackFactoryType): void
16
+ }
17
+
18
18
  export let XHRIntercept: XHRInterceptType