@oipage/cli 0.3.0 → 1.0.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 (92) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +76 -47
  4. package/LICENSE +20 -20
  5. package/README.md +204 -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 → mimeTypes.json} +108 -104
  11. package/bin/disk.js +42 -42
  12. package/bin/help.js +63 -55
  13. package/bin/intercept.js +15 -15
  14. package/bin/network.js +21 -21
  15. package/bin/notebook/data.js +185 -0
  16. package/bin/notebook/index.js +168 -9
  17. package/bin/proxy.js +82 -82
  18. package/bin/run +146 -146
  19. package/bin/serve.js +455 -318
  20. package/bin/template/404.html +184 -184
  21. package/bin/tools/deleteEmptyFolder.js +33 -33
  22. package/bin/tools/format.js +75 -75
  23. package/bin/tools/isBinary.js +83 -83
  24. package/bin/tools/moduleForm.js +548 -0
  25. package/bin/tools/network.js +42 -42
  26. package/bin/tools/openBrowser.js +34 -34
  27. package/bin/tools/resolve404.js +98 -98
  28. package/bin/tools/resolveImport.js +278 -97
  29. package/bin/tools/resolvePackage.js +412 -0
  30. package/bin/website-htmls/components/ui-select-file/index.html +8 -8
  31. package/bin/website-htmls/components/ui-select-file/index.js +42 -42
  32. package/bin/website-htmls/components/ui-select-file/index.scss +44 -44
  33. package/bin/website-htmls/dialogs/imageSize/index.html +54 -54
  34. package/bin/website-htmls/dialogs/imageSize/index.js +53 -53
  35. package/bin/website-htmls/dialogs/imageSize/index.scss +140 -140
  36. package/bin/website-htmls/dialogs/index.js +52 -52
  37. package/bin/website-htmls/images/addFile.svg +1 -1
  38. package/bin/website-htmls/images/img-to-pdf.svg +1 -1
  39. package/bin/website-htmls/index.html +17 -17
  40. package/bin/website-htmls/main.js +13 -13
  41. package/bin/website-htmls/pages/App/index.html +6 -6
  42. package/bin/website-htmls/pages/App/index.js +22 -22
  43. package/bin/website-htmls/pages/App/index.scss +43 -43
  44. package/bin/website-htmls/pages/appStore/index.html +7 -7
  45. package/bin/website-htmls/pages/appStore/index.js +19 -19
  46. package/bin/website-htmls/pages/appStore/index.scss +54 -54
  47. package/bin/website-htmls/pages/chart/index.html +8 -8
  48. package/bin/website-htmls/pages/chart/index.js +72 -72
  49. package/bin/website-htmls/pages/chart/index.scss +71 -71
  50. package/bin/website-htmls/pages/home/index.html +19 -19
  51. package/bin/website-htmls/pages/home/index.js +19 -19
  52. package/bin/website-htmls/pages/home/index.scss +87 -87
  53. package/bin/website-htmls/pages/image-editor/index.html +27 -27
  54. package/bin/website-htmls/pages/image-editor/index.js +106 -106
  55. package/bin/website-htmls/pages/image-editor/index.scss +69 -69
  56. package/bin/website-htmls/pages/img-to-pdf/index.html +3 -3
  57. package/bin/website-htmls/pages/img-to-pdf/index.js +44 -44
  58. package/bin/website-htmls/pages/img-to-pdf/index.scss +9 -9
  59. package/bin/website-htmls/pages/recorder-screen/index.html +15 -15
  60. package/bin/website-htmls/pages/recorder-screen/index.js +227 -227
  61. package/bin/website-htmls/pages/recorder-screen/index.scss +52 -52
  62. package/bin/website-htmls/router.config.js +29 -29
  63. package/bin/website-htmls/styles/common.css +44 -44
  64. package/bin/website-htmls/styles/normalize.css +94 -94
  65. package/bin/website-plugins/intercept/chart.js +33 -33
  66. package/bin/website-plugins/intercept/getPackage.js +17 -17
  67. package/bin/website-plugins/intercept/head.js +8 -8
  68. package/bin/website-plugins/intercept/index.js +4 -8
  69. package/bin/website-plugins/loader/index.js +11 -11
  70. package/bin/website-plugins/loader/oipage-html-loader.js +7 -7
  71. package/bin/website-plugins/loader/oipage-scss-loader.js +149 -149
  72. package/docs/css/base.css +122 -0
  73. package/docs/css/components.css +180 -0
  74. package/docs/css/layout.css +295 -0
  75. package/docs/css/responsive.css +49 -0
  76. package/docs/images/file-list.webp +0 -0
  77. package/docs/images/logo-topbar.svg +5 -0
  78. package/docs/images/logo.png +0 -0
  79. package/docs/images/logo.svg +6 -0
  80. package/docs/images/manual.webp +0 -0
  81. package/docs/images/terminal-serve.webp +0 -0
  82. package/docs/index.html +1392 -0
  83. package/docs/js/copy.js +37 -0
  84. package/docs/js/nav.js +111 -0
  85. package/docs/js/search.js +241 -0
  86. package/docs/js/theme.js +17 -0
  87. package/package.json +42 -42
  88. package/src/index.js +26 -29
  89. package/types/serve.d.ts +83 -83
  90. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +0 -56
  91. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +0 -37
  92. package/docs/config.md +0 -107
package/types/serve.d.ts CHANGED
@@ -1,84 +1,84 @@
1
-
2
- interface DevServerType {
3
-
4
- /**
5
- * 是否自动打开浏览器,默认false,true表示打开
6
- *
7
- * 也可以是一段地址,比如设置open=“docs/index.html”
8
- */
9
- open?: boolean | string
10
-
11
- /**
12
- * 服务器端口号
13
- */
14
- port: number
15
-
16
- /**
17
- * 服务器根路径
18
- */
19
- baseUrl: string
20
-
21
- /**
22
- * 是否开启304缓存,默认开启
23
- */
24
- cache: boolean
25
-
26
- /**
27
- * 是否开启 gzip 压缩,默认不开启
28
- *
29
- * 开启后,对支持 gzip 的客户端请求,自动压缩可压缩类型的文本资源(如 HTML、CSS、JS、JSON、SVG 等)
30
- */
31
- gzip?: boolean
32
-
33
- /**
34
- * 是否开启应用市场,默认true表示开启
35
- */
36
- website: boolean
37
-
38
- intercept?: Array<InterceptType>
39
-
40
- proxy?: {
41
- [key: string]: {
42
- target: string
43
- pathRewrite?: {
44
- [key: string]: string
45
- }
46
- }
47
- }
48
- }
49
-
50
- interface InterceptType {
51
- test: RegExp
52
- handler(request: any, response: any): void
53
- }
54
-
55
- interface LoaderType {
56
- (source: string): string
57
- }
58
-
59
- interface ConfigType {
60
-
61
- /**
62
- * 服务器名称
63
- */
64
- name?: string
65
-
66
- /**
67
- * 服务器版本
68
- */
69
- version?: string
70
-
71
- /**
72
- * 服务器运行配置
73
- */
74
- devServer: DevServerType
75
-
76
- module?: {
77
- rules: Array<{
78
- test: RegExp
79
- use: LoaderType
80
- }>
81
- }
82
- }
83
-
1
+
2
+ interface DevServerType {
3
+
4
+ /**
5
+ * 是否自动打开浏览器,默认false,true表示打开
6
+ *
7
+ * 也可以是一段地址,比如设置open=“docs/index.html”
8
+ */
9
+ open?: boolean | string
10
+
11
+ /**
12
+ * 服务器端口号
13
+ */
14
+ port: number
15
+
16
+ /**
17
+ * 服务器根路径
18
+ */
19
+ baseUrl: string
20
+
21
+ /**
22
+ * 是否开启304缓存,默认开启
23
+ */
24
+ cache: boolean
25
+
26
+ /**
27
+ * 是否开启 gzip 压缩,默认不开启
28
+ *
29
+ * 开启后,对支持 gzip 的客户端请求,自动压缩可压缩类型的文本资源(如 HTML、CSS、JS、JSON、SVG 等)
30
+ */
31
+ gzip?: boolean
32
+
33
+ /**
34
+ * 是否开启应用市场,默认true表示开启
35
+ */
36
+ website: boolean
37
+
38
+ intercept?: Array<InterceptType>
39
+
40
+ proxy?: {
41
+ [key: string]: {
42
+ target: string
43
+ pathRewrite?: {
44
+ [key: string]: string
45
+ }
46
+ }
47
+ }
48
+ }
49
+
50
+ interface InterceptType {
51
+ test: RegExp
52
+ handler(request: any, response: any): void
53
+ }
54
+
55
+ interface LoaderType {
56
+ (source: string): string
57
+ }
58
+
59
+ interface ConfigType {
60
+
61
+ /**
62
+ * 服务器名称
63
+ */
64
+ name?: string
65
+
66
+ /**
67
+ * 服务器版本
68
+ */
69
+ version?: string
70
+
71
+ /**
72
+ * 服务器运行配置
73
+ */
74
+ devServer: DevServerType
75
+
76
+ module?: {
77
+ rules: Array<{
78
+ test: RegExp
79
+ use: LoaderType
80
+ }>
81
+ }
82
+ }
83
+
84
84
  export default function (config?: ConfigType): void
@@ -1,56 +0,0 @@
1
- const headFactory = require("./head.js");
2
- const getPackage = require("./getPackage.js");
3
-
4
- const head = headFactory();
5
-
6
- // VISLite库
7
- module.exports = {
8
- test: /^vislite$/,
9
- handler(request, response) {
10
- head["Content-Type"] = "application/javascript;charset=utf-8";
11
- head["ETag"] = "VISLite@v" + require("vislite/package.json").version;
12
-
13
- if (request.headers["if-none-match"] === head["ETag"]) {
14
- response.writeHead('304', head);
15
- response.end();
16
- console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Cache File: VISLite\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
17
- return;
18
- }
19
-
20
- response.writeHead(200, head);
21
-
22
- let source =getPackage("vislite/lib/index.umd.min.js");
23
-
24
- response.write(`let module = { exports: {} };
25
- let exports = module.exports;
26
- ${source}
27
- export let Cardinal = module.exports.Cardinal;
28
- export let Hermite = module.exports.Hermite;
29
- export let Matrix4 = module.exports.Matrix4;
30
- export let rotate = module.exports.rotate;
31
- export let move = module.exports.move;
32
- export let scale = module.exports.scale;
33
- export let getLoopColors = module.exports.getLoopColors;
34
- export let animation = module.exports.animation;
35
- export let ruler = module.exports.ruler;
36
- export let SVG = module.exports.SVG;
37
- export let Canvas = module.exports.Canvas;
38
- export let RawCanvas = module.exports.RawCanvas;
39
- export let getWebGLContext = module.exports.getWebGLContext;
40
- export let Shader = module.exports.Shader;
41
- export let Texture = module.exports.Texture;
42
- export let Buffer = module.exports.Buffer;
43
- export let Eoap = module.exports.Eoap;
44
- export let Mercator = module.exports.Mercator;
45
- export let throttle = module.exports.throttle;
46
- export let assemble = module.exports.assemble;
47
- export let MapCoordinate = module.exports.MapCoordinate;
48
- export let TreeLayout = module.exports.TreeLayout;
49
- export let PieLayout = module.exports.PieLayout;
50
- export let BarLayout = module.exports.BarLayout;
51
- export let initOption = module.exports.initOption;
52
- export let mergeOption = module.exports.mergeOption;
53
- `);
54
- response.end();
55
- }
56
- };
@@ -1,37 +0,0 @@
1
- const headFactory = require("./head.js");
2
- const getPackage = require("./getPackage.js");
3
-
4
- const head = headFactory();
5
-
6
- // Zipaper框架
7
- module.exports = {
8
- test: /^zipaper$/,
9
- handler(request, response) {
10
- head["Content-Type"] = "application/javascript;charset=utf-8";
11
- head["ETag"] = "Zipaper@v" + require("zipaper/package.json").version;
12
-
13
- if (request.headers["if-none-match"] === head["ETag"]) {
14
- response.writeHead('304', head);
15
- response.end();
16
- console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Cache File: Zipaper\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
17
- return;
18
- }
19
-
20
- response.writeHead(200, head);
21
-
22
- let source = getPackage("zipaper/dist/Zipaper.min.js");
23
-
24
- response.write(`let module = { exports: {} };
25
- let exports = module.exports;
26
- ${source}
27
- export let createApp = exports.createApp;
28
- export let defineDirective = exports.defineDirective;
29
- export let defineElement = exports.defineElement;
30
- export let defineRouter = exports.defineRouter;
31
- export let ref = exports.ref;
32
- export let reactive = exports.reactive;
33
- export let watcher = exports.watcher;
34
- `);
35
- response.end();
36
- }
37
- };
package/docs/config.md DELETED
@@ -1,107 +0,0 @@
1
- # 可配置项
2
-
3
- ## name
4
-
5
- 服务器名称,默认OIPage。
6
-
7
- ## version
8
-
9
- 服务器版本,默认使用@oipage/cli版本。
10
-
11
- ## devServer
12
-
13
- ### open
14
-
15
- 是否自动打开浏览器,默认false,true表示打开;也可以是一段地址,比如设置open=“docs/index.html”。
16
-
17
- ### cache
18
-
19
- 是否开启304缓存,默认true,表示开启。
20
-
21
- ### gzip
22
-
23
- > 始于 v0.3.0
24
-
25
- 是否开启 gzip 压缩,默认true,表示开启。
26
-
27
- 开启后,服务器会对支持 gzip 的客户端请求,自动压缩可压缩类型的文本资源(如 HTML、CSS、JS、JSON、SVG 等),可以有效减少传输体积,加快页面加载速度。
28
-
29
- 使用 Node.js 内置 `zlib` 模块实现,无需安装额外依赖。可通过命令行参数控制:
30
-
31
- ```shell
32
- oipage-cli serve --gzip true
33
- ```
34
-
35
- 或在配置文件中开启:
36
-
37
- ```js
38
- devServer: {
39
- gzip: true
40
- }
41
- ```
42
-
43
- ### port
44
-
45
- 端口,默认8080。此外,可以在执行的时候,通过命令参数覆盖(下同):
46
-
47
- ```shell
48
- oipage-cli serve --config ./oipage.config.js -p 20000
49
- ```
50
-
51
- ### baseUrl
52
-
53
- 服务器根目录,默认当前命令行目录。可以是绝对路径,如果为相对路径,则是相对当前命令行目录。
54
-
55
- ### 404
56
-
57
- 自定义 404 页面,函数接收两个参数 filePath(文件磁盘路径) 和 url(请求地址)。
58
-
59
- ```js
60
- 404: function (filePath, url) {
61
- return "<h1>自定义的 404 页面</h1><p>你访问的页面不存在!</p>";
62
- }
63
- ```
64
-
65
- ### proxy
66
-
67
- 转发功能
68
-
69
- ```js
70
- proxy: {
71
- "/apidemo": {
72
- target: "https://oi-contrib.github.io/OIPage",
73
- pathRewrite: { '^/apidemo': '' }, // 地址重写,可选
74
- }
75
- }
76
- ```
77
-
78
- ### intercept
79
-
80
- 请求拦截,可以实现针对特殊请求的自定义处理。
81
-
82
- ```js
83
- intercept: Array<{
84
- test: /\.do$/,
85
- handler(request, response) {
86
- // todo
87
- }
88
- }>
89
- ```
90
-
91
- ## module
92
-
93
- ### rules
94
-
95
- 用于处理特殊文件,其中use的参数source为原始内容,此函数返回处理后的内容。此外,此函数的this包含若干有用属性或方法,具体如下:
96
-
97
- - root: 字符串,服务器根路径。
98
-
99
- - setFileType: 函数,用于设置文件类型。比如如果希望设置为js文件:
100
-
101
- ```js
102
- this.setFileType("application/javascript")
103
- ```
104
-
105
- - path: 字符串,文件相对路径。
106
-
107
- - entry: 布尔值,是否是浏览器地址栏直接访问。