oipage 1.4.0-alpha.1 → 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 +55 -50
  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
@@ -1,20 +1,20 @@
1
- interface animationResult {
2
-
3
- /**
4
- * 一个函数,调用该函数,可以提前结束动画
5
- */
6
- stop(): void
7
- }
8
-
9
- interface animationFun {
10
- (deep: number): void
11
- }
12
-
13
- /**
14
- * 轮询动画
15
- */
16
- export interface animationType {
17
- (doback: animationFun, duration?: number, callback?: animationFun): animationResult
18
- }
19
-
1
+ interface animationResult {
2
+
3
+ /**
4
+ * 一个函数,调用该函数,可以提前结束动画
5
+ */
6
+ stop(): void
7
+ }
8
+
9
+ interface animationFun {
10
+ (deep: number): void
11
+ }
12
+
13
+ /**
14
+ * 轮询动画
15
+ */
16
+ export interface animationType {
17
+ (doback: animationFun, duration?: number, callback?: animationFun): animationResult
18
+ }
19
+
20
20
  export let animation: animationType
@@ -1,109 +1,109 @@
1
1
  /*!
2
- * animation of OIPage v1.4.0-alpha.1
2
+ * animation of OIPage v1.4.0
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
- export 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
+ export 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
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 数字格式化
3
+ */
4
+ export interface numberFormatType {
5
+ (input: number | string): string
6
+ }
7
+
8
+ export let numberFormat: numberFormatType
9
+
10
+ /**
11
+ * 日期格式化
12
+ */
13
+ export interface dateFormatType {
14
+ (input?: string | Date, option?: {
15
+
16
+ /**
17
+ * 输入格式
18
+ */
19
+ inputFormat?: string
20
+
21
+ /**
22
+ * 输出格式
23
+ */
24
+ format?: string
25
+ }): string
26
+ }
27
+
28
+ export let dateFormat: dateFormatType
29
+
@@ -0,0 +1,112 @@
1
+ /*!
2
+ * format of OIPage v1.4.0
3
+ * git+https://github.com/oi-contrib/OIPage.git
4
+ */
5
+
6
+ export function numberFormat(input) {
7
+ if (!input && input !== 0) {
8
+ return '';
9
+ } else {
10
+ input = input + "";
11
+
12
+ var decimalValue, integerValue;
13
+
14
+ var dotIndex = input.indexOf('.');
15
+ if (dotIndex == -1) {
16
+ decimalValue = ".00";
17
+ integerValue = input;
18
+ } else {
19
+ var temp = input.split(".");
20
+ decimalValue = "." + (temp[1] + "0").substring(0, 2);
21
+ integerValue = temp[0];
22
+ }
23
+
24
+ var integerArray = []
25
+ for (var index = integerValue.length; index > 0; index -= 3) {
26
+ integerArray.unshift(integerValue.substring(index > 2 ? index - 3 : 0, index));
27
+ }
28
+
29
+ return integerArray.join(",") + decimalValue;
30
+ }
31
+ }
32
+
33
+ export function dateFormat(input, option) {
34
+ option = option || option;
35
+ var dateObj;
36
+
37
+ // 如果无值,就用当前日期
38
+ if (!input) {
39
+ dateObj = new Date();
40
+ }
41
+
42
+ // 日期对象
43
+ else if (typeof input == 'object' && input.constructor === Date) {
44
+ dateObj = input;
45
+ }
46
+
47
+ // 否则就尝试创建日期对象
48
+ else if (!option.inputFormat) {
49
+ dateObj = new Date(input);
50
+ if (dateObj + "" == "Invalid Date") {
51
+ console.error("非法的日期格式:" + input, dateObj);
52
+ return "";
53
+ }
54
+ }
55
+
56
+ // 年、月、日、时、分、秒
57
+ var single = {
58
+ yyyy: 0, MM: 0, dd: 0, HH: 0, mm: 0, ss: 0
59
+ };
60
+
61
+ // 如果获取了日期实例
62
+ if (dateObj) {
63
+
64
+ single.yyyy = dateObj.getFullYear();
65
+ single.MM = dateObj.getMonth() + 1;
66
+ single.dd = dateObj.getDate();
67
+
68
+ single.HH = dateObj.getHours();
69
+ single.mm = dateObj.getMinutes();
70
+ single.ss = dateObj.getSeconds();
71
+ }
72
+
73
+ // 否则只能借助 inputFormat 来解析
74
+ else {
75
+ var inputFormat = option.inputFormat + "", valIndex = 0;
76
+ for (var index = 0; index < inputFormat.length; index++) {
77
+
78
+ // 年
79
+ if (inputFormat.substring(index, index + 4) == "yyyy") {
80
+ single.yyyy = +input.substring(valIndex, valIndex + 4);
81
+
82
+ valIndex += 4;
83
+ index += 3;
84
+ } else {
85
+ var curFlag = inputFormat.substring(index, index + 2);
86
+ if (["MM", "dd", "HH", "mm", "ss"].indexOf(curFlag) > -1) {
87
+ var valContent = input[valIndex];
88
+ if (/\d/.test(input[valIndex + 1])) {
89
+ valContent += input[valIndex + 1];
90
+ valIndex += 2;
91
+ } else {
92
+ valIndex += 1;
93
+ }
94
+
95
+ (single)[curFlag] = +valContent;
96
+ index += 1;
97
+ } else {
98
+ valIndex += 1;
99
+ }
100
+ }
101
+ }
102
+ }
103
+
104
+ if (single.MM < 10) single.MM = "0" + single.MM;
105
+ if (single.dd < 10) single.dd = "0" + single.dd;
106
+ if (single.HH < 10) single.HH = "0" + single.HH;
107
+ if (single.mm < 10) single.mm = "0" + single.mm;
108
+ if (single.ss < 10) single.ss = "0" + single.ss;
109
+
110
+ var format = option.format || "yyyy/MM/dd";
111
+ return format.replace("yyyy", single.yyyy).replace("MM", single.MM).replace("dd", single.dd).replace("HH", single.HH).replace("mm", single.mm).replace("ss", single.ss);
112
+ };
@@ -1,10 +1,10 @@
1
- /**
2
- * 把一段字符串变成json返回
3
- * @param express 非严格json字符串
4
- * @returns 返回一个JSON对象
5
- */
6
- export interface strToJsonType {
7
- (express:string): object
8
- }
9
-
1
+ /**
2
+ * 把一段字符串变成json返回
3
+ * @param express 非严格json字符串
4
+ * @returns 返回一个JSON对象
5
+ */
6
+ export interface strToJsonType {
7
+ (express:string): object
8
+ }
9
+
10
10
  export let strToJson: strToJsonType