oipage 1.0.0-alpha.2 → 1.0.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.
package/CHANGELOG CHANGED
@@ -1,58 +1,19 @@
1
- v0.1.0:
2
- date:2024-09-21
3
- changes:
4
- - 初始化版本
5
- 1、命令
6
- (包括:help、server、version、config、delete、copy、pick、move、network、get、post、cat、run)
7
- 2、corejs
8
- * animation 动画
9
- * throttle 节流函数
10
- 3、browserjs
11
- * getStyle 获取节点样式
12
- * onReady 解析完执行
13
- 4、nodejs
14
- * server 服务器
15
- * options 命令行参数解析
16
- * file 文件相关操作
17
- * console 控制台打印
18
- (包括:log、warn、error、linelog、deeplog)
19
- * ajax 网络请求
20
- * network 网络信息等
21
- * data 资源数据
22
- * image 图片相关操作
23
- * loader 文件解析
24
- (simpleScss、xhtml)
25
- 5、stylecss
26
- * 统一浏览器样式 normalize.css
27
- * 十二栅格化 rasterize.css
28
- * 架屏动画 skeleton.css
29
- v0.2.0:
30
- date:2024-12-01
31
- changes:
32
- - 优化改造
33
- 1、nodejs
34
- * linelog新增清除行记录重置功能
35
- * deeplog新增清除行记录重置功能
36
- - 新增功能
37
- 1、nodejs
38
- * plain 读取文本内容
39
- * form 表单录入
40
- (包括:input输入框、select列表选择)
41
- * server hander方法补充api
42
- (包括:getFileInfo()、filePath)
43
1
  v1.0.0:
44
- date:
2
+ date:2025-02-13
45
3
  changes:
46
4
  - 原v0.x的功能将独立一个分支继续维护:https://github.com/oi-contrib/OIPage/blob/v0.x/CHANGELOG
47
5
  (v0.x保持对零碎方法这种形式的支持和维护,此版本开始将作为一个框架或一个系统的工具箱以提供更高效的使用方式,这是一次彻底的非兼容改造)
48
6
  - 初始化版本(v1.x)
49
- 1、API模块
7
+ 1、API功能(浏览器)
50
8
  * animation 动画
51
- * deeplog 进度打印
52
9
  * getStyle 获取节点样式
53
- * linglog 单行打印
54
- * onReady 等待DOM加载完毕执行
55
10
  * setStyle 设置节点样式
11
+ * onReady 加载完毕执行
12
+ * throttle 节流函数
13
+ 2、API功能(Node.js)
14
+ * animation 动画
15
+ * deeplog 进度打印
16
+ * linglog 单行打印
56
17
  * throttle 节流函数
57
- 2、命令
18
+ 3、命令(oipage-cli)
58
19
  * serve 开发服务器
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
- # [OIPage](https://github.com/oi-contrib/OIPage)
2
- 前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等
1
+ - 💘 开源不易,去 <i>[Github给个Star](https://github.com/oi-contrib/OIPage) </i>吧!
2
+
3
+ <img src='https://oi-contrib.github.io/OIPage/images/logo.png' height='100px'/>
3
4
 
4
5
  <p>
5
6
  <a href="https://zxl20070701.github.io/toolbox/#/npm-download?packages=oipage&interval=7">
@@ -7,14 +8,69 @@
7
8
  </a>
8
9
  <a href="https://www.npmjs.com/package/oipage">
9
10
  <img src="https://img.shields.io/npm/v/oipage.svg" alt="npm">
11
+ </a>
12
+ <a href="https://github.com/oi-contrib/OIPage/issues">
13
+ <img src="https://img.shields.io/github/issues/oi-contrib/OIPage" alt="issue">
10
14
  </a>
11
15
  <a href="https://github.com/oi-contrib/OIPage" target='_blank'>
12
16
  <img alt="GitHub repo stars" src="https://img.shields.io/github/stars/oi-contrib/OIPage?style=social">
13
17
  </a>
18
+ <a href="https://gitee.com/oi-contrib/OIPage" target='_blank'>
19
+ <img alt="Gitee repo stars" src="https://gitee.com/oi-contrib/OIPage/badge/star.svg">
20
+ </a>
21
+ <a href="https://gitee.com/oi-contrib/OIPage">
22
+ <img src="https://gitee.com/oi-contrib/OIPage/badge/fork.svg" alt="forks">
23
+ </a>
14
24
  </p>
15
25
 
16
26
  <img src="https://nodei.co/npm/oipage.png?downloads=true&amp;downloadRank=true&amp;stars=true" alt="NPM">
17
27
 
28
+ # [OIPage](https://github.com/oi-contrib/OIPage)
29
+ 前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等。官网地址:[https://oi-contrib.github.io/OIPage](https://oi-contrib.github.io/OIPage)
30
+
31
+ ## 如何使用?
32
+
33
+ 你可以作为一个命令行使用,那么你需要全局安装:
34
+
35
+ ```shell
36
+ npm install -g oipage
37
+ ```
38
+
39
+ 也可以作为项目开发中的一个功能加强,在 package.json 中配置命令或nodejs文件中引入需要的模块使用,那么就在项目中执行安装命令:
40
+
41
+ ```shell
42
+ npm install oipage --save
43
+ ```
44
+
45
+ 全局安装后,就可以直接作为命令行使用了。你可以打印帮助查看:
46
+
47
+ ```shell
48
+ oipage-cli
49
+ ```
50
+
51
+ 比如会出现下列内容:
52
+
53
+ ```
54
+ OIPage@v1.0.0
55
+
56
+ 可以使用的命令如下:
57
+
58
+ 【1】oipage-cli serve 开发服务器
59
+ --port|-p 端口号
60
+ --baseUrl 服务器根目录(相对命令行)
61
+ ......
62
+ ```
63
+
64
+ 根据提示我们知道,比如第一个命令,其提供了一个快速访问本地资源服务器的功能,比如执行:
65
+
66
+ ```shell
67
+ oipage-cli serve -p 8080
68
+ ```
69
+
70
+ 启动成功后,直接访问: http://localhost:8080/ 即可。
71
+
72
+ 如果你需要在项目中使用,我们也提供了一些有用的API,具体可以访问[ 在线文档 ](https://oi-contrib.github.io/OIPage)进行了解。
73
+
18
74
  ## 版权
19
75
 
20
76
  MIT License
package/bin/resolve404.js CHANGED
@@ -18,9 +18,9 @@ module.exports = function (filePath, url) {
18
18
 
19
19
  try {
20
20
  subItems = readdirSync(filePath);
21
- console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Open Folder: " + url + '\x1b[0m ' + new Date().toLocaleString());
21
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Read Folder: " + url + '\x1b[0m ' + new Date().toLocaleString());
22
22
  } catch (e) {
23
- console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Open " + (/\/$/.test(url) ? "Folder" : "File") + ": \x1b[35m" + url + ' 404 Not Found\x1b[0m ' + new Date().toLocaleString());
23
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Read " + (/\/$/.test(url) ? "Folder" : "File") + ": \x1b[35m" + url + ' 404 Not Found\x1b[0m ' + new Date().toLocaleString());
24
24
  try {
25
25
  filePath = join(filePath, "../");
26
26
  subItems = readdirSync(filePath);
package/bin/serve.js CHANGED
@@ -35,7 +35,7 @@ module.exports = function (config) {
35
35
  response.write(readFileSync(filePath));
36
36
  response.end();
37
37
 
38
- console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Open File: " + url + '\x1b[0m ' + new Date().toLocaleString());
38
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Read File: " + url + '\x1b[0m ' + new Date().toLocaleString());
39
39
  }
40
40
 
41
41
  // 否则就是404
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.0.0-alpha.2
2
+ * animation of OIPage v1.0.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -92,14 +92,16 @@ function animation(doback, duration, callback) {
92
92
  doback(deep);
93
93
  }, duration, callback);
94
94
 
95
- // 返回一个函数
96
- // 用于在动画结束前结束动画
97
- return function () {
98
- var i;
99
- for (i in $timers) {
100
- if ($timers[i].id == id) {
101
- $timers[i].id = void 0;
102
- return;
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
+ }
103
105
  }
104
106
  }
105
107
  };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 单行打印
3
+ * @param stream 打印的内容
4
+ */
5
+ export interface linelogType {
6
+ (stream: string): void
7
+ }
8
+
9
+ export let linelog: linelogType
10
+
11
+ /**
12
+ * 进度打印
13
+ * @param percentum 进度0-100
14
+ * @param stream 说明文字,可选
15
+ */
16
+ export interface deeplogType {
17
+ (percentum: number, stream?: string): void
18
+ }
19
+
20
+ export let deeplog: deeplogType
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * linelog of OIPage v1.0.0-alpha.2
2
+ * cmdlog of OIPage v1.0.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -48,5 +48,35 @@ let linelog = (function (stream) {
48
48
 
49
49
  };
50
50
  })(process.stdout);
51
-
51
+
52
+ /**
53
+ * 进度打印
54
+ *
55
+ * @param {number} percentum 进度0-100
56
+ * @param {string} stream 说明文字,可选
57
+ */
58
+ function deeplog (percentum, stream) {
59
+ if (arguments.length == 0) {
60
+ linelog();
61
+ return;
62
+ }
63
+
64
+ if (arguments.length <= 1) stream = "";
65
+
66
+ let txt = "",
67
+ i = 0;
68
+
69
+ // 补充已经有的进度
70
+ for (; i <= percentum && i <= 100; i += 5) {
71
+ txt += "█";
72
+ }
73
+
74
+ // 补充余下的空白
75
+ for (; i <= 100; i += 5) {
76
+ txt += "░";
77
+ }
78
+
79
+ linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
80
+ };
52
81
  exports.linelog = linelog;
82
+ exports.deeplog = deeplog;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.0.0-alpha.2
2
+ * throttle of OIPage v1.0.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "oipage",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0",
4
4
  "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
5
  "sideEffects": false,
6
6
  "scripts": {
7
7
  "dev": "node ./build/index.js watch",
8
8
  "build": "node ./build/index.js",
9
- "docs": "node ./bin/run serve -p 20000 --baseUrl ./docs"
9
+ "serve": "node ./bin/run serve -p 20000"
10
10
  },
11
11
  "bin": {
12
12
  "oipage-cli": "bin/run"
@@ -33,7 +33,7 @@
33
33
  "bugs": {
34
34
  "url": "https://github.com/oi-contrib/OIPage/issues"
35
35
  },
36
- "homepage": "https://github.com/oi-contrib/OIPage",
36
+ "homepage": "https://oi-contrib.github.io/OIPage",
37
37
  "devDependencies": {
38
38
  "oipage": "^0.2.0"
39
39
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.0.0-alpha.2
2
+ * animation of OIPage v1.0.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -18,7 +18,7 @@ var $timerId;
18
18
  *
19
19
  * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
20
20
  */
21
- function animation(doback, duration, callback) {
21
+ export function animation(doback, duration, callback) {
22
22
  if (arguments.length < 2) duration = 400;
23
23
  if (arguments.length < 3) callback = function () { };
24
24
 
@@ -92,17 +92,18 @@ function animation(doback, duration, callback) {
92
92
  doback(deep);
93
93
  }, duration, callback);
94
94
 
95
- // 返回一个函数
96
- // 用于在动画结束前结束动画
97
- return function () {
98
- var i;
99
- for (i in $timers) {
100
- if ($timers[i].id == id) {
101
- $timers[i].id = void 0;
102
- return;
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
+ }
103
105
  }
104
106
  }
105
107
  };
106
108
 
107
- };
108
- export let animation = animation;
109
+ };
@@ -1,14 +1,13 @@
1
1
  /*!
2
- * onReady of OIPage v1.0.0-alpha.2
2
+ * onReady of OIPage v1.0.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- function onReady(callback) {
6
+ export function onReady(callback) {
7
7
  var readyState = document.readyState;
8
8
  if (readyState === 'interactive' || readyState === 'complete') {
9
9
  callback();
10
10
  } else {
11
11
  window.addEventListener("DOMContentLoaded", callback);
12
12
  }
13
- };
14
- export let onReady = onReady;
13
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 设置节点样式
3
+ */
4
+ export interface setStyleType {
5
+ (el: HTMLElement, styles: {
6
+ [key: string]: string | number
7
+ }): void
8
+ }
9
+
10
+ export let setStyle: setStyleType
11
+
12
+ /**
13
+ * 获取节点样式
14
+ */
15
+ export interface getStyleType {
16
+ (el: HTMLElement, name: string): string
17
+ (el: HTMLElement): {
18
+ [key: string]: string
19
+ }
20
+ }
21
+
22
+ export let getStyle: getStyleType
@@ -1,9 +1,15 @@
1
1
  /*!
2
- * getStyle of OIPage v1.0.0-alpha.2
2
+ * style of OIPage v1.0.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- function getStyle(el, name) {
6
+ export function setStyle(el, styles) {
7
+ for (var key in styles) {
8
+ el.style[key] = styles[key];
9
+ }
10
+ };
11
+
12
+ export function getStyle(el, name) {
7
13
 
8
14
  // 获取结点的全部样式
9
15
  var allStyle = document.defaultView && document.defaultView.getComputedStyle ?
@@ -15,5 +21,4 @@ function getStyle(el, name) {
15
21
  allStyle.getPropertyValue(name) :
16
22
  allStyle;
17
23
 
18
- };
19
- export let getStyle = getStyle;
24
+ };
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * throttle of OIPage v1.0.0-alpha.2
2
+ * throttle of OIPage v1.0.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- function throttle(callback, _option) {
6
+ export function throttle(callback, _option) {
7
7
 
8
8
  // 缺省值
9
9
  var option = {
@@ -52,5 +52,4 @@ function throttle(callback, _option) {
52
52
  }
53
53
 
54
54
  };
55
- };
56
- export let throttle = throttle;
55
+ };
@@ -1,10 +0,0 @@
1
- /**
2
- * 进度打印
3
- * @param percentum 进度0-100
4
- * @param stream 说明文字,可选
5
- */
6
- export interface deeplogType {
7
- (percentum: number, stream?: string): void
8
- }
9
-
10
- export let deeplog: deeplogType
@@ -1,35 +0,0 @@
1
- /*!
2
- * deeplog of OIPage v1.0.0-alpha.2
3
- * git+https://github.com/oi-contrib/OIPage.git
4
- */
5
- const {linelog} = require("../linelog/index.js");
6
- /**
7
- * 进度打印
8
- *
9
- * @param {number} percentum 进度0-100
10
- * @param {string} stream 说明文字,可选
11
- */
12
- function deeplog (percentum, stream) {
13
- if (arguments.length == 0) {
14
- linelog();
15
- return;
16
- }
17
-
18
- if (arguments.length <= 1) stream = "";
19
-
20
- let txt = "",
21
- i = 0;
22
-
23
- // 补充已经有的进度
24
- for (; i <= percentum && i <= 100; i += 5) {
25
- txt += "█";
26
- }
27
-
28
- // 补充余下的空白
29
- for (; i <= 100; i += 5) {
30
- txt += "░";
31
- }
32
-
33
- linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
34
- };
35
- exports.deeplog = deeplog;
@@ -1,9 +0,0 @@
1
- /**
2
- * 单行打印
3
- * @param stream 打印的内容
4
- */
5
- export interface linelogType {
6
- (stream: string): void
7
- }
8
-
9
- export let linelog: linelogType
@@ -1,11 +0,0 @@
1
- /**
2
- * 获取节点样式
3
- */
4
- export interface getStyleType {
5
- (el: HTMLElement, name: string): string
6
- (el: HTMLElement): {
7
- [key: string]: string
8
- }
9
- }
10
-
11
- export let getStyle: getStyleType
@@ -1,10 +0,0 @@
1
- /**
2
- * 设置节点样式
3
- */
4
- export interface setStyleType {
5
- (el: HTMLElement, styles: {
6
- [key: string]: string | number
7
- }): void
8
- }
9
-
10
- export let setStyle: setStyleType
@@ -1,11 +0,0 @@
1
- /*!
2
- * setStyle of OIPage v1.0.0-alpha.2
3
- * git+https://github.com/oi-contrib/OIPage.git
4
- */
5
-
6
- function setStyle(el, styles) {
7
- for (var key in styles) {
8
- el.style[key] = styles[key];
9
- }
10
- };
11
- export let setStyle = setStyle;