@e-mc/document 0.5.17 → 0.5.19
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 +5 -5
- package/package.json +4 -4
- package/util.js +18 -5
package/index.js
CHANGED
|
@@ -1153,11 +1153,11 @@ class Document extends core_1.Client {
|
|
|
1153
1153
|
transformer = context;
|
|
1154
1154
|
context = this;
|
|
1155
1155
|
}
|
|
1156
|
-
if (typeof transformer
|
|
1157
|
-
transformer
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1156
|
+
if ((0, types_1.isObject)(transformer) && typeof transformer.default === 'function') {
|
|
1157
|
+
transformer = transformer.default;
|
|
1158
|
+
}
|
|
1159
|
+
else if (typeof transformer !== 'function') {
|
|
1160
|
+
throw (0, types_1.errorMessage)(plugin, pkg || name, 'Invalid function');
|
|
1161
1161
|
}
|
|
1162
1162
|
if (pkg) {
|
|
1163
1163
|
CACHE_PACKAGE[plugin + username] = transformer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.19",
|
|
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.5.
|
|
24
|
-
"@e-mc/db": "0.5.
|
|
25
|
-
"@e-mc/types": "0.5.
|
|
23
|
+
"@e-mc/core": "0.5.19",
|
|
24
|
+
"@e-mc/db": "0.5.19",
|
|
25
|
+
"@e-mc/types": "0.5.19",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
27
|
"htmlparser2": "^9.1.0",
|
|
28
28
|
"js-yaml": "^4.1.0",
|
package/util.js
CHANGED
|
@@ -5,13 +5,26 @@ const path = require("path");
|
|
|
5
5
|
const types_1 = require("@e-mc/types");
|
|
6
6
|
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return types_1.isObject; } });
|
|
7
7
|
function loadPlugins(name, plugins = []) {
|
|
8
|
-
if (Array.isArray(name)) {
|
|
9
|
-
plugins = name;
|
|
10
|
-
}
|
|
11
8
|
const result = [];
|
|
12
|
-
|
|
9
|
+
const items = (Array.isArray(name) ? name : plugins).map(value => {
|
|
10
|
+
let pkg, options;
|
|
11
|
+
if ((0, types_1.isString)(value)) {
|
|
12
|
+
pkg = value;
|
|
13
|
+
}
|
|
14
|
+
else if (Array.isArray(value)) {
|
|
15
|
+
[pkg, options] = value;
|
|
16
|
+
if (!(0, types_1.isString)(pkg)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (typeof value === 'function') {
|
|
21
|
+
return [value];
|
|
22
|
+
}
|
|
23
|
+
return pkg ? [pkg, options] : null;
|
|
24
|
+
});
|
|
25
|
+
for (const plugin of items) {
|
|
13
26
|
if (plugin) {
|
|
14
|
-
let method = require(plugin[0]), options = plugin[1];
|
|
27
|
+
let method = typeof plugin[0] === 'function' ? plugin[0] : require(plugin[0]), options = plugin[1];
|
|
15
28
|
if ((0, types_1.isPlainObject)(method)) {
|
|
16
29
|
const attr = options === null || options === void 0 ? void 0 : options.__default__;
|
|
17
30
|
if ((0, types_1.isString)(attr)) {
|