hw-weapp-compiler 1.0.6 → 1.0.7
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.
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
const { createPool, POOL_SIZE } = require('./loadModule');
|
|
2
1
|
const htmlparser2 = require('htmlparser2');
|
|
3
2
|
const path = require('path');
|
|
4
3
|
const fse = require('fs-extra');
|
|
5
4
|
const { ASSET_EXT_PATTERN, PATTERNS, SRC_DIR } = require('../config/constants');
|
|
6
5
|
|
|
7
|
-
const resolvePool = createPool(POOL_SIZE);
|
|
8
|
-
|
|
9
6
|
function getWxmlAssets(filePath, content) {
|
|
10
7
|
const resolvePath = (attr, dir) => {
|
|
11
|
-
return
|
|
12
|
-
() =>
|
|
13
|
-
new Promise((resolve) => {
|
|
14
|
-
this.resolve(SRC_DIR, attr, async (err, result) => {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
this.resolve(SRC_DIR, attr, async (err, result) => {
|
|
15
10
|
let res = result;
|
|
16
11
|
if (err) {
|
|
17
12
|
if (await fse.pathExists(path.resolve(dir, attr))) {
|
|
@@ -25,8 +20,7 @@ function getWxmlAssets(filePath, content) {
|
|
|
25
20
|
resolve(res);
|
|
26
21
|
}
|
|
27
22
|
});
|
|
28
|
-
|
|
29
|
-
);
|
|
23
|
+
});
|
|
30
24
|
};
|
|
31
25
|
return new Promise((resolve, reject) => {
|
|
32
26
|
let allAttrs = [];
|
|
@@ -1,55 +1,16 @@
|
|
|
1
|
-
const POOL_SIZE = 16;
|
|
2
|
-
|
|
3
|
-
function createPool(limit) {
|
|
4
|
-
let active = 0;
|
|
5
|
-
const pending = [];
|
|
6
|
-
const next = () => {
|
|
7
|
-
while (pending.length && active < limit) {
|
|
8
|
-
const { fn, resolve, reject } = pending.shift();
|
|
9
|
-
active++;
|
|
10
|
-
Promise.resolve()
|
|
11
|
-
.then(fn)
|
|
12
|
-
.then(
|
|
13
|
-
(v) => {
|
|
14
|
-
active--;
|
|
15
|
-
resolve(v);
|
|
16
|
-
next();
|
|
17
|
-
},
|
|
18
|
-
(e) => {
|
|
19
|
-
active--;
|
|
20
|
-
reject(e);
|
|
21
|
-
next();
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
return (fn) =>
|
|
27
|
-
new Promise((resolve, reject) => {
|
|
28
|
-
pending.push({ fn, resolve, reject });
|
|
29
|
-
next();
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const pool = createPool(POOL_SIZE);
|
|
34
|
-
|
|
35
1
|
function loadModule(file) {
|
|
36
|
-
return
|
|
37
|
-
()
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
}),
|
|
49
|
-
);
|
|
2
|
+
return new Promise((resolve) => {
|
|
3
|
+
this.addDependency(file);
|
|
4
|
+
this.loadModule(file, (err, src) => {
|
|
5
|
+
if (err) {
|
|
6
|
+
this.emitError(err);
|
|
7
|
+
resolve(null);
|
|
8
|
+
} else {
|
|
9
|
+
resolve(src);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
});
|
|
50
13
|
}
|
|
51
14
|
module.exports = {
|
|
52
15
|
loadModule,
|
|
53
|
-
createPool,
|
|
54
|
-
POOL_SIZE,
|
|
55
16
|
};
|