@e-mc/document 0.7.19 → 0.7.21

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.
Files changed (3) hide show
  1. package/index.js +2 -2
  2. package/package.json +4 -4
  3. package/util.js +18 -5
package/index.js CHANGED
@@ -1151,10 +1151,10 @@ class Document extends core_1.Client {
1151
1151
  context = this;
1152
1152
  pkg = undefined;
1153
1153
  }
1154
- if (transformer && typeof transformer !== 'function') {
1154
+ if ((0, types_1.isObject)(transformer) && typeof transformer.default === 'function') {
1155
1155
  transformer = transformer.default;
1156
1156
  }
1157
- if (typeof transformer !== 'function') {
1157
+ else if (typeof transformer !== 'function') {
1158
1158
  throw (0, types_1.errorMessage)(plugin, pkg || name, 'Invalid function');
1159
1159
  }
1160
1160
  if (pkg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/document",
3
- "version": "0.7.19",
3
+ "version": "0.7.21",
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.7.19",
24
- "@e-mc/db": "0.7.19",
25
- "@e-mc/types": "0.7.19",
23
+ "@e-mc/core": "0.7.21",
24
+ "@e-mc/db": "0.7.21",
25
+ "@e-mc/types": "0.7.21",
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
- for (const plugin of plugins.map(item => (0, types_1.isString)(item) ? [item, undefined] : Array.isArray(item) && (0, types_1.isString)(item[0]) ? item : null)) {
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)) {