@oipage/cli 0.3.0-alpha.5 → 0.3.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 (74) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +47 -47
  4. package/LICENSE +20 -20
  5. package/README.md +132 -132
  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 +106 -106
  10. package/bin/data/mineTypes.json +104 -104
  11. package/bin/disk.js +42 -42
  12. package/bin/help.js +55 -55
  13. package/bin/intercept.js +15 -15
  14. package/bin/network.js +21 -21
  15. package/bin/notebook/index.js +8 -8
  16. package/bin/proxy.js +82 -82
  17. package/bin/run +146 -146
  18. package/bin/serve.js +318 -318
  19. package/bin/template/404.html +184 -184
  20. package/bin/tools/deleteEmptyFolder.js +33 -33
  21. package/bin/tools/format.js +75 -75
  22. package/bin/tools/isBinary.js +83 -83
  23. package/bin/tools/network.js +42 -42
  24. package/bin/tools/openBrowser.js +34 -34
  25. package/bin/tools/resolve404.js +98 -98
  26. package/bin/tools/resolveImport.js +96 -96
  27. package/bin/website-htmls/components/ui-select-file/index.html +8 -8
  28. package/bin/website-htmls/components/ui-select-file/index.js +42 -42
  29. package/bin/website-htmls/components/ui-select-file/index.scss +44 -44
  30. package/bin/website-htmls/dialogs/imageSize/index.html +54 -54
  31. package/bin/website-htmls/dialogs/imageSize/index.js +53 -53
  32. package/bin/website-htmls/dialogs/imageSize/index.scss +140 -140
  33. package/bin/website-htmls/dialogs/index.js +52 -52
  34. package/bin/website-htmls/images/addFile.svg +1 -1
  35. package/bin/website-htmls/images/img-to-pdf.svg +1 -1
  36. package/bin/website-htmls/index.html +17 -17
  37. package/bin/website-htmls/main.js +13 -13
  38. package/bin/website-htmls/pages/App/index.html +6 -6
  39. package/bin/website-htmls/pages/App/index.js +22 -22
  40. package/bin/website-htmls/pages/App/index.scss +43 -43
  41. package/bin/website-htmls/pages/appStore/index.html +7 -7
  42. package/bin/website-htmls/pages/appStore/index.js +19 -19
  43. package/bin/website-htmls/pages/appStore/index.scss +54 -54
  44. package/bin/website-htmls/pages/chart/index.html +8 -8
  45. package/bin/website-htmls/pages/chart/index.js +72 -72
  46. package/bin/website-htmls/pages/chart/index.scss +71 -71
  47. package/bin/website-htmls/pages/home/index.html +19 -19
  48. package/bin/website-htmls/pages/home/index.js +19 -19
  49. package/bin/website-htmls/pages/home/index.scss +87 -87
  50. package/bin/website-htmls/pages/image-editor/index.html +27 -27
  51. package/bin/website-htmls/pages/image-editor/index.js +106 -106
  52. package/bin/website-htmls/pages/image-editor/index.scss +69 -69
  53. package/bin/website-htmls/pages/img-to-pdf/index.html +3 -3
  54. package/bin/website-htmls/pages/img-to-pdf/index.js +44 -44
  55. package/bin/website-htmls/pages/img-to-pdf/index.scss +9 -9
  56. package/bin/website-htmls/pages/recorder-screen/index.html +15 -15
  57. package/bin/website-htmls/pages/recorder-screen/index.js +227 -227
  58. package/bin/website-htmls/pages/recorder-screen/index.scss +52 -52
  59. package/bin/website-htmls/router.config.js +29 -29
  60. package/bin/website-htmls/styles/common.css +44 -44
  61. package/bin/website-htmls/styles/normalize.css +94 -94
  62. package/bin/website-plugins/intercept/chart.js +33 -33
  63. package/bin/website-plugins/intercept/getPackage.js +17 -17
  64. package/bin/website-plugins/intercept/head.js +8 -8
  65. package/bin/website-plugins/intercept/index.js +8 -8
  66. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +55 -55
  67. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +36 -36
  68. package/bin/website-plugins/loader/index.js +11 -11
  69. package/bin/website-plugins/loader/oipage-html-loader.js +7 -7
  70. package/bin/website-plugins/loader/oipage-scss-loader.js +149 -149
  71. package/docs/config.md +106 -106
  72. package/package.json +42 -42
  73. package/src/index.js +29 -29
  74. package/types/serve.d.ts +83 -83
@@ -1,97 +1,97 @@
1
- const { readFileSync, existsSync, statSync } = require("fs");
2
- const { join } = require("path");
3
- const { testIntercept } = require("../intercept.js");
4
-
5
- module.exports = function (basePath, filePath, entry, intercept, isDownload, isWebsite) {
6
- basePath = join(basePath, "./");
7
-
8
- if (statSync(filePath).isDirectory()) { return { source: "", resolveImport: content => content }; }
9
- let source = readFileSync(filePath);
10
- let resolveImport = content => content;
11
-
12
- let __resolveImport = function (content) {
13
- return content.replace(/import [^'"]* from (['"])([^'"]*)['"]/sg, function (_importCode, _, _importUrl) {
14
- if (/^[./]/.test(_importUrl)) {
15
- return _importCode;
16
- } else {
17
- return _importCode.replace(_importUrl, _importUrl.replace(/((@[^/]+\/){0,1}[^/])+/s, function (npmName) {
18
-
19
- if (testIntercept(npmName, intercept)) {
20
- return (isWebsite ? "/@website/@modules/" : "/@modules/") + npmName;
21
- } else {
22
-
23
- let node_modulesRootPath = join(filePath, "../");
24
- let prePath = "";
25
- while (true) {
26
- let npmBundlePath = join(node_modulesRootPath, "./node_modules/", npmName);
27
-
28
- // 如果存在
29
- if (existsSync(npmBundlePath) && statSync(npmBundlePath).isDirectory()) {
30
- let npmNameValue = npmName;
31
-
32
- // 对于类似 import VISLite from "vislite"
33
- // 需要把包名解析成具体的文件
34
- if (!/\//.test(_importUrl
35
-
36
- // 兼容 "@oipage/browser.js" 类似的包
37
- // 2026年09月11日 于南宁
38
- .replace(/@[^/]+\//, ""))) {
39
- let bundlePackage = require(join(npmBundlePath, "./package.json"));
40
- npmNameValue = npmName + "/" + bundlePackage.main;
41
- }
42
-
43
- return (prePath ? prePath : "./") + "node_modules/" + npmNameValue;
44
- }
45
-
46
- if (node_modulesRootPath === basePath) {
47
-
48
- // 如果命令行根目录是一个项目
49
- let packagePath = join(basePath, "./package.json");
50
-
51
- // statSync代替lstatSync,修复符号链接指向文件夹时无法正确判断文件
52
- // 2026年09月10日 于南宁
53
- if (existsSync(packagePath) && !statSync(packagePath).isDirectory()) {
54
- let bundlePackage = require(packagePath);
55
- if (!/\//.test(_importUrl)) {
56
- return "/" + bundlePackage.main;
57
- } else {
58
- return "/"
59
- }
60
- }
61
-
62
- return "/@modules/" + npmName;
63
- } else {
64
- node_modulesRootPath = join(node_modulesRootPath, "../");
65
- prePath = "../" + prePath;
66
- }
67
- }
68
-
69
- }
70
- }));
71
- }
72
- });
73
- };
74
-
75
- // 如果是下载
76
- if (isDownload) {
77
- // todo
78
- }
79
-
80
- // 如果不是直接访问的
81
- else if (!entry) {
82
- source += "";
83
- resolveImport = (content, notResolve) => notResolve ? content : __resolveImport(content);
84
- }
85
-
86
- // 如果是.html或.htm结尾
87
- else if (/\.html{0,1}$/.test(filePath)) {
88
- source = (source + "").replace(/<script type="module">(.*)<\/script>/sg, function (_, _matchCode) {
89
- return `<script type="module">${__resolveImport(_matchCode)}</script>`;
90
- });
91
- }
92
-
93
- return {
94
- source,
95
- resolveImport
96
- };
1
+ const { readFileSync, existsSync, statSync } = require("fs");
2
+ const { join } = require("path");
3
+ const { testIntercept } = require("../intercept.js");
4
+
5
+ module.exports = function (basePath, filePath, entry, intercept, isDownload, isWebsite) {
6
+ basePath = join(basePath, "./");
7
+
8
+ if (statSync(filePath).isDirectory()) { return { source: "", resolveImport: content => content }; }
9
+ let source = readFileSync(filePath);
10
+ let resolveImport = content => content;
11
+
12
+ let __resolveImport = function (content) {
13
+ return content.replace(/import [^'"]* from (['"])([^'"]*)['"]/sg, function (_importCode, _, _importUrl) {
14
+ if (/^[./]/.test(_importUrl)) {
15
+ return _importCode;
16
+ } else {
17
+ return _importCode.replace(_importUrl, _importUrl.replace(/((@[^/]+\/){0,1}[^/])+/s, function (npmName) {
18
+
19
+ if (testIntercept(npmName, intercept)) {
20
+ return (isWebsite ? "/@website/@modules/" : "/@modules/") + npmName;
21
+ } else {
22
+
23
+ let node_modulesRootPath = join(filePath, "../");
24
+ let prePath = "";
25
+ while (true) {
26
+ let npmBundlePath = join(node_modulesRootPath, "./node_modules/", npmName);
27
+
28
+ // 如果存在
29
+ if (existsSync(npmBundlePath) && statSync(npmBundlePath).isDirectory()) {
30
+ let npmNameValue = npmName;
31
+
32
+ // 对于类似 import VISLite from "vislite"
33
+ // 需要把包名解析成具体的文件
34
+ if (!/\//.test(_importUrl
35
+
36
+ // 兼容 "@oipage/browser.js" 类似的包
37
+ // 2026年09月11日 于南宁
38
+ .replace(/@[^/]+\//, ""))) {
39
+ let bundlePackage = require(join(npmBundlePath, "./package.json"));
40
+ npmNameValue = npmName + "/" + bundlePackage.main;
41
+ }
42
+
43
+ return (prePath ? prePath : "./") + "node_modules/" + npmNameValue;
44
+ }
45
+
46
+ if (node_modulesRootPath === basePath) {
47
+
48
+ // 如果命令行根目录是一个项目
49
+ let packagePath = join(basePath, "./package.json");
50
+
51
+ // statSync代替lstatSync,修复符号链接指向文件夹时无法正确判断文件
52
+ // 2026年09月10日 于南宁
53
+ if (existsSync(packagePath) && !statSync(packagePath).isDirectory()) {
54
+ let bundlePackage = require(packagePath);
55
+ if (!/\//.test(_importUrl)) {
56
+ return "/" + bundlePackage.main;
57
+ } else {
58
+ return "/"
59
+ }
60
+ }
61
+
62
+ return "/@modules/" + npmName;
63
+ } else {
64
+ node_modulesRootPath = join(node_modulesRootPath, "../");
65
+ prePath = "../" + prePath;
66
+ }
67
+ }
68
+
69
+ }
70
+ }));
71
+ }
72
+ });
73
+ };
74
+
75
+ // 如果是下载
76
+ if (isDownload) {
77
+ // todo
78
+ }
79
+
80
+ // 如果不是直接访问的
81
+ else if (!entry) {
82
+ source += "";
83
+ resolveImport = (content, notResolve) => notResolve ? content : __resolveImport(content);
84
+ }
85
+
86
+ // 如果是.html或.htm结尾
87
+ else if (/\.html{0,1}$/.test(filePath)) {
88
+ source = (source + "").replace(/<script type="module">(.*)<\/script>/sg, function (_, _matchCode) {
89
+ return `<script type="module">${__resolveImport(_matchCode)}</script>`;
90
+ });
91
+ }
92
+
93
+ return {
94
+ source,
95
+ resolveImport
96
+ };
97
97
  };
@@ -1,9 +1,9 @@
1
- <div class="ui-select-file-view">
2
- <h2 class="title" z-bind="_props.title"></h2>
3
- <div class="tips" z-bind="_props.tips"></div>
4
- <div class="file">
5
- <input type="file" :multiple="_props.multiple?'multiple':'none'" id="input" z-on:change.stop="doChange"
6
- z-bind:accept="accept" />
7
- <label for="input" z-bind="'选择'+_props.type+'文件'"></label>
8
- </div>
1
+ <div class="ui-select-file-view">
2
+ <h2 class="title" z-bind="_props.title"></h2>
3
+ <div class="tips" z-bind="_props.tips"></div>
4
+ <div class="file">
5
+ <input type="file" :multiple="_props.multiple?'multiple':'none'" id="input" z-on:change.stop="doChange"
6
+ z-bind:accept="accept" />
7
+ <label for="input" z-bind="'选择'+_props.type+'文件'"></label>
8
+ </div>
9
9
  </div>
@@ -1,43 +1,43 @@
1
- import { defineElement } from "zipaper";
2
- import template from "./index.html";
3
- import style from "./index.scss";
4
-
5
- export default defineElement({
6
- template,
7
- emits: ["change"],
8
- props: {
9
- title: {
10
- type: String,
11
- required: true,
12
- },
13
- tips: {
14
- type: String,
15
- required: true,
16
- },
17
- type: {
18
- type: String,
19
- required: true,
20
- },
21
- multiple: {
22
- type: Boolean,
23
- default: true
24
- }
25
- },
26
- data() {
27
- return {
28
- accept: {
29
- pdf: "application/pdf",
30
- image: "image/*",
31
- video: "video/*",
32
- }[this._props.type]
33
- };
34
- },
35
- methods: {
36
- doChange(event, target) {
37
- this.$emit("change", target.files);
38
- }
39
- },
40
- style: {
41
- content: style
42
- }
1
+ import { defineElement } from "zipaper";
2
+ import template from "./index.html";
3
+ import style from "./index.scss";
4
+
5
+ export default defineElement({
6
+ template,
7
+ emits: ["change"],
8
+ props: {
9
+ title: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ tips: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ type: {
18
+ type: String,
19
+ required: true,
20
+ },
21
+ multiple: {
22
+ type: Boolean,
23
+ default: true
24
+ }
25
+ },
26
+ data() {
27
+ return {
28
+ accept: {
29
+ pdf: "application/pdf",
30
+ image: "image/*",
31
+ video: "video/*",
32
+ }[this._props.type]
33
+ };
34
+ },
35
+ methods: {
36
+ doChange(event, target) {
37
+ this.$emit("change", target.files);
38
+ }
39
+ },
40
+ style: {
41
+ content: style
42
+ }
43
43
  });
@@ -1,45 +1,45 @@
1
- .ui-select-file-view{
2
- &>.title {
3
- text-align: center;
4
- font-weight: 700;
5
- color: rgb(26, 26, 26);
6
- font-size: 36px;
7
- line-height: 48px;
8
- padding-top: 30px;
9
- }
10
-
11
- &>.tips {
12
- text-align: center;
13
- line-height: 30px;
14
- font-size: 22px;
15
- color: rgb(26, 26, 26);
16
- font-weight: 300;
17
- }
18
-
19
- &>.file {
20
- text-align: center;
21
- margin-top: 30px;
22
-
23
- input {
24
- display: none;
25
- }
26
-
27
- label {
28
- line-height: 50px;
29
- display: inline-block;
30
- border: 1px solid gray;
31
- background-image: url("./images/addFile.svg");
32
- background-repeat: no-repeat;
33
- background-position: 5px center;
34
- background-size: auto 70%;
35
- padding-left: 40px;
36
- padding-right: 10px;
37
- border-radius: 5px;
38
-
39
- &:hover {
40
- text-decoration: underline;
41
- cursor: pointer;
42
- }
43
- }
44
- }
1
+ .ui-select-file-view{
2
+ &>.title {
3
+ text-align: center;
4
+ font-weight: 700;
5
+ color: rgb(26, 26, 26);
6
+ font-size: 36px;
7
+ line-height: 48px;
8
+ padding-top: 30px;
9
+ }
10
+
11
+ &>.tips {
12
+ text-align: center;
13
+ line-height: 30px;
14
+ font-size: 22px;
15
+ color: rgb(26, 26, 26);
16
+ font-weight: 300;
17
+ }
18
+
19
+ &>.file {
20
+ text-align: center;
21
+ margin-top: 30px;
22
+
23
+ input {
24
+ display: none;
25
+ }
26
+
27
+ label {
28
+ line-height: 50px;
29
+ display: inline-block;
30
+ border: 1px solid gray;
31
+ background-image: url("./images/addFile.svg");
32
+ background-repeat: no-repeat;
33
+ background-position: 5px center;
34
+ background-size: auto 70%;
35
+ padding-left: 40px;
36
+ padding-right: 10px;
37
+ border-radius: 5px;
38
+
39
+ &:hover {
40
+ text-decoration: underline;
41
+ cursor: pointer;
42
+ }
43
+ }
44
+ }
45
45
  }
@@ -1,55 +1,55 @@
1
- <h2 z-bind="title"></h2>
2
- <div class="right-btn">
3
- <div>
4
- <fieldset>
5
- <legend>
6
- 当前大小
7
- </legend>
8
- <ul z-bind:lock="title=='图像大小'?'yes':'no'">
9
- <li>
10
- <label>宽度:</label>
11
- <span z-bind="width"></span>px
12
- </li>
13
- <li>
14
- <label>宽度:</label>
15
- <span z-bind="height"></span>px
16
- </li>
17
- </ul>
18
- </fieldset>
19
- <fieldset>
20
- <legend>
21
- 新建大小
22
- </legend>
23
- <ul z-bind:lock="title=='图像大小'?'yes':'no'">
24
- <li>
25
- <label>宽度(W):</label>
26
- <input type="text" z-model="newWidth" z-on:input="calcHeight">
27
- px
28
- </li>
29
- <li>
30
- <label>高度(H):</label>
31
- <input type="text" z-model="newHeight" z-on:input="calcWidth">
32
- px
33
- </li>
34
- <li z-bind:active="title=='画布大小'?'yes':'no'">
35
- <label>定位:</label>
36
- <div class="change-type" z-bind:type="changeType">
37
- <span z-on:click="doChangeType" val="left-top"></span>
38
- <span z-on:click="doChangeType" val="center-top"></span>
39
- <span z-on:click="doChangeType" val="right-top"></span>
40
- <span z-on:click="doChangeType" val="left-middle"></span>
41
- <span z-on:click="doChangeType" val="center-middle"></span>
42
- <span z-on:click="doChangeType" val="right-middle"></span>
43
- <span z-on:click="doChangeType" val="left-bottom"></span>
44
- <span z-on:click="doChangeType" val="center-bottom"></span>
45
- <span z-on:click="doChangeType" val="right-bottom"></span>
46
- </div>
47
- </li>
48
- </ul>
49
- </fieldset>
50
- </div>
51
- <div>
52
- <button z-on:click="doSubmit">确定</button>
53
- <button z-on:click="doClose">取消</button>
54
- </div>
1
+ <h2 z-bind="title"></h2>
2
+ <div class="right-btn">
3
+ <div>
4
+ <fieldset>
5
+ <legend>
6
+ 当前大小
7
+ </legend>
8
+ <ul z-bind:lock="title=='图像大小'?'yes':'no'">
9
+ <li>
10
+ <label>宽度:</label>
11
+ <span z-bind="width"></span>px
12
+ </li>
13
+ <li>
14
+ <label>宽度:</label>
15
+ <span z-bind="height"></span>px
16
+ </li>
17
+ </ul>
18
+ </fieldset>
19
+ <fieldset>
20
+ <legend>
21
+ 新建大小
22
+ </legend>
23
+ <ul z-bind:lock="title=='图像大小'?'yes':'no'">
24
+ <li>
25
+ <label>宽度(W):</label>
26
+ <input type="text" z-model="newWidth" z-on:input="calcHeight">
27
+ px
28
+ </li>
29
+ <li>
30
+ <label>高度(H):</label>
31
+ <input type="text" z-model="newHeight" z-on:input="calcWidth">
32
+ px
33
+ </li>
34
+ <li z-bind:active="title=='画布大小'?'yes':'no'">
35
+ <label>定位:</label>
36
+ <div class="change-type" z-bind:type="changeType">
37
+ <span z-on:click="doChangeType" val="left-top"></span>
38
+ <span z-on:click="doChangeType" val="center-top"></span>
39
+ <span z-on:click="doChangeType" val="right-top"></span>
40
+ <span z-on:click="doChangeType" val="left-middle"></span>
41
+ <span z-on:click="doChangeType" val="center-middle"></span>
42
+ <span z-on:click="doChangeType" val="right-middle"></span>
43
+ <span z-on:click="doChangeType" val="left-bottom"></span>
44
+ <span z-on:click="doChangeType" val="center-bottom"></span>
45
+ <span z-on:click="doChangeType" val="right-bottom"></span>
46
+ </div>
47
+ </li>
48
+ </ul>
49
+ </fieldset>
50
+ </div>
51
+ <div>
52
+ <button z-on:click="doSubmit">确定</button>
53
+ <button z-on:click="doClose">取消</button>
54
+ </div>
55
55
  </div>
@@ -1,53 +1,53 @@
1
- import { defineElement, ref } from "zipaper"
2
- import template from "./index.html"
3
- import style from "./index.scss";
4
-
5
- export default defineElement({
6
- template,
7
- data() {
8
- return {
9
- title: this._props.title,
10
- width: this._props.width,
11
- height: this._props.height,
12
-
13
- newWidth: ref(this._props.width),
14
- newHeight: ref(this._props.height),
15
-
16
- changeType: ref('center-middle')
17
- }
18
- },
19
- methods: {
20
- calcHeight() {
21
- if (this.title == '图像大小') {
22
- this.newHeight = +(this.newWidth * this.height / this.width).toFixed(0);
23
- }
24
- },
25
-
26
- calcWidth() {
27
- if (this.title == '图像大小') {
28
- this.newWidth = +(this.newHeight * this.width / this.height).toFixed(0);
29
- }
30
- },
31
-
32
- doChangeType: function (event, target) {
33
- this.changeType = target.getAttribute('val');
34
- },
35
-
36
- // 确定
37
- doSubmit: function () {
38
- this.$closeDialog({
39
- width: +this.newWidth,
40
- height: +this.newHeight,
41
- changeType: this.changeType
42
- });
43
- },
44
-
45
- // 取消
46
- doClose: function () {
47
- this.$closeDialog();
48
- }
49
- },
50
- style: {
51
- content: style
52
- }
53
- })
1
+ import { defineElement, ref } from "zipaper"
2
+ import template from "./index.html"
3
+ import style from "./index.scss";
4
+
5
+ export default defineElement({
6
+ template,
7
+ data() {
8
+ return {
9
+ title: this._props.title,
10
+ width: this._props.width,
11
+ height: this._props.height,
12
+
13
+ newWidth: ref(this._props.width),
14
+ newHeight: ref(this._props.height),
15
+
16
+ changeType: ref('center-middle')
17
+ }
18
+ },
19
+ methods: {
20
+ calcHeight() {
21
+ if (this.title == '图像大小') {
22
+ this.newHeight = +(this.newWidth * this.height / this.width).toFixed(0);
23
+ }
24
+ },
25
+
26
+ calcWidth() {
27
+ if (this.title == '图像大小') {
28
+ this.newWidth = +(this.newHeight * this.width / this.height).toFixed(0);
29
+ }
30
+ },
31
+
32
+ doChangeType: function (event, target) {
33
+ this.changeType = target.getAttribute('val');
34
+ },
35
+
36
+ // 确定
37
+ doSubmit: function () {
38
+ this.$closeDialog({
39
+ width: +this.newWidth,
40
+ height: +this.newHeight,
41
+ changeType: this.changeType
42
+ });
43
+ },
44
+
45
+ // 取消
46
+ doClose: function () {
47
+ this.$closeDialog();
48
+ }
49
+ },
50
+ style: {
51
+ content: style
52
+ }
53
+ })