oipage 1.3.1 → 1.4.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 (46) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +83 -76
  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 +24 -24
  9. package/bin/intercept.js +15 -15
  10. package/bin/run +96 -96
  11. package/bin/serve.d.ts +51 -0
  12. package/bin/serve.js +131 -128
  13. package/bin/template/404.html +171 -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/nodejs/animation/index.d.ts +19 -19
  19. package/nodejs/animation/index.js +104 -104
  20. package/nodejs/cmdlog/index.d.ts +20 -20
  21. package/nodejs/cmdlog/index.js +75 -75
  22. package/nodejs/disk/index.d.ts +16 -16
  23. package/nodejs/disk/index.js +78 -78
  24. package/nodejs/json/index.d.ts +9 -9
  25. package/nodejs/json/index.js +206 -206
  26. package/nodejs/logform/index.d.ts +18 -18
  27. package/nodejs/logform/index.js +94 -94
  28. package/nodejs/reader/index.d.ts +32 -32
  29. package/nodejs/reader/index.js +20 -20
  30. package/nodejs/throttle/index.d.ts +30 -30
  31. package/nodejs/throttle/index.js +50 -50
  32. package/package.json +40 -40
  33. package/web/animation/index.d.ts +19 -19
  34. package/web/animation/index.js +104 -104
  35. package/web/json/index.d.ts +9 -9
  36. package/web/json/index.js +206 -206
  37. package/web/onReady/index.d.ts +7 -7
  38. package/web/onReady/index.js +8 -8
  39. package/web/performChunk/index.d.ts +4 -4
  40. package/web/performChunk/index.js +19 -19
  41. package/web/reader/index.d.ts +32 -32
  42. package/web/reader/index.js +20 -20
  43. package/web/style/index.d.ts +21 -21
  44. package/web/style/index.js +19 -19
  45. package/web/throttle/index.d.ts +30 -30
  46. package/web/throttle/index.js +50 -50
@@ -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.3.1
2
+ * reader of OIPage v1.4.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.3.1
2
+ * throttle of OIPage v1.4.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,40 +1,40 @@
1
- {
2
- "name": "oipage",
3
- "version": "1.3.1",
4
- "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
- "sideEffects": false,
6
- "scripts": {
7
- "dev": "node ./build/index.js watch",
8
- "build": "node ./build/index.js",
9
- "serve": "node ./bin/run serve --config ./oipage.config.js"
10
- },
11
- "bin": {
12
- "oipage-cli": "bin/run"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/oi-contrib/OIPage.git"
17
- },
18
- "keywords": [
19
- "dev",
20
- "server",
21
- "style",
22
- "css",
23
- "nodejs",
24
- "core",
25
- "oipage",
26
- "browser"
27
- ],
28
- "author": {
29
- "name": "zxl20070701",
30
- "url": "https://zxl20070701.github.io/notebook/home.html"
31
- },
32
- "license": "MIT",
33
- "bugs": {
34
- "url": "https://github.com/oi-contrib/OIPage/issues"
35
- },
36
- "homepage": "https://oi-contrib.github.io/OIPage",
37
- "dependencies": {
38
- "vislite": "^1.4.0"
39
- }
40
- }
1
+ {
2
+ "name": "oipage",
3
+ "version": "1.4.0-alpha.1",
4
+ "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
+ "sideEffects": false,
6
+ "scripts": {
7
+ "dev": "node ./build/index.js watch",
8
+ "build": "node ./build/index.js",
9
+ "serve": "node ./bin/run serve --config ./oipage.config.js"
10
+ },
11
+ "bin": {
12
+ "oipage-cli": "bin/run"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/oi-contrib/OIPage.git"
17
+ },
18
+ "keywords": [
19
+ "dev",
20
+ "server",
21
+ "style",
22
+ "css",
23
+ "nodejs",
24
+ "core",
25
+ "oipage",
26
+ "browser"
27
+ ],
28
+ "author": {
29
+ "name": "zxl20070701",
30
+ "url": "https://zxl20070701.github.io/notebook/home.html"
31
+ },
32
+ "license": "MIT",
33
+ "bugs": {
34
+ "url": "https://github.com/oi-contrib/OIPage/issues"
35
+ },
36
+ "homepage": "https://oi-contrib.github.io/OIPage",
37
+ "dependencies": {
38
+ "vislite": "^1.4.0"
39
+ }
40
+ }
@@ -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.3.1
2
+ * animation of OIPage v1.4.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
- 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
  }
@@ -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