@oipage/cli 0.1.0-alpha.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 (81) hide show
  1. package/.github/FUNDING.yml +12 -0
  2. package/.mailmap +1 -0
  3. package/AUTHORS.txt +6 -0
  4. package/CHANGELOG +5 -0
  5. package/LICENSE +21 -0
  6. package/README.md +184 -0
  7. package/bin/WebSocket/decodeWsFrame.js +43 -0
  8. package/bin/WebSocket/encodeWsFrame.js +28 -0
  9. package/bin/WebSocket/headersToJSON.js +26 -0
  10. package/bin/WebSocket/index.js +80 -0
  11. package/bin/data/mineTypes.json +105 -0
  12. package/bin/disk.js +43 -0
  13. package/bin/help.js +51 -0
  14. package/bin/images/file.png +0 -0
  15. package/bin/images/folder.png +0 -0
  16. package/bin/intercept.js +16 -0
  17. package/bin/network.js +22 -0
  18. package/bin/proxy.js +75 -0
  19. package/bin/run +134 -0
  20. package/bin/serve.js +189 -0
  21. package/bin/template/404.html +185 -0
  22. package/bin/tools/deleteEmptyFolder.js +34 -0
  23. package/bin/tools/format.js +76 -0
  24. package/bin/tools/network.js +43 -0
  25. package/bin/tools/openBrowser.js +26 -0
  26. package/bin/tools/resolve404.js +84 -0
  27. package/bin/tools/resolveImport.js +89 -0
  28. package/bin/website-htmls/components/ui-select-file/index.html +9 -0
  29. package/bin/website-htmls/components/ui-select-file/index.js +43 -0
  30. package/bin/website-htmls/components/ui-select-file/index.scss +45 -0
  31. package/bin/website-htmls/dialogs/imageSize/index.html +55 -0
  32. package/bin/website-htmls/dialogs/imageSize/index.js +53 -0
  33. package/bin/website-htmls/dialogs/imageSize/index.scss +141 -0
  34. package/bin/website-htmls/dialogs/index.js +53 -0
  35. package/bin/website-htmls/images/addFile.svg +1 -0
  36. package/bin/website-htmls/images/chart.png +0 -0
  37. package/bin/website-htmls/images/image-editor.png +0 -0
  38. package/bin/website-htmls/images/img-to-pdf.svg +1 -0
  39. package/bin/website-htmls/images/lock.png +0 -0
  40. package/bin/website-htmls/images/logo.png +0 -0
  41. package/bin/website-htmls/images/mosaic.png +0 -0
  42. package/bin/website-htmls/images/recorder-screen.png +0 -0
  43. package/bin/website-htmls/images/size.png +0 -0
  44. package/bin/website-htmls/images/video-player.jpeg +0 -0
  45. package/bin/website-htmls/index.html +18 -0
  46. package/bin/website-htmls/main.js +14 -0
  47. package/bin/website-htmls/pages/App/index.html +7 -0
  48. package/bin/website-htmls/pages/App/index.js +23 -0
  49. package/bin/website-htmls/pages/App/index.scss +44 -0
  50. package/bin/website-htmls/pages/appStore/index.html +6 -0
  51. package/bin/website-htmls/pages/appStore/index.js +20 -0
  52. package/bin/website-htmls/pages/appStore/index.scss +44 -0
  53. package/bin/website-htmls/pages/chart/index.html +9 -0
  54. package/bin/website-htmls/pages/chart/index.js +73 -0
  55. package/bin/website-htmls/pages/chart/index.scss +72 -0
  56. package/bin/website-htmls/pages/home/index.html +20 -0
  57. package/bin/website-htmls/pages/home/index.js +20 -0
  58. package/bin/website-htmls/pages/home/index.scss +88 -0
  59. package/bin/website-htmls/pages/image-editor/index.html +28 -0
  60. package/bin/website-htmls/pages/image-editor/index.js +107 -0
  61. package/bin/website-htmls/pages/image-editor/index.scss +70 -0
  62. package/bin/website-htmls/pages/img-to-pdf/index.html +4 -0
  63. package/bin/website-htmls/pages/img-to-pdf/index.js +45 -0
  64. package/bin/website-htmls/pages/img-to-pdf/index.scss +10 -0
  65. package/bin/website-htmls/pages/recorder-screen/index.html +16 -0
  66. package/bin/website-htmls/pages/recorder-screen/index.js +228 -0
  67. package/bin/website-htmls/pages/recorder-screen/index.scss +53 -0
  68. package/bin/website-htmls/router.config.js +30 -0
  69. package/bin/website-htmls/styles/common.css +44 -0
  70. package/bin/website-htmls/styles/normalize.css +95 -0
  71. package/bin/website-plugins/intercept/chart.js +34 -0
  72. package/bin/website-plugins/intercept/getPackage.js +18 -0
  73. package/bin/website-plugins/intercept/head.js +9 -0
  74. package/bin/website-plugins/intercept/index.js +9 -0
  75. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +31 -0
  76. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +37 -0
  77. package/bin/website-plugins/loader/index.js +12 -0
  78. package/bin/website-plugins/loader/oipage-html-loader.js +8 -0
  79. package/bin/website-plugins/loader/oipage-scss-loader.js +150 -0
  80. package/package.json +43 -0
  81. package/types/index.d.ts +77 -0
@@ -0,0 +1,45 @@
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
+ methods: {
8
+ doChange(event) {
9
+ let files = event.data, promises = [], iframeEl = document.getElementById("iframe");
10
+
11
+ let template = "";
12
+ for (let index = 0; index < files.length; index++) {
13
+ let file = files[index];
14
+
15
+ promises.push(new Promise(function (resolve) {
16
+
17
+ let reader = new FileReader();
18
+
19
+ reader.onload = function () {
20
+
21
+ template += '<div style="display: flex;justify-content: center;align-items: center;height: 100vh;width: 100vw;"><img src="' + reader.result + '" style="max-width: 100vw;max-height: 100vh;"></img></div>';
22
+ resolve("");
23
+ }
24
+ reader.readAsDataURL(file);
25
+ }));
26
+ }
27
+
28
+ Promise.all(promises).then(function () {
29
+ let iframeWindow = iframeEl.contentWindow;
30
+ let iframeDocument = iframeEl.contentWindow?.document;
31
+
32
+ iframeDocument.open();
33
+ iframeDocument.write(`<style>body{margin:0px;}</style>` + template);
34
+ iframeDocument.close();
35
+
36
+ setTimeout(function () {
37
+ iframeWindow.print();
38
+ }, 500);
39
+ });
40
+ }
41
+ },
42
+ style: {
43
+ content: style
44
+ }
45
+ })
@@ -0,0 +1,10 @@
1
+ .img-to-pdf-view {
2
+ padding: 20px 12px;
3
+ box-sizing: border-box;
4
+
5
+ ui-select-file { display: block; max-width: 720px; margin: 0 auto 12px; }
6
+
7
+ iframe { display: none; width: 100%; height: 600px; border: none; }
8
+
9
+ @media (max-width: 600px) { iframe { height: 320px; } }
10
+ }
@@ -0,0 +1,16 @@
1
+ <div class="recorder-screen-view">
2
+ <div class="controls">
3
+ <button z-on:click="startRecorder" z-bind:active="isRun?'no':'yes'">
4
+ 开始录制
5
+ </button>
6
+ <div class="audio-options">
7
+ <label>
8
+ <input type="checkbox" z-model="includeSystemAudio"> 包含系统音频
9
+ </label>
10
+ <label>
11
+ <input type="checkbox" z-model="includeMicrophoneAudio"> 包含麦克风音频
12
+ </label>
13
+ </div>
14
+ </div>
15
+ <video id="video-el"></video>
16
+ </div>
@@ -0,0 +1,228 @@
1
+ import { defineElement, ref } from "zipaper"
2
+ import template from "./index.html"
3
+ import style from "./index.scss"
4
+
5
+ var mediaRecorder;
6
+ export default defineElement({
7
+ template,
8
+ data() {
9
+ return {
10
+ isRun: ref(false),
11
+ includeSystemAudio: ref(true),
12
+ includeMicrophoneAudio: ref(true)
13
+ }
14
+ },
15
+ methods: {
16
+
17
+ // 开始录制(根据用户选择包含音频)
18
+ startRecorder: function () {
19
+ var _this = this;
20
+
21
+ if (!this.isRun) {
22
+ var videoEl = document.getElementById("video-el");
23
+
24
+ // 静音播放防止回音
25
+ videoEl.muted = true;
26
+
27
+ // 根据用户选择获取屏幕内容
28
+ navigator.mediaDevices.getDisplayMedia({
29
+ video: true,
30
+ audio: _this.includeSystemAudio || _this.includeMicrophoneAudio
31
+ }).then(function (displayStream) {
32
+
33
+ // 如果用户选择包含麦克风音频,尝试获取麦克风流
34
+ if (_this.includeMicrophoneAudio) {
35
+ navigator.mediaDevices.getUserMedia({ audio: true }).then(function (micStream) {
36
+
37
+ _this.isRun = true;
38
+
39
+ // 根据用户选择创建音频混合
40
+ var AudioCtx = window.AudioContext || window.webkitAudioContext;
41
+ var audioCtx = new AudioCtx();
42
+ var destination = audioCtx.createMediaStreamDestination();
43
+
44
+ // 如果用户选择包含系统音频且屏幕流包含音频,则将其接入混音
45
+ if (_this.includeSystemAudio && displayStream.getAudioTracks().length) {
46
+ try {
47
+ var displaySource = audioCtx.createMediaStreamSource(displayStream);
48
+ displaySource.connect(destination);
49
+ } catch (e) {
50
+ console.warn('display audio connect failed', e);
51
+ }
52
+ }
53
+
54
+ // 如果用户选择包含麦克风音频,将麦克风接入混音
55
+ if (_this.includeMicrophoneAudio) {
56
+ try {
57
+ var micSource = audioCtx.createMediaStreamSource(micStream);
58
+ micSource.connect(destination);
59
+ } catch (e) {
60
+ console.warn('mic audio connect failed', e);
61
+ }
62
+ }
63
+
64
+ // 构造最终用于录制的流:视频来自屏幕,音频根据用户选择
65
+ var combinedStream = new MediaStream();
66
+ var vTrack = displayStream.getVideoTracks()[0];
67
+ if (vTrack) combinedStream.addTrack(vTrack);
68
+
69
+ // 无论用户选择了哪种音频,都尝试添加音频轨道
70
+ // 这样可以确保当用户选择包含音频时,音频轨道总是被添加到录制流中
71
+ destination.stream.getAudioTracks().forEach(function (t) {
72
+ combinedStream.addTrack(t);
73
+ });
74
+
75
+ // 视频预览使用合并流(已静音)
76
+ videoEl.srcObject = combinedStream;
77
+ videoEl.onloadedmetadata = function () {
78
+ videoEl.play();
79
+ };
80
+
81
+ // 创建 MediaRecorder 并录制
82
+ mediaRecorder = new MediaRecorder(combinedStream, {
83
+ mimeType: MediaRecorder.isTypeSupported("video/webm; codecs=vp9") ? "video/webm; codecs=vp9" : "video/webm"
84
+ });
85
+
86
+ var chunks = [];
87
+ mediaRecorder.addEventListener("dataavailable", function (event) {
88
+ if (event.data && event.data.size) chunks.push(event.data);
89
+ });
90
+
91
+ // 当屏幕停止共享时结束录制
92
+ if (displayStream.getVideoTracks()[0]) {
93
+ displayStream.getVideoTracks()[0].onended = function () {
94
+ if (mediaRecorder && mediaRecorder.state !== 'inactive') mediaRecorder.stop();
95
+ };
96
+ }
97
+
98
+ mediaRecorder.addEventListener("stop", function () {
99
+ // 停止流与释放资源
100
+ try { displayStream.getTracks().forEach(function (t) { t.stop(); }); } catch (e) { }
101
+ try { micStream.getTracks().forEach(function (t) { t.stop(); }); } catch (e) { }
102
+ try { audioCtx.close(); } catch (e) { }
103
+
104
+ if (!chunks.length) {
105
+ _this.isRun = false;
106
+ mediaRecorder = null;
107
+ return;
108
+ }
109
+
110
+ var blob = new Blob(chunks, { type: chunks[0].type });
111
+ var url = URL.createObjectURL(blob);
112
+ var downEl = document.createElement("a");
113
+ downEl.href = url;
114
+ downEl.download = "屏幕录制.webm";
115
+ downEl.click();
116
+ _this.isRun = false;
117
+ mediaRecorder = null;
118
+ });
119
+
120
+ mediaRecorder.start();
121
+
122
+ }).catch(function (micErr) {
123
+ // 获取麦克风失败,根据用户选择降级处理
124
+ console.warn('getUserMedia(mic) failed, fallback based on user selection', micErr);
125
+ _this.isRun = true;
126
+
127
+ // 如果用户没有要求麦克风音频,或者屏幕流没有音频,直接使用屏幕流
128
+ if (!_this.includeMicrophoneAudio || !displayStream.getAudioTracks().length) {
129
+ videoEl.srcObject = displayStream;
130
+ videoEl.onloadedmetadata = function () { videoEl.play(); };
131
+
132
+ mediaRecorder = new MediaRecorder(displayStream, {
133
+ mimeType: MediaRecorder.isTypeSupported("video/webm; codecs=vp9") ? "video/webm; codecs=vp9" : "video/webm"
134
+ });
135
+ } else {
136
+ // 用户要求麦克风音频但获取失败,尝试使用屏幕流中的音频(如果存在)
137
+ if (displayStream.getAudioTracks().length > 0) {
138
+ alert("无法获取麦克风权限,将使用系统音频进行录制");
139
+ } else {
140
+ alert("无法获取麦克风权限,且屏幕流无音频,将录制无声视频");
141
+ }
142
+ videoEl.srcObject = displayStream;
143
+ videoEl.onloadedmetadata = function () { videoEl.play(); };
144
+
145
+ mediaRecorder = new MediaRecorder(displayStream, {
146
+ mimeType: MediaRecorder.isTypeSupported("video/webm; codecs=vp9") ? "video/webm; codecs=vp9" : "video/webm"
147
+ });
148
+ }
149
+
150
+ var chunks2 = [];
151
+ mediaRecorder.addEventListener("dataavailable", function (event) {
152
+ if (event.data && event.data.size) chunks2.push(event.data);
153
+ });
154
+
155
+ if (displayStream.getVideoTracks()[0]) {
156
+ displayStream.getVideoTracks()[0].onended = function () {
157
+ if (mediaRecorder && mediaRecorder.state !== 'inactive') mediaRecorder.stop();
158
+ };
159
+ }
160
+
161
+ mediaRecorder.addEventListener("stop", function () {
162
+ try { displayStream.getTracks().forEach(function (t) { t.stop(); }); } catch (e) { }
163
+ if (!chunks2.length) { _this.isRun = false; mediaRecorder = null; return; }
164
+ var blob = new Blob(chunks2, { type: chunks2[0].type });
165
+ var url = URL.createObjectURL(blob);
166
+ var downEl = document.createElement("a");
167
+ downEl.href = url;
168
+ downEl.download = "屏幕录制.webm";
169
+ downEl.click();
170
+ _this.isRun = false;
171
+ mediaRecorder = null;
172
+ });
173
+
174
+ mediaRecorder.start();
175
+ });
176
+ } else {
177
+ // 用户没有选择包含麦克风音频,直接使用屏幕流
178
+ _this.isRun = true;
179
+
180
+ videoEl.srcObject = displayStream;
181
+ videoEl.onloadedmetadata = function () { videoEl.play(); };
182
+
183
+ mediaRecorder = new MediaRecorder(displayStream, {
184
+ mimeType: MediaRecorder.isTypeSupported("video/webm; codecs=vp9") ? "video/webm; codecs=vp9" : "video/webm"
185
+ });
186
+
187
+ var chunks3 = [];
188
+ mediaRecorder.addEventListener("dataavailable", function (event) {
189
+ if (event.data && event.data.size) chunks3.push(event.data);
190
+ });
191
+
192
+ if (displayStream.getVideoTracks()[0]) {
193
+ displayStream.getVideoTracks()[0].onended = function () {
194
+ if (mediaRecorder && mediaRecorder.state !== 'inactive') mediaRecorder.stop();
195
+ };
196
+ }
197
+
198
+ mediaRecorder.addEventListener("stop", function () {
199
+ try { displayStream.getTracks().forEach(function (t) { t.stop(); }); } catch (e) { }
200
+ if (!chunks3.length) { _this.isRun = false; mediaRecorder = null; return; }
201
+ var blob = new Blob(chunks3, { type: chunks3[0].type });
202
+ var url = URL.createObjectURL(blob);
203
+ var downEl = document.createElement("a");
204
+ downEl.href = url;
205
+ downEl.download = "屏幕录制.webm";
206
+ downEl.click();
207
+ _this.isRun = false;
208
+ mediaRecorder = null;
209
+ });
210
+
211
+ mediaRecorder.start();
212
+ }
213
+
214
+ }).catch(function (event) {
215
+ alert("用户取消l了屏幕共享或发生错误,无法开始录制!");
216
+ console.error('getDisplayMedia error:', event);
217
+ });
218
+
219
+ } else {
220
+ alert("正在录制中,请点击‘完成’按钮结束后再启动新的录制程序!");
221
+ }
222
+
223
+ }
224
+ },
225
+ style: {
226
+ content: style
227
+ }
228
+ })
@@ -0,0 +1,53 @@
1
+ .recorder-screen-view {
2
+ .controls {
3
+ position: absolute;
4
+ top: 5px;
5
+ right: 200px;
6
+ display: flex;
7
+ align-items: center;
8
+ z-index: 10;
9
+
10
+ &>button {
11
+ height: 35px;
12
+ padding: 0 30px;
13
+ border: none;
14
+ cursor: pointer;
15
+ background-color: red;
16
+ color: white;
17
+ border-radius: 5px;
18
+ margin-right: 20px;
19
+
20
+ &[active='no'] {
21
+ background-color: rgb(239, 139, 139);
22
+ cursor: not-allowed;
23
+ }
24
+ }
25
+
26
+ .audio-options {
27
+ display: flex;
28
+ background-color: rgba(255, 255, 255, 0.9);
29
+ padding: 5px 10px;
30
+ border-radius: 5px;
31
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
32
+
33
+ label {
34
+ display: flex;
35
+ align-items: center;
36
+ margin: 5px 0;
37
+ font-size: 14px;
38
+ color: #333;
39
+ cursor: pointer;
40
+
41
+ input[type="checkbox"] {
42
+ margin-right: 8px;
43
+ }
44
+ }
45
+ }
46
+ }
47
+
48
+ &>video {
49
+ width: 100vw;
50
+ height: calc(100vh - 50px);
51
+ background-color: black;
52
+ }
53
+ }
@@ -0,0 +1,30 @@
1
+ import { defineRouter } from "zipaper"
2
+
3
+ export default defineRouter({
4
+ routers: [{
5
+ path: "/",
6
+ redirect: "/appStore"
7
+ }, {
8
+ path: "/appStore",
9
+ component: () => import("./pages/appStore/index.js"),
10
+ children: [{
11
+ path: "/",
12
+ redirect: "/home"
13
+ }, {
14
+ path: "/home",
15
+ component: () => import("./pages/home/index.js"),
16
+ }, {
17
+ path: "/chart",
18
+ component: () => import("./pages/chart/index.js"),
19
+ }, {
20
+ path: "/image-editor",
21
+ component: () => import("./pages/image-editor/index.js"),
22
+ }, {
23
+ path: "/img-to-pdf",
24
+ component: () => import("./pages/img-to-pdf/index.js"),
25
+ }, {
26
+ path: "/recorder-screen",
27
+ component: () => import("./pages/recorder-screen/index.js"),
28
+ }]
29
+ }]
30
+ })
@@ -0,0 +1,44 @@
1
+ /* Global base styles for improved look and responsiveness */
2
+ html, body {
3
+ height: 100%;
4
+ margin: 0;
5
+ padding: 0;
6
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
7
+ background: #f7f9fc;
8
+ color: #0f1723;
9
+ -webkit-font-smoothing: antialiased;
10
+ }
11
+
12
+ .container {
13
+ max-width: 1100px;
14
+ margin: 0 auto;
15
+ padding: 16px;
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ /* Buttons and inputs */
20
+ button {
21
+ font-family: inherit;
22
+ border-radius: 8px;
23
+ padding: 8px 12px;
24
+ background: #111827;
25
+ color: #fff;
26
+ border: none;
27
+ cursor: pointer;
28
+ }
29
+
30
+ input[type="text"], input[type="search"], input, textarea {
31
+ font-family: inherit;
32
+ padding: 8px 10px;
33
+ border-radius: 8px;
34
+ border: 1px solid #e6e9ee;
35
+ outline: none;
36
+ }
37
+
38
+ /* Utility helpers */
39
+ .hidden { display: none !important; }
40
+
41
+ @media (prefers-color-scheme: dark) {
42
+ html, body { background: #0b1220; color: #e6eef8; }
43
+ button { background: #e6eef8; color: #0b1220; }
44
+ }
@@ -0,0 +1,95 @@
1
+ /* 统一不同浏览器的基础样式 */
2
+
3
+ html {
4
+ /* 防止iPhone在坚屏转向横屏时放大文字 */
5
+ -ms-text-size-adjust: 100%;
6
+ -webkit-text-size-adjust: 100%;
7
+ /* 统一行高 */
8
+ line-height: 1.15;
9
+ }
10
+
11
+ button,
12
+ input,
13
+ select {
14
+ /* 兼容部分手机下border不显示问题 */
15
+ border: 1px solid #b2b2bd;
16
+ }
17
+
18
+ article,
19
+ footer,
20
+ header,
21
+ nav,
22
+ section {
23
+ /* 修正旧浏览器未定义的块级元素 */
24
+ display: block;
25
+ }
26
+
27
+ canvas,
28
+ svg {
29
+ /* 修正旧浏览器未定义的行内块元素 */
30
+ display: inline-block;
31
+ }
32
+
33
+ * {
34
+ /* 统一不同浏览器盒子尺寸计算方法 */
35
+ box-sizing: border-box;
36
+ }
37
+
38
+ ::-ms-clear,
39
+ ::-ms-reveal {
40
+ /* 去掉IE浏览器输入框叉叉和眼睛 */
41
+ display: none;
42
+ }
43
+
44
+ img {
45
+ /* 针对火狐浏览器在img标签没有src时候的差异修复 */
46
+ display: inline-block;
47
+ }
48
+
49
+ html {
50
+ /* 设置默认字体为统一的安全字体 */
51
+ font-family: sans-serif;
52
+ }
53
+
54
+ a {
55
+ /* 默认去掉下划线 */
56
+ text-decoration: none;
57
+ }
58
+
59
+ li {
60
+ /* 去掉前置索引 */
61
+ list-style-type: none;
62
+ }
63
+
64
+ ul,
65
+ ol,
66
+ li,
67
+ p,
68
+ h1,
69
+ h2,
70
+ h3,
71
+ h4,
72
+ h5,
73
+ h6 {
74
+ /* 去掉不喜欢的间距 */
75
+ -webkit-margin-before: 0;
76
+ -webkit-margin-after: 0;
77
+ -webkit-padding-start: 0;
78
+ /* 去掉不喜欢的间距,针对火狐浏览器等 */
79
+ margin-block-end: 0;
80
+ margin-block-start: 0;
81
+ padding-inline-start: 0;
82
+ /* 修改IE和其它浏览器不一致问题 */
83
+ padding: 0;
84
+ margin: 0;
85
+ }
86
+
87
+ body {
88
+ /* 去掉默认的8px */
89
+ margin: 0;
90
+ }
91
+
92
+ table {
93
+ /* 设置默认表格边框合并为一个单一的边框 */
94
+ border-collapse: collapse;
95
+ }
@@ -0,0 +1,34 @@
1
+ const headFactory = require("./head.js");
2
+
3
+ const head = headFactory();
4
+
5
+ // 聊天
6
+ module.exports = {
7
+ test: /^\/chart\//,
8
+ handler(request, response, wsHandler) {
9
+ let url = decodeURIComponent(request.url);
10
+
11
+ let requestData = "";
12
+
13
+ request.on('data', (chunk) => {
14
+ requestData += chunk;
15
+ });
16
+
17
+ request.on('end', () => {
18
+
19
+ if (/sendMsg$/.test(url)) {
20
+ wsHandler.notifyBrowser({
21
+ payloadData: requestData
22
+ });
23
+ }
24
+
25
+ head["Content-Type"] = "application/json;charset=utf-8";
26
+ response.writeHead(200, head);
27
+ response.write(JSON.stringify({
28
+ code: "000000"
29
+ }));
30
+ response.end();
31
+
32
+ });
33
+ }
34
+ };
@@ -0,0 +1,18 @@
1
+ const { readFileSync } = require("fs");
2
+ const { join } = require("path");
3
+ const { existsSync } = require("fs");
4
+
5
+ module.exports = function (filpath) {
6
+
7
+ let node_modulesPath = join(__dirname, "../../../node_modules");
8
+
9
+ while (!existsSync(join(node_modulesPath, filpath)) && node_modulesPath != join(node_modulesPath, "../")) {
10
+ node_modulesPath = join(node_modulesPath, "../");
11
+ }
12
+
13
+ let source = readFileSync(join(node_modulesPath, filpath), {
14
+ encoding: "utf8"
15
+ });
16
+
17
+ return source;
18
+ };
@@ -0,0 +1,9 @@
1
+ const pkg = require("../../../package.json");
2
+
3
+ module.exports = function () {
4
+ return {
5
+ 'Access-Control-Allow-Origin': '*',
6
+ 'Server': 'Powered by @oipage/cli:website@' + pkg.version,
7
+ 'Content-Type': 'text/plain;charset=utf-8'
8
+ };
9
+ };
@@ -0,0 +1,9 @@
1
+ const OIPageZipaperIntercept = require("./oipage-zipaper-intercept.js");
2
+ const OIPageVISLiteIntercept = require("./oipage-vislite-intercept.js");
3
+ const ChartIntercept = require("./chart.js");
4
+
5
+ module.exports = [
6
+ OIPageZipaperIntercept,
7
+ OIPageVISLiteIntercept,
8
+ ChartIntercept
9
+ ];
@@ -0,0 +1,31 @@
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 Canvas = module.exports.Canvas;
28
+ `);
29
+ response.end();
30
+ }
31
+ };
@@ -0,0 +1,37 @@
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
+ };