@e-mc/document 0.6.15 → 0.6.17
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/index.js +2 -2
- package/package.json +4 -4
- package/util.js +18 -5
package/index.js
CHANGED
|
@@ -1138,10 +1138,10 @@ class Document extends core_1.Client {
|
|
|
1138
1138
|
context = this;
|
|
1139
1139
|
pkg = undefined;
|
|
1140
1140
|
}
|
|
1141
|
-
if (transformer && typeof transformer
|
|
1141
|
+
if ((0, types_1.isObject)(transformer) && typeof transformer.default === 'function') {
|
|
1142
1142
|
transformer = transformer.default;
|
|
1143
1143
|
}
|
|
1144
|
-
if (typeof transformer !== 'function') {
|
|
1144
|
+
else if (typeof transformer !== 'function') {
|
|
1145
1145
|
throw (0, types_1.errorMessage)(plugin, pkg || name, 'Invalid function');
|
|
1146
1146
|
}
|
|
1147
1147
|
if (pkg) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.17",
|
|
4
4
|
"description": "Document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.6.
|
|
24
|
-
"@e-mc/db": "0.6.
|
|
25
|
-
"@e-mc/types": "0.6.
|
|
23
|
+
"@e-mc/core": "0.6.17",
|
|
24
|
+
"@e-mc/db": "0.6.17",
|
|
25
|
+
"@e-mc/types": "0.6.17",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
27
|
"domhandler": "^5.0.3",
|
|
28
28
|
"domutils": "^3.1.0",
|
package/util.js
CHANGED
|
@@ -23,13 +23,26 @@ exports.IMPORTS = {
|
|
|
23
23
|
"uglify-js": "@pi-r/uglify-js"
|
|
24
24
|
};
|
|
25
25
|
function loadPlugins(name, plugins = []) {
|
|
26
|
-
if (Array.isArray(name)) {
|
|
27
|
-
plugins = name;
|
|
28
|
-
}
|
|
29
26
|
const result = [];
|
|
30
|
-
|
|
27
|
+
const items = (Array.isArray(name) ? name : plugins).map(value => {
|
|
28
|
+
let pkg, options;
|
|
29
|
+
if ((0, types_1.isString)(value)) {
|
|
30
|
+
pkg = value;
|
|
31
|
+
}
|
|
32
|
+
else if (Array.isArray(value)) {
|
|
33
|
+
[pkg, options] = value;
|
|
34
|
+
if (!(0, types_1.isString)(pkg)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (typeof value === 'function') {
|
|
39
|
+
return [value];
|
|
40
|
+
}
|
|
41
|
+
return pkg ? [pkg, options] : null;
|
|
42
|
+
});
|
|
43
|
+
for (const plugin of items) {
|
|
31
44
|
if (plugin) {
|
|
32
|
-
let method = require(plugin[0]), options = plugin[1];
|
|
45
|
+
let method = typeof plugin[0] === 'function' ? plugin[0] : require(plugin[0]), options = plugin[1];
|
|
33
46
|
if ((0, types_1.isPlainObject)(method)) {
|
|
34
47
|
const attr = options === null || options === void 0 ? void 0 : options.__default__;
|
|
35
48
|
if ((0, types_1.isString)(attr)) {
|