@e-mc/document 0.9.16 → 0.9.18

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.9.16/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.18/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, ViewEngine } from "./squared";
@@ -183,14 +183,14 @@ NOTE: **@e-mc/document** is an abstract base class and cannot be instantiated. *
183
183
 
184
184
  ## References
185
185
 
186
- - https://www.unpkg.com/@e-mc/types@0.9.16/lib/squared.d.ts
187
- - https://www.unpkg.com/@e-mc/types@0.9.16/lib/asset.d.ts
188
- - https://www.unpkg.com/@e-mc/types@0.9.16/lib/core.d.ts
189
- - https://www.unpkg.com/@e-mc/types@0.9.16/lib/document.d.ts
190
- - https://www.unpkg.com/@e-mc/types@0.9.16/lib/filemanager.d.ts
191
- - https://www.unpkg.com/@e-mc/types@0.9.16/lib/logger.d.ts
192
- - https://www.unpkg.com/@e-mc/types@0.9.16/lib/settings.d.ts
193
- - https://www.unpkg.com/@e-mc/types@0.9.16/lib/watch.d.ts
186
+ - https://www.unpkg.com/@e-mc/types@0.9.18/lib/squared.d.ts
187
+ - https://www.unpkg.com/@e-mc/types@0.9.18/lib/asset.d.ts
188
+ - https://www.unpkg.com/@e-mc/types@0.9.18/lib/core.d.ts
189
+ - https://www.unpkg.com/@e-mc/types@0.9.18/lib/document.d.ts
190
+ - https://www.unpkg.com/@e-mc/types@0.9.18/lib/filemanager.d.ts
191
+ - https://www.unpkg.com/@e-mc/types@0.9.18/lib/logger.d.ts
192
+ - https://www.unpkg.com/@e-mc/types@0.9.18/lib/settings.d.ts
193
+ - https://www.unpkg.com/@e-mc/types@0.9.18/lib/watch.d.ts
194
194
 
195
195
  ## LICENSE
196
196
 
package/index.js CHANGED
@@ -1215,11 +1215,11 @@ class Document extends core_1.Client {
1215
1215
  transformer = context;
1216
1216
  context = this;
1217
1217
  }
1218
- if (typeof transformer !== 'function') {
1219
- transformer &&= transformer.default;
1220
- if (typeof transformer !== 'function') {
1221
- throw (0, types_1.errorMessage)(plugin, pkg || name, 'Invalid function');
1222
- }
1218
+ if ((0, types_1.isObject)(transformer) && typeof transformer.default === 'function') {
1219
+ transformer = transformer.default;
1220
+ }
1221
+ else if (typeof transformer !== 'function') {
1222
+ throw (0, types_1.errorMessage)(plugin, pkg || name, 'Invalid function');
1223
1223
  }
1224
1224
  if (pkg) {
1225
1225
  CACHE_PACKAGE[plugin + username] = transformer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/document",
3
- "version": "0.9.16",
3
+ "version": "0.9.18",
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": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.9.16",
24
- "@e-mc/db": "0.9.16",
25
- "@e-mc/types": "0.9.16",
23
+ "@e-mc/core": "0.9.18",
24
+ "@e-mc/db": "0.9.18",
25
+ "@e-mc/types": "0.9.18",
26
26
  "chalk": "4.1.2",
27
27
  "domhandler": "^5.0.3",
28
28
  "domutils": "^3.1.0",
package/util.js CHANGED
@@ -22,13 +22,26 @@ exports.IMPORTS = {
22
22
  "uglify-js": "@pi-r/uglify-js"
23
23
  };
24
24
  function loadPlugins(name, plugins = []) {
25
- if (Array.isArray(name)) {
26
- plugins = name;
27
- }
28
25
  const result = [];
29
- 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)) {
26
+ const items = (Array.isArray(name) ? name : plugins).map(value => {
27
+ let pkg, options;
28
+ if ((0, types_1.isString)(value)) {
29
+ pkg = value;
30
+ }
31
+ else if (Array.isArray(value)) {
32
+ [pkg, options] = value;
33
+ if (!(0, types_1.isString)(pkg)) {
34
+ return null;
35
+ }
36
+ }
37
+ else if (typeof value === 'function') {
38
+ return [value];
39
+ }
40
+ return pkg ? [pkg, options] : null;
41
+ });
42
+ for (const plugin of items) {
30
43
  if (plugin) {
31
- let method = require(plugin[0]), options = plugin[1];
44
+ let method = typeof plugin[0] === 'function' ? plugin[0] : require(plugin[0]), options = plugin[1];
32
45
  if ((0, types_1.isPlainObject)(method)) {
33
46
  const attr = options?.__default__;
34
47
  if ((0, types_1.isString)(attr)) {