oipage 1.2.0-alpha.4 → 1.2.0-beta.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/AUTHORS.txt ADDED
@@ -0,0 +1,6 @@
1
+ Authors ordered by first contribution.
2
+
3
+ zxl20070701 <1904314465@qq.com> <https://github.com/zxl20070701>
4
+
5
+ -----------------------------------------------------
6
+ We thank all of them for their contributions!
package/CHANGELOG CHANGED
@@ -34,7 +34,7 @@ v1.1.0:
34
34
  * dist 磁盘操作
35
35
  * run 运行多命令
36
36
  v1.2.0:
37
- date:
37
+ date:2025-03-01
38
38
  changes:
39
39
  - 优化改造
40
40
  1、优化npm包目录结构等
package/bin/serve.js CHANGED
@@ -39,10 +39,11 @@ module.exports = function (config) {
39
39
  };
40
40
 
41
41
  let sendType = "";
42
+ let entry = headers.Accept !== "*/*";
42
43
 
43
44
  // 如果文件小于10M,认为不大,直接读取
44
45
  if (fileInfo.size < 10 * 1024 * 1024) {
45
- let { source, resolveImport } = resolveImportFactory(basePath, filePath, headers.Accept === "*/*", urlArray[1] === "download")
46
+ let { source, resolveImport } = resolveImportFactory(basePath, filePath, entry, urlArray[1] === "download")
46
47
 
47
48
  // 只处理非下载文件
48
49
  // 过大的也不进行处理
@@ -52,9 +53,10 @@ module.exports = function (config) {
52
53
  source = config.module.rules[i].use.call({
53
54
  root: basePath, // 服务器根路径
54
55
  path: filePath.replace(basePath, ""), // 文件相对路径
55
- entry: headers.Accept !== "*/*", // 是否是浏览器地址栏直接访问
56
- setFileType(fileType) { // 设置文件类型
57
- responseHeader['Content-type'] = fileType + ";charset=utf-8";
56
+ entry, // 是否是浏览器地址栏直接访问
57
+ setFileType(_fileType) { // 设置文件类型
58
+ fileType = _fileType;
59
+ responseHeader['Content-type'] = _fileType + ";charset=utf-8";
58
60
  }
59
61
  }, source);
60
62
  break;
@@ -64,7 +66,7 @@ module.exports = function (config) {
64
66
 
65
67
  sendType = "Read";
66
68
  response.writeHead('200', responseHeader);
67
- response.write(resolveImport(source));
69
+ response.write(resolveImport(source, fileType !== "application/javascript"));
68
70
  response.end();
69
71
  }
70
72
 
@@ -1,7 +1,7 @@
1
1
  const { readFileSync, existsSync, lstatSync } = require("fs");
2
2
  const { join } = require("path");
3
3
 
4
- module.exports = function (basePath, filePath, needResolve, isDownload) {
4
+ module.exports = function (basePath, filePath, entry, isDownload) {
5
5
  let source = readFileSync(filePath);
6
6
  let resolveImport = content => content;
7
7
 
@@ -60,10 +60,10 @@ module.exports = function (basePath, filePath, needResolve, isDownload) {
60
60
  // todo
61
61
  }
62
62
 
63
- // 如果需要解析
64
- else if (needResolve) {
63
+ // 如果不是直接访问的
64
+ else if (!entry) {
65
65
  source += "";
66
- resolveImport = __resolveImport;
66
+ resolveImport = (content, notResolve) => notResolve ? content : __resolveImport(content);
67
67
  }
68
68
 
69
69
  // 如果是.html或.htm结尾
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.2.0-alpha.4
2
+ * animation of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * cmdlog of OIPage v1.2.0-alpha.4
2
+ * cmdlog of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * disk of OIPage v1.2.0-alpha.4
2
+ * disk of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * logform of OIPage v1.2.0-alpha.4
2
+ * logform of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  const {linelog} = require("../cmdlog/index.js");
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.2.0-alpha.4
2
+ * throttle of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oipage",
3
- "version": "1.2.0-alpha.4",
3
+ "version": "1.2.0-beta.0",
4
4
  "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.2.0-alpha.4
2
+ * animation of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * onReady of OIPage v1.2.0-alpha.4
2
+ * onReady of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * style of OIPage v1.2.0-alpha.4
2
+ * style of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.2.0-alpha.4
2
+ * throttle of OIPage v1.2.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5