oipage 0.2.0 → 0.3.1-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/.github/FUNDING.yml +11 -11
- package/AUTHORS.txt +6 -6
- package/CHANGELOG +62 -43
- package/LICENSE +20 -20
- package/README.md +122 -122
- package/bin/options.js +73 -73
- package/bin/run +208 -208
- package/browserjs/getStyle/index.d.ts +10 -10
- package/browserjs/getStyle/index.js +12 -12
- package/browserjs/index.d.ts +12 -12
- package/browserjs/index.js +8 -8
- package/browserjs/onReady/index.d.ts +7 -7
- package/browserjs/onReady/index.js +7 -7
- package/browserjs/setStyle/index.d.ts +9 -9
- package/browserjs/setStyle/index.js +4 -4
- package/corejs/animation/index.d.ts +11 -11
- package/corejs/animation/index.js +101 -101
- package/corejs/index.d.ts +9 -9
- package/corejs/index.js +6 -6
- package/corejs/throttle/index.d.ts +30 -30
- package/corejs/throttle/index.js +49 -49
- package/nodejs/core/file.js +162 -127
- package/nodejs/core/image.js +4 -4
- package/nodejs/core/log.js +89 -89
- package/nodejs/core/network.js +39 -39
- package/nodejs/core/options.js +48 -48
- package/nodejs/core/remote.js +60 -60
- package/nodejs/core/responseFileList.js +27 -27
- package/nodejs/core/server.js +198 -175
- package/nodejs/data/404.js +51 -51
- package/nodejs/data/mime.types.js +111 -111
- package/nodejs/form/common.js +2 -2
- package/nodejs/form/index.js +79 -79
- package/nodejs/form/select.js +9 -9
- package/nodejs/index.js +57 -57
- package/nodejs/loader/simpleScss.js +247 -247
- package/nodejs/loader/xhtml.js +520 -520
- package/nodejs/reader/plain.js +20 -20
- package/package.json +33 -33
- package/stylecss/index.css +3 -3
- package/stylecss/normalize.css +93 -93
- package/stylecss/rasterize.css +317 -317
- package/stylecss/skeleton.css +16 -16
- package/types/get-options.d.ts +5 -5
- package/types/index.d.ts +186 -186
package/bin/run
CHANGED
|
@@ -1,209 +1,209 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
process.title = 'OIPage';
|
|
6
|
-
|
|
7
|
-
const server = require('../nodejs/core/server');
|
|
8
|
-
const { options, help } = require('./options');
|
|
9
|
-
const { log, error } = require('../nodejs/core/log');
|
|
10
|
-
const { deleteSync, copySync, moveSync, listFileSync, fullPathSync } = require("../nodejs/core/file");
|
|
11
|
-
const network = require("../nodejs/core/network");
|
|
12
|
-
const { get, post } = require("../nodejs/core/remote");
|
|
13
|
-
const fs = require("fs");
|
|
14
|
-
const path = require("path");
|
|
15
|
-
const { exec } = require('child_process');
|
|
16
|
-
|
|
17
|
-
const jsonfile = require("../package.json");
|
|
18
|
-
|
|
19
|
-
// 组装好缩写和全写的映射
|
|
20
|
-
let shortHands = {};
|
|
21
|
-
for (let key in options) {
|
|
22
|
-
if (options[key].short) shortHands["-" + options[key].short] = "--" + key;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 命令行传递的参数
|
|
26
|
-
const parsed = require("../nodejs/core/options")(shortHands, process.argv);
|
|
27
|
-
|
|
28
|
-
(() => {
|
|
29
|
-
|
|
30
|
-
// 打印版本
|
|
31
|
-
if (Array.isArray(parsed.version)) {
|
|
32
|
-
log("\nOIPage@v" + jsonfile.version + "\n");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 基于配置文件运行
|
|
36
|
-
else if (Array.isArray(parsed.config)) {
|
|
37
|
-
if (parsed.config.length < 1) parsed.config[0] = './oipage.config.js';
|
|
38
|
-
|
|
39
|
-
// 读取配置
|
|
40
|
-
let configFile = require(path.join(process.cwd(), parsed.config[0]));
|
|
41
|
-
|
|
42
|
-
// 如果配置了服务器
|
|
43
|
-
if ("devServer" in configFile) {
|
|
44
|
-
server(configFile.devServer);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 删除
|
|
49
|
-
else if (Array.isArray(parsed.delete)) {
|
|
50
|
-
|
|
51
|
-
// 获取绝对路径
|
|
52
|
-
let targetPath = fullPathSync(parsed.delete[0]);
|
|
53
|
-
|
|
54
|
-
deleteSync(targetPath);
|
|
55
|
-
log(`> delete ${targetPath.replace(process.cwd(), '.')}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 复制
|
|
59
|
-
else if (Array.isArray(parsed.copy)) {
|
|
60
|
-
|
|
61
|
-
// 获取绝对路径
|
|
62
|
-
let sourcePath = fullPathSync(parsed.copy[0]);
|
|
63
|
-
let targetPath = fullPathSync(parsed.copy[1]);
|
|
64
|
-
|
|
65
|
-
// 如果存在
|
|
66
|
-
copySync(sourcePath, targetPath);
|
|
67
|
-
log(`> copy ${sourcePath.replace(process.cwd(), '.')} ➔ ${targetPath.replace(process.cwd(), '.')}`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 复制文件(一级展开)
|
|
71
|
-
else if (Array.isArray(parsed.pick)) {
|
|
72
|
-
|
|
73
|
-
// 如果目标文件夹不存在,创建
|
|
74
|
-
if (!fs.existsSync(parsed.pick[1])) {
|
|
75
|
-
fs.mkdirSync(parsed.pick[1], { recursive: true });
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
listFileSync(parsed.pick[0], fileInfo => {
|
|
79
|
-
|
|
80
|
-
// 获取路径
|
|
81
|
-
let sourcePath = fullPathSync(fileInfo.path);
|
|
82
|
-
let targetPath = fullPathSync(path.join(parsed.pick[1], fileInfo.name));
|
|
83
|
-
|
|
84
|
-
let index = 1;
|
|
85
|
-
while (fs.existsSync(targetPath)) {
|
|
86
|
-
targetPath = fullPathSync(path.join(parsed.pick[1], "【" + index + "】" + fileInfo.name));
|
|
87
|
-
index += 1;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
log(`> copy ${sourcePath.replace(process.cwd(), '.')} ➔ ${targetPath.replace(process.cwd(), '.')}`);
|
|
91
|
-
copySync(sourcePath, targetPath);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 移动
|
|
96
|
-
else if (Array.isArray(parsed.move)) {
|
|
97
|
-
|
|
98
|
-
// 获取绝对路径
|
|
99
|
-
let sourcePath = fullPathSync(parsed.move[0]);
|
|
100
|
-
let targetPath = fullPathSync(parsed.move[1]);
|
|
101
|
-
|
|
102
|
-
// 如果存在
|
|
103
|
-
moveSync(sourcePath, targetPath);
|
|
104
|
-
log(`> move ${sourcePath.replace(process.cwd(), '.')} ➔ ${targetPath.replace(process.cwd(), '.')}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 网络信息
|
|
108
|
-
else if (Array.isArray(parsed.network)) {
|
|
109
|
-
log(JSON.stringify(network(), null, 4));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// GET请求
|
|
113
|
-
else if (Array.isArray(parsed.get)) {
|
|
114
|
-
get(parsed.get[0]).then(data => {
|
|
115
|
-
log(data);
|
|
116
|
-
}).catch(e => {
|
|
117
|
-
error(e);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// PSOT请求
|
|
122
|
-
else if (Array.isArray(parsed.post)) {
|
|
123
|
-
post(parsed.post[0]).then(data => {
|
|
124
|
-
log(data);
|
|
125
|
-
}).catch(e => {
|
|
126
|
-
error(e);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// 查看文件
|
|
131
|
-
else if (Array.isArray(parsed.cat)) {
|
|
132
|
-
try {
|
|
133
|
-
let filepath = fullPathSync(parsed.cat[0])
|
|
134
|
-
|
|
135
|
-
log(fs.readFileSync(filepath, {
|
|
136
|
-
encoding: "utf8"
|
|
137
|
-
}));
|
|
138
|
-
} catch (e) {
|
|
139
|
-
error(e);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// 运行多命令
|
|
144
|
-
else if (Array.isArray(parsed.run)) {
|
|
145
|
-
for (let index = 0; index < parsed.run.length; index++) {
|
|
146
|
-
const child = exec(parsed.run[index]);
|
|
147
|
-
|
|
148
|
-
// 监听子线程的stdout
|
|
149
|
-
child.stdout.on('data', (data) => {
|
|
150
|
-
console.log(`[${index + 1}] log:${data}`);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// 监听子线程的stderr
|
|
154
|
-
child.stderr.on('data', (data) => {
|
|
155
|
-
console.error(`[${index + 1}] error:${data}`);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// 子线程结束处理
|
|
159
|
-
child.on('close', (code) => {
|
|
160
|
-
console.log(`[${index + 1}] 子线程结束,退出码 ${code}`);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// 子线程出错处理
|
|
164
|
-
child.on('error', (error) => {
|
|
165
|
-
console.error(`[${index + 1}] 子线程错误: ${error.message}`);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// 服务器
|
|
171
|
-
else if (Array.isArray(parsed.server)) {
|
|
172
|
-
server({
|
|
173
|
-
port: parsed.server[0],
|
|
174
|
-
basePath: parsed.server[1]
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// 否则就是帮助
|
|
179
|
-
else {
|
|
180
|
-
let helpParsed = Array.isArray(parsed.help) ? parsed.help : parsed.__terminal__;
|
|
181
|
-
|
|
182
|
-
// 打印具体的配置提示
|
|
183
|
-
if (helpParsed && helpParsed.length > 0) {
|
|
184
|
-
let help0 = helpParsed[0];
|
|
185
|
-
|
|
186
|
-
// 缩写转全拼
|
|
187
|
-
if (help0.length == 1) {
|
|
188
|
-
help0 = shortHands["-" + help0];
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (help0) {
|
|
192
|
-
help0 = help0.replace(/^--/, "");
|
|
193
|
-
|
|
194
|
-
// 根据需要帮助的命令获取对应的信息
|
|
195
|
-
const help0Option = options[help0];
|
|
196
|
-
if (help0Option) {
|
|
197
|
-
log(`
|
|
198
|
-
` + help0Option.demo + ` ` + help0Option.info + `
|
|
199
|
-
`);
|
|
200
|
-
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
log(help);
|
|
208
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
process.title = 'OIPage';
|
|
6
|
+
|
|
7
|
+
const server = require('../nodejs/core/server');
|
|
8
|
+
const { options, help } = require('./options');
|
|
9
|
+
const { log, error } = require('../nodejs/core/log');
|
|
10
|
+
const { deleteSync, copySync, moveSync, listFileSync, fullPathSync } = require("../nodejs/core/file");
|
|
11
|
+
const network = require("../nodejs/core/network");
|
|
12
|
+
const { get, post } = require("../nodejs/core/remote");
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const { exec } = require('child_process');
|
|
16
|
+
|
|
17
|
+
const jsonfile = require("../package.json");
|
|
18
|
+
|
|
19
|
+
// 组装好缩写和全写的映射
|
|
20
|
+
let shortHands = {};
|
|
21
|
+
for (let key in options) {
|
|
22
|
+
if (options[key].short) shortHands["-" + options[key].short] = "--" + key;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 命令行传递的参数
|
|
26
|
+
const parsed = require("../nodejs/core/options")(shortHands, process.argv);
|
|
27
|
+
|
|
28
|
+
(() => {
|
|
29
|
+
|
|
30
|
+
// 打印版本
|
|
31
|
+
if (Array.isArray(parsed.version)) {
|
|
32
|
+
log("\nOIPage@v" + jsonfile.version + "\n");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 基于配置文件运行
|
|
36
|
+
else if (Array.isArray(parsed.config)) {
|
|
37
|
+
if (parsed.config.length < 1) parsed.config[0] = './oipage.config.js';
|
|
38
|
+
|
|
39
|
+
// 读取配置
|
|
40
|
+
let configFile = require(path.join(process.cwd(), parsed.config[0]));
|
|
41
|
+
|
|
42
|
+
// 如果配置了服务器
|
|
43
|
+
if ("devServer" in configFile) {
|
|
44
|
+
server(configFile.devServer);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 删除
|
|
49
|
+
else if (Array.isArray(parsed.delete)) {
|
|
50
|
+
|
|
51
|
+
// 获取绝对路径
|
|
52
|
+
let targetPath = fullPathSync(parsed.delete[0]);
|
|
53
|
+
|
|
54
|
+
deleteSync(targetPath);
|
|
55
|
+
log(`> delete ${targetPath.replace(process.cwd(), '.')}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 复制
|
|
59
|
+
else if (Array.isArray(parsed.copy)) {
|
|
60
|
+
|
|
61
|
+
// 获取绝对路径
|
|
62
|
+
let sourcePath = fullPathSync(parsed.copy[0]);
|
|
63
|
+
let targetPath = fullPathSync(parsed.copy[1]);
|
|
64
|
+
|
|
65
|
+
// 如果存在
|
|
66
|
+
copySync(sourcePath, targetPath);
|
|
67
|
+
log(`> copy ${sourcePath.replace(process.cwd(), '.')} ➔ ${targetPath.replace(process.cwd(), '.')}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 复制文件(一级展开)
|
|
71
|
+
else if (Array.isArray(parsed.pick)) {
|
|
72
|
+
|
|
73
|
+
// 如果目标文件夹不存在,创建
|
|
74
|
+
if (!fs.existsSync(parsed.pick[1])) {
|
|
75
|
+
fs.mkdirSync(parsed.pick[1], { recursive: true });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
listFileSync(parsed.pick[0], fileInfo => {
|
|
79
|
+
|
|
80
|
+
// 获取路径
|
|
81
|
+
let sourcePath = fullPathSync(fileInfo.path);
|
|
82
|
+
let targetPath = fullPathSync(path.join(parsed.pick[1], fileInfo.name));
|
|
83
|
+
|
|
84
|
+
let index = 1;
|
|
85
|
+
while (fs.existsSync(targetPath)) {
|
|
86
|
+
targetPath = fullPathSync(path.join(parsed.pick[1], "【" + index + "】" + fileInfo.name));
|
|
87
|
+
index += 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
log(`> copy ${sourcePath.replace(process.cwd(), '.')} ➔ ${targetPath.replace(process.cwd(), '.')}`);
|
|
91
|
+
copySync(sourcePath, targetPath);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 移动
|
|
96
|
+
else if (Array.isArray(parsed.move)) {
|
|
97
|
+
|
|
98
|
+
// 获取绝对路径
|
|
99
|
+
let sourcePath = fullPathSync(parsed.move[0]);
|
|
100
|
+
let targetPath = fullPathSync(parsed.move[1]);
|
|
101
|
+
|
|
102
|
+
// 如果存在
|
|
103
|
+
moveSync(sourcePath, targetPath);
|
|
104
|
+
log(`> move ${sourcePath.replace(process.cwd(), '.')} ➔ ${targetPath.replace(process.cwd(), '.')}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 网络信息
|
|
108
|
+
else if (Array.isArray(parsed.network)) {
|
|
109
|
+
log(JSON.stringify(network(), null, 4));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// GET请求
|
|
113
|
+
else if (Array.isArray(parsed.get)) {
|
|
114
|
+
get(parsed.get[0]).then(data => {
|
|
115
|
+
log(data);
|
|
116
|
+
}).catch(e => {
|
|
117
|
+
error(e);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// PSOT请求
|
|
122
|
+
else if (Array.isArray(parsed.post)) {
|
|
123
|
+
post(parsed.post[0]).then(data => {
|
|
124
|
+
log(data);
|
|
125
|
+
}).catch(e => {
|
|
126
|
+
error(e);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 查看文件
|
|
131
|
+
else if (Array.isArray(parsed.cat)) {
|
|
132
|
+
try {
|
|
133
|
+
let filepath = fullPathSync(parsed.cat[0])
|
|
134
|
+
|
|
135
|
+
log(fs.readFileSync(filepath, {
|
|
136
|
+
encoding: "utf8"
|
|
137
|
+
}));
|
|
138
|
+
} catch (e) {
|
|
139
|
+
error(e);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 运行多命令
|
|
144
|
+
else if (Array.isArray(parsed.run)) {
|
|
145
|
+
for (let index = 0; index < parsed.run.length; index++) {
|
|
146
|
+
const child = exec(parsed.run[index]);
|
|
147
|
+
|
|
148
|
+
// 监听子线程的stdout
|
|
149
|
+
child.stdout.on('data', (data) => {
|
|
150
|
+
console.log(`[${index + 1}] log:${data}`);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// 监听子线程的stderr
|
|
154
|
+
child.stderr.on('data', (data) => {
|
|
155
|
+
console.error(`[${index + 1}] error:${data}`);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// 子线程结束处理
|
|
159
|
+
child.on('close', (code) => {
|
|
160
|
+
console.log(`[${index + 1}] 子线程结束,退出码 ${code}`);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// 子线程出错处理
|
|
164
|
+
child.on('error', (error) => {
|
|
165
|
+
console.error(`[${index + 1}] 子线程错误: ${error.message}`);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 服务器
|
|
171
|
+
else if (Array.isArray(parsed.server)) {
|
|
172
|
+
server({
|
|
173
|
+
port: parsed.server[0],
|
|
174
|
+
basePath: parsed.server[1]
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 否则就是帮助
|
|
179
|
+
else {
|
|
180
|
+
let helpParsed = Array.isArray(parsed.help) ? parsed.help : parsed.__terminal__;
|
|
181
|
+
|
|
182
|
+
// 打印具体的配置提示
|
|
183
|
+
if (helpParsed && helpParsed.length > 0) {
|
|
184
|
+
let help0 = helpParsed[0];
|
|
185
|
+
|
|
186
|
+
// 缩写转全拼
|
|
187
|
+
if (help0.length == 1) {
|
|
188
|
+
help0 = shortHands["-" + help0];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (help0) {
|
|
192
|
+
help0 = help0.replace(/^--/, "");
|
|
193
|
+
|
|
194
|
+
// 根据需要帮助的命令获取对应的信息
|
|
195
|
+
const help0Option = options[help0];
|
|
196
|
+
if (help0Option) {
|
|
197
|
+
log(`
|
|
198
|
+
` + help0Option.demo + ` ` + help0Option.info + `
|
|
199
|
+
`);
|
|
200
|
+
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
log(help);
|
|
208
|
+
}
|
|
209
209
|
})();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 获取节点样式
|
|
3
|
-
*/
|
|
4
|
-
export interface getStyleType {
|
|
5
|
-
(el: HTMLElement, name: string): string
|
|
6
|
-
(el: HTMLElement): {
|
|
7
|
-
[key: string]: string
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 获取节点样式
|
|
3
|
+
*/
|
|
4
|
+
export interface getStyleType {
|
|
5
|
+
(el: HTMLElement, name: string): string
|
|
6
|
+
(el: HTMLElement): {
|
|
7
|
+
[key: string]: string
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
11
|
export let getStyle: getStyleType
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export function getStyle(el, name) {
|
|
2
|
-
|
|
3
|
-
// 获取结点的全部样式
|
|
4
|
-
var allStyle = document.defaultView && document.defaultView.getComputedStyle ?
|
|
5
|
-
document.defaultView.getComputedStyle(el, null) :
|
|
6
|
-
el.currentStyle;
|
|
7
|
-
|
|
8
|
-
// 如果没有指定属性名称,返回全部样式
|
|
9
|
-
return typeof name === 'string' ?
|
|
10
|
-
allStyle.getPropertyValue(name) :
|
|
11
|
-
allStyle;
|
|
12
|
-
|
|
1
|
+
export function getStyle(el, name) {
|
|
2
|
+
|
|
3
|
+
// 获取结点的全部样式
|
|
4
|
+
var allStyle = document.defaultView && document.defaultView.getComputedStyle ?
|
|
5
|
+
document.defaultView.getComputedStyle(el, null) :
|
|
6
|
+
el.currentStyle;
|
|
7
|
+
|
|
8
|
+
// 如果没有指定属性名称,返回全部样式
|
|
9
|
+
return typeof name === 'string' ?
|
|
10
|
+
allStyle.getPropertyValue(name) :
|
|
11
|
+
allStyle;
|
|
12
|
+
|
|
13
13
|
};
|
package/browserjs/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getStyleType } from "./getStyle"
|
|
2
|
-
import { setStyleType } from "./setStyle"
|
|
3
|
-
import { onReadyType } from "./onReady"
|
|
4
|
-
|
|
5
|
-
export default class Corejs {
|
|
6
|
-
static getStyle: getStyleType
|
|
7
|
-
static setStyle: setStyleType
|
|
8
|
-
static onReady: onReadyType
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export let getStyle: getStyleType
|
|
12
|
-
export let setStyle: setStyleType
|
|
1
|
+
import { getStyleType } from "./getStyle"
|
|
2
|
+
import { setStyleType } from "./setStyle"
|
|
3
|
+
import { onReadyType } from "./onReady"
|
|
4
|
+
|
|
5
|
+
export default class Corejs {
|
|
6
|
+
static getStyle: getStyleType
|
|
7
|
+
static setStyle: setStyleType
|
|
8
|
+
static onReady: onReadyType
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export let getStyle: getStyleType
|
|
12
|
+
export let setStyle: setStyleType
|
|
13
13
|
export let onReady: onReadyType
|
package/browserjs/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getStyle } from "./getStyle/index.js";
|
|
2
|
-
import { setStyle } from "./setStyle/index.js";
|
|
3
|
-
import { onReady } from "./onReady/index.js";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
getStyle: getStyle,
|
|
7
|
-
setStyle: setStyle,
|
|
8
|
-
onReady: onReady
|
|
1
|
+
import { getStyle } from "./getStyle/index.js";
|
|
2
|
+
import { setStyle } from "./setStyle/index.js";
|
|
3
|
+
import { onReady } from "./onReady/index.js";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
getStyle: getStyle,
|
|
7
|
+
setStyle: setStyle,
|
|
8
|
+
onReady: onReady
|
|
9
9
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 等待DOM加载完毕执行
|
|
3
|
-
*/
|
|
4
|
-
export interface onReadyType {
|
|
5
|
-
(callback: Function): void
|
|
6
|
-
}
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 等待DOM加载完毕执行
|
|
3
|
+
*/
|
|
4
|
+
export interface onReadyType {
|
|
5
|
+
(callback: Function): void
|
|
6
|
+
}
|
|
7
|
+
|
|
8
8
|
export let onReady: onReadyType
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function onReady(callback) {
|
|
2
|
-
var readyState = document.readyState;
|
|
3
|
-
if (readyState === 'interactive' || readyState === 'complete') {
|
|
4
|
-
callback();
|
|
5
|
-
} else {
|
|
6
|
-
window.addEventListener("DOMContentLoaded", callback);
|
|
7
|
-
}
|
|
1
|
+
export function onReady(callback) {
|
|
2
|
+
var readyState = document.readyState;
|
|
3
|
+
if (readyState === 'interactive' || readyState === 'complete') {
|
|
4
|
+
callback();
|
|
5
|
+
} else {
|
|
6
|
+
window.addEventListener("DOMContentLoaded", callback);
|
|
7
|
+
}
|
|
8
8
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 设置节点样式
|
|
3
|
-
*/
|
|
4
|
-
export interface setStyleType {
|
|
5
|
-
(el: HTMLElement, styles: {
|
|
6
|
-
[key: string]: string | number
|
|
7
|
-
}): void
|
|
8
|
-
}
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 设置节点样式
|
|
3
|
+
*/
|
|
4
|
+
export interface setStyleType {
|
|
5
|
+
(el: HTMLElement, styles: {
|
|
6
|
+
[key: string]: string | number
|
|
7
|
+
}): void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
10
|
export let setStyle: setStyleType
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function setStyle(el, styles) {
|
|
2
|
-
for (var key in styles) {
|
|
3
|
-
el.style[key] = styles[key];
|
|
4
|
-
}
|
|
1
|
+
export function setStyle(el, styles) {
|
|
2
|
+
for (var key in styles) {
|
|
3
|
+
el.style[key] = styles[key];
|
|
4
|
+
}
|
|
5
5
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
interface animationFun {
|
|
2
|
-
(deep: number): void
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 轮询动画,返回一个函数,调用该函数,可以提前结束动画
|
|
7
|
-
*/
|
|
8
|
-
export interface animationType {
|
|
9
|
-
(doback: animationFun, duration?: number, callback?: animationFun): Function
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
interface animationFun {
|
|
2
|
+
(deep: number): void
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 轮询动画,返回一个函数,调用该函数,可以提前结束动画
|
|
7
|
+
*/
|
|
8
|
+
export interface animationType {
|
|
9
|
+
(doback: animationFun, duration?: number, callback?: animationFun): Function
|
|
10
|
+
}
|
|
11
|
+
|
|
12
12
|
export let animation: animationType
|