oipage 0.1.0-alpha.1 → 0.1.0-alpha.2

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 (45) hide show
  1. package/CHANGELOG +38 -0
  2. package/README.md +103 -4
  3. package/bin/options.js +45 -11
  4. package/bin/run +165 -20
  5. package/browserjs/getStyle/index.d.ts +11 -0
  6. package/browserjs/getStyle/index.js +13 -0
  7. package/browserjs/index.d.ts +10 -0
  8. package/browserjs/index.js +7 -0
  9. package/browserjs/onReady/index.d.ts +8 -0
  10. package/browserjs/onReady/index.js +8 -0
  11. package/corejs/animation/index.d.ts +12 -0
  12. package/corejs/animation/index.js +102 -0
  13. package/corejs/index.d.ts +10 -0
  14. package/corejs/index.js +7 -0
  15. package/corejs/throttle/index.d.ts +31 -0
  16. package/corejs/throttle/index.js +50 -0
  17. package/nodejs/core/file.js +128 -0
  18. package/nodejs/core/image.js +5 -0
  19. package/nodejs/core/log.js +82 -0
  20. package/nodejs/core/network.js +40 -0
  21. package/nodejs/core/options.js +49 -0
  22. package/nodejs/core/remote.js +60 -0
  23. package/nodejs/core/responseFileList.js +28 -0
  24. package/nodejs/core/server.js +163 -0
  25. package/nodejs/data/404.js +52 -0
  26. package/nodejs/data/images/file.js +1 -0
  27. package/nodejs/data/images/folder.js +1 -0
  28. package/nodejs/data/mime.types.js +112 -0
  29. package/nodejs/index.js +48 -0
  30. package/nodejs/loader/simpleScss.js +248 -0
  31. package/nodejs/loader/xhtml.js +521 -0
  32. package/package.json +16 -20
  33. package/stylecss/index.css +3 -0
  34. package/stylecss/normalize.css +94 -0
  35. package/stylecss/rasterize.css +318 -0
  36. package/stylecss/skeleton.css +16 -0
  37. package/types/get-options.d.ts +6 -0
  38. package/types/index.d.ts +187 -0
  39. package/public/index.html +0 -14
  40. package/script/command/build.js +0 -22
  41. package/script/command/dev.js +0 -38
  42. package/script/config/alignment.js +0 -15
  43. package/script/config/webpack.js +0 -60
  44. package/src/platforms/h5/index.js +0 -0
  45. package/src/runtime/index.js +0 -0
@@ -0,0 +1,318 @@
1
+ .container .row {
2
+ font-size: 0;
3
+ }
4
+
5
+ .container .row>.col-size-1,
6
+ .container .row>.col-xs-1,
7
+ .container .row>.col-sm-1,
8
+ .container .row>.col-md-1,
9
+ .container .row>.col-lg-1,
10
+ .container .row>.col-size-2,
11
+ .container .row>.col-xs-2,
12
+ .container .row>.col-sm-2,
13
+ .container .row>.col-md-2,
14
+ .container .row>.col-lg-2,
15
+ .container .row>.col-size-3,
16
+ .container .row>.col-xs-3,
17
+ .container .row>.col-sm-3,
18
+ .container .row>.col-md-3,
19
+ .container .row>.col-lg-3,
20
+ .container .row>.col-size-4,
21
+ .container .row>.col-xs-4,
22
+ .container .row>.col-sm-4,
23
+ .container .row>.col-md-4,
24
+ .container .row>.col-lg-4,
25
+ .container .row>.col-size-5,
26
+ .container .row>.col-xs-5,
27
+ .container .row>.col-sm-5,
28
+ .container .row>.col-md-5,
29
+ .container .row>.col-lg-5,
30
+ .container .row>.col-size-6,
31
+ .container .row>.col-xs-6,
32
+ .container .row>.col-sm-6,
33
+ .container .row>.col-md-6,
34
+ .container .row>.col-lg-6,
35
+ .container .row>.col-size-7,
36
+ .container .row>.col-xs-7,
37
+ .container .row>.col-sm-7,
38
+ .container .row>.col-md-7,
39
+ .container .row>.col-lg-7,
40
+ .container .row>.col-size-8,
41
+ .container .row>.col-xs-8,
42
+ .container .row>.col-sm-8,
43
+ .container .row>.col-md-8,
44
+ .container .row>.col-lg-8,
45
+ .container .row>.col-size-9,
46
+ .container .row>.col-xs-9,
47
+ .container .row>.col-sm-9,
48
+ .container .row>.col-md-9,
49
+ .container .row>.col-lg-9,
50
+ .container .row>.col-size-10,
51
+ .container .row>.col-xs-10,
52
+ .container .row>.col-sm-10,
53
+ .container .row>.col-md-10,
54
+ .container .row>.col-lg-10,
55
+ .container .row>.col-size-11,
56
+ .container .row>.col-xs-11,
57
+ .container .row>.col-sm-11,
58
+ .container .row>.col-md-11,
59
+ .container .row>.col-lg-11,
60
+ .container .row>.col-size-12,
61
+ .container .row>.col-xs-12,
62
+ .container .row>.col-sm-12,
63
+ .container .row>.col-md-12,
64
+ .container .row>.col-lg-12 {
65
+ vertical-align: top;
66
+ display: inline-block;
67
+ width: 100%;
68
+ font-size: 16px;
69
+ position: relative;
70
+ }
71
+
72
+ .container .row>.col-size-12 {
73
+ width: 100%;
74
+ }
75
+
76
+ .container .row>.col-size-11 {
77
+ width: 91.66666667%;
78
+ }
79
+
80
+ .container .row>.col-size-10 {
81
+ width: 83.33333333%;
82
+ }
83
+
84
+ .container .row>.col-size-9 {
85
+ width: 75%;
86
+ }
87
+
88
+ .container .row>.col-size-8 {
89
+ width: 66.66666667%;
90
+ }
91
+
92
+ .container .row>.col-size-7 {
93
+ width: 58.33333333%;
94
+ }
95
+
96
+ .container .row>.col-size-6 {
97
+ width: 50%;
98
+ }
99
+
100
+ .container .row>.col-size-5 {
101
+ width: 41.66666667%;
102
+ }
103
+
104
+ .container .row>.col-size-4 {
105
+ width: 33.33333333%;
106
+ }
107
+
108
+ .container .row>.col-size-3 {
109
+ width: 25%;
110
+ }
111
+
112
+ .container .row>.col-size-2 {
113
+ width: 16.66666667%;
114
+ }
115
+
116
+ .container .row>.col-size-1 {
117
+ width: 8.33333333%;
118
+ }
119
+
120
+ @media (max-width: 768px) {
121
+ .container .row>.col-xs-12 {
122
+ width: 100%;
123
+ }
124
+
125
+ .container .row>.col-xs-11 {
126
+ width: 91.66666667%;
127
+ }
128
+
129
+ .container .row>.col-xs-10 {
130
+ width: 83.33333333%;
131
+ }
132
+
133
+ .container .row>.col-xs-9 {
134
+ width: 75%;
135
+ }
136
+
137
+ .container .row>.col-xs-8 {
138
+ width: 66.66666667%;
139
+ }
140
+
141
+ .container .row>.col-xs-7 {
142
+ width: 58.33333333%;
143
+ }
144
+
145
+ .container .row>.col-xs-6 {
146
+ width: 50%;
147
+ }
148
+
149
+ .container .row>.col-xs-5 {
150
+ width: 41.66666667%;
151
+ }
152
+
153
+ .container .row>.col-xs-4 {
154
+ width: 33.33333333%;
155
+ }
156
+
157
+ .container .row>.col-xs-3 {
158
+ width: 25%;
159
+ }
160
+
161
+ .container .row>.col-xs-2 {
162
+ width: 16.66666667%;
163
+ }
164
+
165
+ .container .row>.col-xs-1 {
166
+ width: 8.33333333%;
167
+ }
168
+ }
169
+
170
+ @media (min-width: 768px) {
171
+ .container .row>.col-sm-12 {
172
+ width: 100%;
173
+ }
174
+
175
+ .container .row>.col-sm-11 {
176
+ width: 91.66666667%;
177
+ }
178
+
179
+ .container .row>.col-sm-10 {
180
+ width: 83.33333333%;
181
+ }
182
+
183
+ .container .row>.col-sm-9 {
184
+ width: 75%;
185
+ }
186
+
187
+ .container .row>.col-sm-8 {
188
+ width: 66.66666667%;
189
+ }
190
+
191
+ .container .row>.col-sm-7 {
192
+ width: 58.33333333%;
193
+ }
194
+
195
+ .container .row>.col-sm-6 {
196
+ width: 50%;
197
+ }
198
+
199
+ .container .row>.col-sm-5 {
200
+ width: 41.66666667%;
201
+ }
202
+
203
+ .container .row>.col-sm-4 {
204
+ width: 33.33333333%;
205
+ }
206
+
207
+ .container .row>.col-sm-3 {
208
+ width: 25%;
209
+ }
210
+
211
+ .container .row>.col-sm-2 {
212
+ width: 16.66666667%;
213
+ }
214
+
215
+ .container .row>.col-sm-1 {
216
+ width: 8.33333333%;
217
+ }
218
+ }
219
+
220
+ @media (min-width: 992px) {
221
+ .container .row>.col-md-12 {
222
+ width: 100%;
223
+ }
224
+
225
+ .container .row>.col-md-11 {
226
+ width: 91.66666667%;
227
+ }
228
+
229
+ .container .row>.col-md-10 {
230
+ width: 83.33333333%;
231
+ }
232
+
233
+ .container .row>.col-md-9 {
234
+ width: 75%;
235
+ }
236
+
237
+ .container .row>.col-md-8 {
238
+ width: 66.66666667%;
239
+ }
240
+
241
+ .container .row>.col-md-7 {
242
+ width: 58.33333333%;
243
+ }
244
+
245
+ .container .row>.col-md-6 {
246
+ width: 50%;
247
+ }
248
+
249
+ .container .row>.col-md-5 {
250
+ width: 41.66666667%;
251
+ }
252
+
253
+ .container .row>.col-md-4 {
254
+ width: 33.33333333%;
255
+ }
256
+
257
+ .container .row>.col-md-3 {
258
+ width: 25%;
259
+ }
260
+
261
+ .container .row>.col-md-2 {
262
+ width: 16.66666667%;
263
+ }
264
+
265
+ .container .row>.col-md-1 {
266
+ width: 8.33333333%;
267
+ }
268
+ }
269
+
270
+ @media (min-width: 1200px) {
271
+ .container .row>.col-lg-12 {
272
+ width: 100%;
273
+ }
274
+
275
+ .container .row>.col-lg-11 {
276
+ width: 91.66666667%;
277
+ }
278
+
279
+ .container .row>.col-lg-10 {
280
+ width: 83.33333333%;
281
+ }
282
+
283
+ .container .row>.col-lg-9 {
284
+ width: 75%;
285
+ }
286
+
287
+ .container .row>.col-lg-8 {
288
+ width: 66.66666667%;
289
+ }
290
+
291
+ .container .row>.col-lg-7 {
292
+ width: 58.33333333%;
293
+ }
294
+
295
+ .container .row>.col-lg-6 {
296
+ width: 50%;
297
+ }
298
+
299
+ .container .row>.col-lg-5 {
300
+ width: 41.66666667%;
301
+ }
302
+
303
+ .container .row>.col-lg-4 {
304
+ width: 33.33333333%;
305
+ }
306
+
307
+ .container .row>.col-lg-3 {
308
+ width: 25%;
309
+ }
310
+
311
+ .container .row>.col-lg-2 {
312
+ width: 16.66666667%;
313
+ }
314
+
315
+ .container .row>.col-lg-1 {
316
+ width: 8.33333333%;
317
+ }
318
+ }
@@ -0,0 +1,16 @@
1
+ @keyframes stylecss-skeleton_animation {
2
+ 0% {
3
+ background-position: 100% 50%
4
+ }
5
+
6
+ to {
7
+ background-position: 0 50%
8
+ }
9
+ }
10
+
11
+ .stylecss-skeleton_item,
12
+ .stylecss-skeleton * {
13
+ background: linear-gradient(to right, #F3F3F6 8%, #cdcecf 18%, #F3F3F6 33%);
14
+ background-size: 400% 100%;
15
+ animation: stylecss-skeleton_animation 2s ease infinite;
16
+ }
@@ -0,0 +1,6 @@
1
+ export default interface getOptionsType {
2
+
3
+ // 返回数据是否是json
4
+ json?: boolean
5
+
6
+ }
package/types/index.d.ts CHANGED
@@ -0,0 +1,187 @@
1
+ import getOptionsType from './get-options'
2
+
3
+ export default class OIPage {
4
+
5
+ /**
6
+ * 命令行参数解析
7
+ * @param shortHands
8
+ * @param argv
9
+ */
10
+ static options(shortHands: any, argv: any): any
11
+
12
+ /**
13
+ * 删除文件或文件夹
14
+ * @param target
15
+ */
16
+ static deleteSync(target: string): void
17
+
18
+ /**
19
+ * 复制文件或文件夹
20
+ * @param source
21
+ * @param target
22
+ */
23
+ static copySync(source: string, target: string): void
24
+
25
+ /**
26
+ * 移动文件或文件夹
27
+ * @param source
28
+ * @param target
29
+ */
30
+ static moveSync(source: string, target: string): void
31
+
32
+ /**
33
+ * 遍历当前文件或文件夹中所有文件
34
+ * @param source
35
+ * @param callback
36
+ */
37
+ static listFileSync(source: string, callback: (fileInfo: {
38
+ name: string,
39
+ path: string,
40
+ folder: string
41
+ }) => void): void
42
+
43
+ /**
44
+ * 获取文件或文件夹的全路径
45
+ * @param pathString 需要变成全路径的路径
46
+ * @param contextPath 拼接上下文路径,可选,默认当前命令行路径
47
+ * @returns {path} 返回拼接的全路径
48
+ */
49
+ static fullPathSync(pathString: string, contextPath?: string): string
50
+
51
+ /**
52
+ * 图片变成base64字符串
53
+ * @param filepath 图片地址
54
+ */
55
+ static toBase64(filepath: string): string
56
+
57
+ /**
58
+ * 日志打印
59
+ * @param txt
60
+ */
61
+ static log(txt: string): void
62
+
63
+ /**
64
+ * 提醒打印
65
+ * @param txt
66
+ */
67
+ static warn(txt: string): void
68
+
69
+ /**
70
+ * 警告打印
71
+ * @param txt
72
+ */
73
+ static error(txt: string): void
74
+
75
+ /**
76
+ * 单行打印
77
+ * @param txt
78
+ */
79
+ static linelog(txt: string): void
80
+
81
+ /**
82
+ * 进度打印
83
+ * @param percentum
84
+ * @param txt
85
+ */
86
+ static deeplog(percentum: number, txt?: string): void
87
+
88
+ /**
89
+ * 进度打印(已废弃,请用deeplog代替)
90
+ * @param percentum
91
+ * @param txt
92
+ */
93
+ static process(percentum: number, txt?: string): void
94
+
95
+ /**
96
+ * Get 请求
97
+ * @param url
98
+ * @param options
99
+ */
100
+ static get(url: string, options?: getOptionsType): Promise<any>
101
+
102
+ /**
103
+ * Post 请求
104
+ * @param url
105
+ * @param options
106
+ */
107
+ static post(url: string, options?: getOptionsType): Promise<any>
108
+
109
+ /**
110
+ * 获取本机网络信息
111
+ */
112
+ static network(): any
113
+
114
+ /**
115
+ * 文件类型
116
+ */
117
+ static mimeTypes(): { [name: string]: string }
118
+
119
+ /**
120
+ * 服务器
121
+ */
122
+ static server(config: {
123
+
124
+ /**
125
+ * 端口号
126
+ *
127
+ * 默认值:20000
128
+ */
129
+ port?: number
130
+
131
+ /**
132
+ * 服务器根地址
133
+ *
134
+ * 默认值:./
135
+ */
136
+ basePath?:string
137
+
138
+ /**
139
+ * 配置转发,可以任意多个
140
+ */
141
+ proxy?: Array<any>
142
+
143
+ /**
144
+ * 自定义拦截,如果返回true表示此次请求自定义处理
145
+ */
146
+ handler?: (request, response) => boolean
147
+
148
+ /**
149
+ * 表示缺省后缀
150
+ *
151
+ * 默认值:[".html",".htm",".js",".json"]
152
+ */
153
+ suffixs?: Array<string>
154
+ }): void
155
+
156
+ /**
157
+ * scss文件转css(只支持部分scss语法)
158
+ * @param source
159
+ */
160
+ static simpleScss(source: string): string
161
+
162
+ /**
163
+ * xhtml文件解析成json对象
164
+ * @param source
165
+ */
166
+ static xhtml(source: string): Array<{
167
+ type: string,
168
+ name: string,
169
+ attrs: {
170
+ [key: string]: string
171
+ },
172
+ __deep__: number,
173
+ __tagType__: string,
174
+ childNodes: Array<number>,
175
+ preNode: null | number,
176
+ nextNode: null | number,
177
+ parentNode: null | number
178
+ } | {
179
+ type: string,
180
+ content: string,
181
+ __deep__: number,
182
+ childNodes: Array<number>,
183
+ preNode: null | number,
184
+ nextNode: null | number,
185
+ parentNode: null | number
186
+ }>
187
+ }
package/public/index.html DELETED
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-cn">
3
-
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title><%= htmlWebpackPlugin.options.title %></title>
8
- </head>
9
-
10
- <body>
11
-
12
- </body>
13
-
14
- </html>
@@ -1,22 +0,0 @@
1
- const Webpack = require("webpack");
2
- const { log } = require("devby");
3
-
4
- const getWebpackConfig = require("../config/webpack");
5
-
6
- module.exports = function (parsed) {
7
- const webpackConfig = getWebpackConfig(parsed);
8
-
9
- // https://webpack.docschina.org/api/node/#webpack
10
- const compiler = Webpack(webpackConfig);
11
-
12
- compiler.run((err, stats) => {
13
- if (err || stats.hasErrors()) {
14
- console.error(err || stats.toJson().errors);
15
- }
16
-
17
- log("<日志> [OIPage] 打包完成:" + webpackConfig.output.path.replace(process.cwd(), '.') + "\n")
18
- compiler.close((closeErr) => {
19
- if (closeErr) console.error(closeErr);
20
- });
21
- });
22
- };
@@ -1,38 +0,0 @@
1
- const Webpack = require("webpack");
2
- const WebpackDevServer = require("webpack-dev-server");
3
- const { log } = require("devby");
4
-
5
- const getWebpackConfig = require("../config/webpack");
6
-
7
- module.exports = function (parsed) {
8
- const webpackConfig = getWebpackConfig(parsed);
9
-
10
- if (parsed.platform == "h5") {
11
- const compiler = Webpack(webpackConfig);
12
-
13
- // https://webpack.docschina.org/api/webpack-dev-server
14
- const server = new WebpackDevServer(webpackConfig.devServer, compiler);
15
-
16
- server.start().then(function () {
17
- // todo
18
- });
19
- } else {
20
- const compiler = Webpack(webpackConfig);
21
-
22
- const watching = compiler.watch(webpackConfig.watchOptions, (err, stats) => {
23
- if (err || stats.hasErrors()) {
24
- console.error(err || stats.toJson().errors);
25
- }
26
-
27
- // 编译成功后的逻辑
28
- console.log(stats.toString({ colors: true }));
29
- });
30
-
31
- watching.close((closeErr) => {
32
- if (closeErr) console.error(closeErr);
33
- log("<日志> [OIPage] 退出监听:" + parsed.platform + "\n");
34
- });
35
-
36
- }
37
-
38
- };
@@ -1,15 +0,0 @@
1
-
2
- // 对齐命令行解析后的参数
3
- exports.command = function (parsed) {
4
- return {
5
-
6
- // 生产还是开发
7
- mode: Array.isArray(parsed.build) ? "production" : "development",
8
-
9
- // 平台
10
- platform: (Array.isArray(parsed.build) ? parsed.build[0] : parsed.dev[0]) || "h5",
11
-
12
- // 项目根目录
13
- root: (Array.isArray(parsed.root) && parsed.root[0]) ? parsed.root[0] : "./"
14
- };
15
- };
@@ -1,60 +0,0 @@
1
- const path = require('path');
2
- const HtmlWebpackPlugin = require('html-webpack-plugin');
3
-
4
- module.exports = function (parsed) {
5
-
6
- const config = {
7
- entry: path.resolve(process.cwd(), parsed.root, "./src/app.js"),
8
- mode: parsed.mode,
9
- plugins: []
10
- };
11
-
12
- // 开发模式
13
- if (parsed.mode == "development") {
14
-
15
- // H5环境
16
- if (parsed.platform == "h5") {
17
- config.devServer = {
18
- open: false,
19
- host: '0.0.0.0',
20
- port: 8080,
21
- hot: true,
22
- compress: false,
23
- historyApiFallback: true
24
- };
25
- }
26
-
27
- // 其它环境
28
- else {
29
- config.output = {
30
- path: path.resolve(process.cwd(), parsed.root, "./dist/dev/" + parsed.platform),
31
- clean: false
32
- };
33
-
34
- config.watchOptions = {
35
- aggregateTimeout: 600, // 当第一个文件更改,会在重新构建前增加延迟
36
- poll: 5007, // 指定毫秒为单位进行轮询
37
- ignored: ['**/node_modules'], // 排除像 node_modules 如此庞大的文件夹
38
- };
39
- }
40
-
41
- }
42
-
43
- // 生产模式
44
- else {
45
- config.output = {
46
- path: path.resolve(process.cwd(), parsed.root, "./dist/build/" + parsed.platform),
47
- clean: true
48
- };
49
- }
50
-
51
- // H5环境
52
- if (parsed.platform == "h5") {
53
- config.plugins.push(new HtmlWebpackPlugin({
54
- template: path.resolve(__dirname, '../../public/index.html'),
55
- title: "OIPage"
56
- }));
57
- }
58
-
59
- return config;
60
- };
File without changes
File without changes