oipage 0.2.0 → 1.0.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.
- package/CHANGELOG +16 -1
- package/README.md +1 -102
- package/bin/mineTypes.json +105 -0
- package/{nodejs/core → bin}/network.js +7 -4
- package/bin/resolve404.js +78 -0
- package/bin/run +8 -200
- package/bin/serve.js +64 -0
- package/images/file.png +0 -0
- package/images/folder.png +0 -0
- package/images/goback.png +0 -0
- package/{corejs → nodejs}/animation/index.js +8 -2
- package/nodejs/deeplog/index.d.ts +10 -0
- package/nodejs/deeplog/index.js +35 -0
- package/nodejs/linelog/index.d.ts +9 -0
- package/nodejs/{core/log.js → linelog/index.js} +12 -55
- package/{corejs → nodejs}/throttle/index.js +9 -3
- package/package.json +12 -5
- package/web/animation/index.d.ts +12 -0
- package/web/animation/index.js +108 -0
- package/{browserjs → web}/getStyle/index.js +8 -2
- package/{browserjs → web}/onReady/index.js +8 -2
- package/web/setStyle/index.js +11 -0
- package/web/throttle/index.d.ts +31 -0
- package/web/throttle/index.js +56 -0
- package/AUTHORS.txt +0 -6
- package/bin/options.js +0 -74
- package/browserjs/index.d.ts +0 -13
- package/browserjs/index.js +0 -9
- package/browserjs/setStyle/index.js +0 -5
- package/corejs/index.d.ts +0 -10
- package/corejs/index.js +0 -7
- package/nodejs/core/file.js +0 -128
- package/nodejs/core/image.js +0 -5
- package/nodejs/core/options.js +0 -49
- package/nodejs/core/remote.js +0 -60
- package/nodejs/core/responseFileList.js +0 -28
- package/nodejs/core/server.js +0 -176
- package/nodejs/data/404.js +0 -52
- package/nodejs/data/images/file.js +0 -1
- package/nodejs/data/images/folder.js +0 -1
- package/nodejs/data/mime.types.js +0 -112
- package/nodejs/form/common.js +0 -3
- package/nodejs/form/index.js +0 -80
- package/nodejs/form/select.js +0 -10
- package/nodejs/index.js +0 -58
- package/nodejs/loader/simpleScss.js +0 -248
- package/nodejs/loader/xhtml.js +0 -521
- package/nodejs/reader/plain.js +0 -20
- package/stylecss/index.css +0 -3
- package/stylecss/normalize.css +0 -94
- package/stylecss/rasterize.css +0 -318
- package/stylecss/skeleton.css +0 -16
- package/types/get-options.d.ts +0 -6
- package/types/index.d.ts +0 -187
- /package/{corejs → nodejs}/animation/index.d.ts +0 -0
- /package/{corejs → nodejs}/throttle/index.d.ts +0 -0
- /package/{browserjs → web}/getStyle/index.d.ts +0 -0
- /package/{browserjs → web}/onReady/index.d.ts +0 -0
- /package/{browserjs → web}/setStyle/index.d.ts +0 -0
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"html": "text/html",
|
|
3
|
-
"htm": "text/html",
|
|
4
|
-
"shtml": "text/html",
|
|
5
|
-
"css": "text/css",
|
|
6
|
-
"xml": "text/xml",
|
|
7
|
-
"gif": "image/gif",
|
|
8
|
-
"jpeg": "image/jpeg",
|
|
9
|
-
"jpg": "image/jpeg",
|
|
10
|
-
"js": "application/javascript",
|
|
11
|
-
"atom": "application/atom+xml",
|
|
12
|
-
"rss": "application/rss+xml",
|
|
13
|
-
|
|
14
|
-
"mml": "text/mathml",
|
|
15
|
-
"txt": "text/plain",
|
|
16
|
-
"jad": "text/vnd.sun.j2me.app-descriptor",
|
|
17
|
-
"wml": "text/vnd.wap.wml",
|
|
18
|
-
"htc": "text/x-component",
|
|
19
|
-
|
|
20
|
-
"png": "image/png",
|
|
21
|
-
"tif": "image/tiff",
|
|
22
|
-
"tiff": "image/tiff",
|
|
23
|
-
"wbmp": "image/vnd.wap.wbmp",
|
|
24
|
-
"ico": "image/x-icon",
|
|
25
|
-
"jng": "image/x-jng",
|
|
26
|
-
"bmp": "image/x-ms-bmp",
|
|
27
|
-
"svg": "image/svg+xml",
|
|
28
|
-
"svgz": "image/svg+xml",
|
|
29
|
-
"webp": "image/webp",
|
|
30
|
-
|
|
31
|
-
"woff": "application/font-woff",
|
|
32
|
-
"jar": "application/java-archive",
|
|
33
|
-
"war": "application/java-archive",
|
|
34
|
-
"ear": "application/java-archive",
|
|
35
|
-
"json": "application/json",
|
|
36
|
-
"hqx": "application/mac-binhex40",
|
|
37
|
-
"doc": "application/msword",
|
|
38
|
-
"pdf": "application/pdf",
|
|
39
|
-
"ps": "application/postscript",
|
|
40
|
-
"eps": "application/postscript",
|
|
41
|
-
"ai": "application/postscript",
|
|
42
|
-
"rtf": "application/rtf",
|
|
43
|
-
"m3u8": "application/vnd.apple.mpegurl",
|
|
44
|
-
"xls": "application/vnd.ms-excel",
|
|
45
|
-
"eot": "application/vnd.ms-fontobject",
|
|
46
|
-
"ppt": "application/vnd.ms-powerpoint",
|
|
47
|
-
"wmlc": "application/vnd.wap.wmlc",
|
|
48
|
-
"kml": "application/vnd.google-earth.kml+xml",
|
|
49
|
-
"kmz": "application/vnd.google-earth.kmz",
|
|
50
|
-
"7z": "application/x-7z-compressed",
|
|
51
|
-
"cco": "application/x-cocoa",
|
|
52
|
-
"jardiff": "application/x-java-archive-diff",
|
|
53
|
-
"jnlp": "application/x-java-jnlp-file",
|
|
54
|
-
"run": "application/x-makeself",
|
|
55
|
-
"pl": "application/x-perl",
|
|
56
|
-
"pm": "application/x-perl",
|
|
57
|
-
"prc": "application/x-pilot",
|
|
58
|
-
"pdb": "application/x-pilot",
|
|
59
|
-
"rar": "application/x-rar-compressed",
|
|
60
|
-
"rpm": "application/x-redhat-package-manager",
|
|
61
|
-
"sea": "application/x-sea",
|
|
62
|
-
"swf": "application/x-shockwave-flash",
|
|
63
|
-
"sit": "application/x-stuffit",
|
|
64
|
-
"tcl": "application/x-tcl",
|
|
65
|
-
"tk": "application/x-tcl",
|
|
66
|
-
"der": "application/x-x509-ca-cert",
|
|
67
|
-
"pem": "application/x-x509-ca-cert",
|
|
68
|
-
"crt": "application/x-x509-ca-cert",
|
|
69
|
-
"xpi": "application/x-xpinstall",
|
|
70
|
-
"xhtml": "application/xhtml+xml",
|
|
71
|
-
"xspf": "application/xspf+xml",
|
|
72
|
-
"zip": "application/zip",
|
|
73
|
-
|
|
74
|
-
"bin": "application/octet-stream",
|
|
75
|
-
"exe": "application/octet-stream",
|
|
76
|
-
"dll": "application/octet-stream",
|
|
77
|
-
"deb": "application/octet-stream",
|
|
78
|
-
"dmg": "application/octet-stream",
|
|
79
|
-
"iso": "application/octet-stream",
|
|
80
|
-
"img": "application/octet-stream",
|
|
81
|
-
"msi": "application/octet-stream",
|
|
82
|
-
"msp": "application/octet-stream",
|
|
83
|
-
"msm": "application/octet-stream",
|
|
84
|
-
|
|
85
|
-
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
86
|
-
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
87
|
-
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
88
|
-
|
|
89
|
-
"mid": "audio/midi",
|
|
90
|
-
"midi": "audio/midi",
|
|
91
|
-
"kar": "audio/midi",
|
|
92
|
-
"mp3": "audio/mpeg",
|
|
93
|
-
"ogg": "audio/ogg",
|
|
94
|
-
"m4a": "audio/x-m4a",
|
|
95
|
-
"ra": "audio/x-realaudio",
|
|
96
|
-
|
|
97
|
-
"3gpp": "video/3gpp",
|
|
98
|
-
"3gp": "video/3gpp",
|
|
99
|
-
"ts": "video/mp2t",
|
|
100
|
-
"mp4": "video/mp4",
|
|
101
|
-
"mpeg": "video/mpeg",
|
|
102
|
-
"mpg": "video/mpeg",
|
|
103
|
-
"mov": "video/quicktime",
|
|
104
|
-
"webm": "video/webm",
|
|
105
|
-
"flv": "video/x-flv",
|
|
106
|
-
"m4v": "video/x-m4v",
|
|
107
|
-
"mng": "video/x-mng",
|
|
108
|
-
"asx": "video/x-ms-asf",
|
|
109
|
-
"asf": "video/x-ms-asf",
|
|
110
|
-
"wmv": "video/x-ms-wmv",
|
|
111
|
-
"avi": "video/x-msvideo"
|
|
112
|
-
};
|
package/nodejs/form/common.js
DELETED
package/nodejs/form/index.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const { getTitle } = require("./common");
|
|
2
|
-
const { logView } = require("./select");
|
|
3
|
-
const { linelog } = require("../core/log");
|
|
4
|
-
|
|
5
|
-
module.exports = function (form) {
|
|
6
|
-
const rl = require("readline").createInterface({
|
|
7
|
-
input: process.stdin,
|
|
8
|
-
output: process.stdout
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
return new Promise(function (resolve, reject) {
|
|
12
|
-
let result = [], keyback = () => { };
|
|
13
|
-
|
|
14
|
-
console.log("");
|
|
15
|
-
|
|
16
|
-
process.stdin.on("keypress", (_str, key) => {
|
|
17
|
-
keyback(key.name);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
let getResult = (index) => {
|
|
21
|
-
if (index >= form.length) {
|
|
22
|
-
process.removeAllListeners("keypress");
|
|
23
|
-
rl.close();
|
|
24
|
-
resolve(result);
|
|
25
|
-
} else {
|
|
26
|
-
let item = form[index];
|
|
27
|
-
|
|
28
|
-
// 文本输入
|
|
29
|
-
if (item.type == "input") {
|
|
30
|
-
|
|
31
|
-
rl.question(getTitle(item.label), (answer) => {
|
|
32
|
-
result.push(answer);
|
|
33
|
-
setTimeout(() => {
|
|
34
|
-
console.log("");
|
|
35
|
-
getResult(index + 1);
|
|
36
|
-
}, 50);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// 列表选择
|
|
42
|
-
else if (item.type == "select") {
|
|
43
|
-
let title = getTitle(item.label);
|
|
44
|
-
|
|
45
|
-
let selectIndex = 0;
|
|
46
|
-
logView(title, item.value, selectIndex);
|
|
47
|
-
keyback = (keyname) => {
|
|
48
|
-
if (keyname == "return") {
|
|
49
|
-
result.push(selectIndex);
|
|
50
|
-
keyback = () => { };
|
|
51
|
-
linelog();
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
getResult(index + 1);
|
|
54
|
-
}, 50);
|
|
55
|
-
} else {
|
|
56
|
-
if (keyname == "left" || keyname == "up") {
|
|
57
|
-
if (selectIndex > 0) selectIndex -= 1;
|
|
58
|
-
else selectIndex = item.value.length - 1;
|
|
59
|
-
} else if (keyname == "right" || keyname == "down") {
|
|
60
|
-
if (selectIndex < item.value.length - 1) selectIndex += 1;
|
|
61
|
-
else selectIndex = 0;
|
|
62
|
-
} else {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
logView(title, item.value, selectIndex);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 非法类型
|
|
72
|
-
else {
|
|
73
|
-
throw new Error("Illegal type!");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
};
|
|
78
|
-
getResult(0);
|
|
79
|
-
});
|
|
80
|
-
};
|
package/nodejs/form/select.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const { linelog } = require("../core/log");
|
|
2
|
-
|
|
3
|
-
exports.logView = (title, list, index) => {
|
|
4
|
-
let txtArray = [];
|
|
5
|
-
for (let i = 0; i < list.length; i++) {
|
|
6
|
-
txtArray.push(" " + (i == index ? "●" : "○") + " " + list[i]);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
linelog(`${title}\n${txtArray.join("\n")}\n`);
|
|
10
|
-
};
|
package/nodejs/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const { deleteSync, copySync, moveSync, listFileSync, fullPathSync } = require('./core/file');
|
|
2
|
-
const { log, warn, error, linelog, deeplog } = require('./core/log');
|
|
3
|
-
const options = require('./core/options');
|
|
4
|
-
const { get, post } = require('./core/remote');
|
|
5
|
-
const network = require('./core/network');
|
|
6
|
-
const mimeTypes = require('./data/mime.types');
|
|
7
|
-
const server = require('./core/server');
|
|
8
|
-
const { toBase64 } = require('./core/image');
|
|
9
|
-
|
|
10
|
-
const simpleScss = require('./loader/simpleScss');
|
|
11
|
-
const xhtml = require('./loader/xhtml');
|
|
12
|
-
|
|
13
|
-
const plain = require('./reader/plain');
|
|
14
|
-
|
|
15
|
-
const form = require('./form/index');
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
|
|
19
|
-
// 命令行相关
|
|
20
|
-
options,
|
|
21
|
-
|
|
22
|
-
// 文件操作相关
|
|
23
|
-
deleteSync, copySync, moveSync, listFileSync, fullPathSync,
|
|
24
|
-
|
|
25
|
-
// 图片相关
|
|
26
|
-
toBase64,
|
|
27
|
-
|
|
28
|
-
// 日志打印
|
|
29
|
-
log, warn, error,
|
|
30
|
-
|
|
31
|
-
// 单行打印
|
|
32
|
-
linelog,
|
|
33
|
-
|
|
34
|
-
// 进度打印
|
|
35
|
-
process: deeplog, // 向下兼容
|
|
36
|
-
deeplog,
|
|
37
|
-
|
|
38
|
-
// 请求
|
|
39
|
-
get, post,
|
|
40
|
-
|
|
41
|
-
// 查看网络信息
|
|
42
|
-
network,
|
|
43
|
-
|
|
44
|
-
// 文件类型
|
|
45
|
-
mimeTypes,
|
|
46
|
-
|
|
47
|
-
// 服务器
|
|
48
|
-
server,
|
|
49
|
-
|
|
50
|
-
// 文件解析
|
|
51
|
-
simpleScss, xhtml,
|
|
52
|
-
|
|
53
|
-
// 文件读取
|
|
54
|
-
plain,
|
|
55
|
-
|
|
56
|
-
// 表单录入
|
|
57
|
-
form
|
|
58
|
-
};
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
let toSelector = function (preSelectorArray, deep) {
|
|
2
|
-
|
|
3
|
-
let selectors = preSelectorArray[0], i, j, k;
|
|
4
|
-
|
|
5
|
-
// 一层层深入
|
|
6
|
-
for (i = 1; i < deep; i++) {
|
|
7
|
-
|
|
8
|
-
let temp = [];
|
|
9
|
-
// 前置循环
|
|
10
|
-
for (j = 0; j < selectors.length; j++) {
|
|
11
|
-
|
|
12
|
-
// 预选循环
|
|
13
|
-
for (k = 0; k < preSelectorArray[i].length; k++) {
|
|
14
|
-
|
|
15
|
-
temp.push(selectors[j] + preSelectorArray[i][k]);
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
selectors = temp;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// 最后补充 {
|
|
25
|
-
return "\n" + (selectors.join(',')) + "{\n";
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// 把代码变成代码块
|
|
29
|
-
// 比如一个注释就是一块,无论注释的内容有多少
|
|
30
|
-
let analyseBlock = function (source) {
|
|
31
|
-
|
|
32
|
-
let i = -1,
|
|
33
|
-
|
|
34
|
-
// 当前面对的字符
|
|
35
|
-
currentChar = null;
|
|
36
|
-
|
|
37
|
-
// 获取下一个字符
|
|
38
|
-
let next = function () {
|
|
39
|
-
currentChar = i++ < source.length - 1 ? source[i] : null;
|
|
40
|
-
return currentChar;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// 获取往后n个值
|
|
44
|
-
let nextNValue = function (n) {
|
|
45
|
-
return source.substring(i, n + i > source.length ? source.length : n + i);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
let blocks = [];
|
|
49
|
-
let currentBlock = "";
|
|
50
|
-
|
|
51
|
-
next();
|
|
52
|
-
|
|
53
|
-
while (true) {
|
|
54
|
-
|
|
55
|
-
// 先剔除空白字符
|
|
56
|
-
// 保证正式开始的时候匹配的是有效的
|
|
57
|
-
while (new RegExp("[\\x20\\t\\r\\n\\f]").test(currentChar)) {
|
|
58
|
-
next();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 如果匹配的字符没有了
|
|
62
|
-
if (currentChar == null) break;
|
|
63
|
-
|
|
64
|
-
// 如果是注释
|
|
65
|
-
// /* 类型一 */
|
|
66
|
-
if (nextNValue(2) == '/*') {
|
|
67
|
-
|
|
68
|
-
next(); next();
|
|
69
|
-
currentBlock = "/*";
|
|
70
|
-
|
|
71
|
-
while (nextNValue(2) != '*/' && currentChar != null) {
|
|
72
|
-
currentBlock += currentChar;
|
|
73
|
-
next();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// 对于注释 /* */
|
|
77
|
-
// 如果到结尾都没有闭合,应该提示语法错误
|
|
78
|
-
if (currentChar == null) {
|
|
79
|
-
throw new Error('The comment is not closed.');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
currentBlock += "*/";
|
|
83
|
-
next(); next();
|
|
84
|
-
|
|
85
|
-
blocks.push({
|
|
86
|
-
value: currentBlock,
|
|
87
|
-
type: "comment-double"
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 如果是注释
|
|
92
|
-
// // 类型二
|
|
93
|
-
else if (nextNValue(2) == '//') {
|
|
94
|
-
currentBlock = '';
|
|
95
|
-
|
|
96
|
-
while (currentChar != '\n' && currentChar != null) {
|
|
97
|
-
currentBlock += currentChar;
|
|
98
|
-
next();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
blocks.push({
|
|
102
|
-
value: currentBlock,
|
|
103
|
-
type: "comment-single"
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// 如果是结束
|
|
109
|
-
// }
|
|
110
|
-
else if (currentChar == '}') {
|
|
111
|
-
|
|
112
|
-
blocks.push({
|
|
113
|
-
value: "}",
|
|
114
|
-
type: "end"
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
next();
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 余下,只有两种情况:
|
|
122
|
-
// 1.如是是开始
|
|
123
|
-
// xxx {
|
|
124
|
-
// 2.可能是一个语句
|
|
125
|
-
// xxx : xxx ;
|
|
126
|
-
// 这两种都需要进一步匹配
|
|
127
|
-
else {
|
|
128
|
-
|
|
129
|
-
currentBlock = '';
|
|
130
|
-
|
|
131
|
-
// 目前先没有考虑下列情况:
|
|
132
|
-
// 语句 content:";"
|
|
133
|
-
while (currentChar != '{' && currentChar != ';' && currentChar != null) {
|
|
134
|
-
currentBlock += currentChar;
|
|
135
|
-
next();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (currentChar == null) {
|
|
139
|
-
throw new Error('Statement or code block missing closure.');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
blocks.push({
|
|
143
|
-
value: currentBlock + currentChar,
|
|
144
|
-
type: {
|
|
145
|
-
'{': "begin",
|
|
146
|
-
';': 'statement'
|
|
147
|
-
}[currentChar]
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
next();
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return blocks;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
module.exports = function (source) {
|
|
161
|
-
|
|
162
|
-
// 分析出代码块
|
|
163
|
-
|
|
164
|
-
let blocks = analyseBlock(source);
|
|
165
|
-
|
|
166
|
-
// 根据代码块获得最终代码
|
|
167
|
-
|
|
168
|
-
let i, j, cssCode = "", preSelectorArray = [], deep = 0;
|
|
169
|
-
for (i = 0; i < blocks.length; i++) {
|
|
170
|
-
|
|
171
|
-
// 注释 double
|
|
172
|
-
if (blocks[i].type == 'comment-double') {
|
|
173
|
-
|
|
174
|
-
cssCode += blocks[i].value;
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// 注释 single
|
|
179
|
-
else if (blocks[i].type == 'comment-single') {
|
|
180
|
-
|
|
181
|
-
cssCode += "\n/* " + blocks[i].value + " */\n";
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// 开始
|
|
186
|
-
else if (blocks[i].type == 'begin') {
|
|
187
|
-
|
|
188
|
-
let preSplit = blocks[i].value.split(',');
|
|
189
|
-
let preSelect = [];
|
|
190
|
-
for (j = 0; j < preSplit.length; j++) {
|
|
191
|
-
|
|
192
|
-
// 去掉两端的空格
|
|
193
|
-
preSelect[j] = preSplit[j].replace(/\{$/, '').trim();
|
|
194
|
-
|
|
195
|
-
// 判断拼接方式
|
|
196
|
-
if (/^&/.test(preSelect[j])) {
|
|
197
|
-
preSelect[j] = preSelect[j].replace(/^&/, '');
|
|
198
|
-
} else {
|
|
199
|
-
preSelect[j] = " " + preSelect[j];
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// 登记到前缀数组
|
|
205
|
-
preSelectorArray[deep] = preSelect;
|
|
206
|
-
deep += 1;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// 结束
|
|
210
|
-
else if (blocks[i].type == 'end') {
|
|
211
|
-
|
|
212
|
-
deep -= 1;
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// 语句
|
|
217
|
-
else if (blocks[i].type == 'statement') {
|
|
218
|
-
|
|
219
|
-
// 如果是第一个
|
|
220
|
-
j = 1;
|
|
221
|
-
let preType = blocks[i - j].type;
|
|
222
|
-
while (['comment-double', 'comment-single'].indexOf(preType) > -1) {
|
|
223
|
-
j += 1;
|
|
224
|
-
preType = blocks[i - j].type;
|
|
225
|
-
}
|
|
226
|
-
if (['end', 'begin'].indexOf(preType) > -1) {
|
|
227
|
-
cssCode += toSelector(preSelectorArray, deep);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
cssCode += "\n" + blocks[i].value + "\n";
|
|
231
|
-
|
|
232
|
-
// 如果是最后一个
|
|
233
|
-
j = 1;
|
|
234
|
-
let nextType = blocks[i + j].type;
|
|
235
|
-
while (['comment-double', 'comment-single'].indexOf(nextType) > -1) {
|
|
236
|
-
j += 1;
|
|
237
|
-
nextType = blocks[i + j].type;
|
|
238
|
-
}
|
|
239
|
-
if (['end', 'begin'].indexOf(nextType) > -1) {
|
|
240
|
-
cssCode += "\n}\n";
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return cssCode;
|
|
248
|
-
};
|