@e-mc/document 0.11.3 → 0.11.4

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.11.3/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.4/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, ViewEngine } from "./squared";
@@ -185,14 +185,14 @@ NOTE: **@e-mc/document** is an abstract base class and cannot be instantiated. *
185
185
 
186
186
  ## References
187
187
 
188
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/squared.d.ts
189
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/asset.d.ts
190
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/core.d.ts
191
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/document.d.ts
192
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/filemanager.d.ts
193
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/logger.d.ts
194
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/settings.d.ts
195
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/watch.d.ts
188
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/squared.d.ts
189
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/asset.d.ts
190
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/core.d.ts
191
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/document.d.ts
192
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/filemanager.d.ts
193
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/logger.d.ts
194
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/settings.d.ts
195
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/watch.d.ts
196
196
 
197
197
  ## LICENSE
198
198
 
package/index.js CHANGED
@@ -1388,10 +1388,10 @@ class Document extends core_1.Client {
1388
1388
  transformer = context;
1389
1389
  context = this;
1390
1390
  }
1391
- if ((0, types_1.isObject)(transformer) && 'default' in transformer) {
1391
+ if ((0, types_1.isObject)(transformer) && typeof transformer.default === 'function') {
1392
1392
  transformer = transformer.default;
1393
1393
  }
1394
- if (typeof transformer !== 'function') {
1394
+ else if (typeof transformer !== 'function') {
1395
1395
  throw (0, types_1.errorMessage)(plugin, pkg || name, "Invalid function");
1396
1396
  }
1397
1397
  if (pkg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/document",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
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.11.3",
24
- "@e-mc/db": "0.11.3",
25
- "@e-mc/types": "0.11.3",
23
+ "@e-mc/core": "0.11.4",
24
+ "@e-mc/db": "0.11.4",
25
+ "@e-mc/types": "0.11.4",
26
26
  "chalk": "4.1.2",
27
27
  "domhandler": "^5.0.3",
28
28
  "domutils": "^3.2.1",
package/util.js CHANGED
@@ -13,18 +13,31 @@ exports.getHashData = getHashData;
13
13
  exports.hasValue = hasValue;
14
14
  exports.getModuleName = getModuleName;
15
15
  exports.removeInternalProperties = removeInternalProperties;
16
- const path = require("node:path");
16
+ const path = require("path");
17
17
  const types_1 = require("@e-mc/types");
18
18
  Object.defineProperty(exports, "IMPORTS", { enumerable: true, get: function () { return types_1.IMPORT_MAP; } });
19
19
  Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return types_1.isObject; } });
20
20
  function loadPlugins(plugins) {
21
- if (!Array.isArray(plugins)) {
22
- plugins = [plugins];
23
- }
24
21
  const result = [];
25
- 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)) {
22
+ const items = (Array.isArray(plugins) ? plugins : [plugins]).map(value => {
23
+ let name, options;
24
+ if ((0, types_1.isString)(value)) {
25
+ name = value;
26
+ }
27
+ else if (Array.isArray(value)) {
28
+ [name, options] = value;
29
+ if (!(0, types_1.isString)(name)) {
30
+ return null;
31
+ }
32
+ }
33
+ else if (typeof value === 'function') {
34
+ return [value];
35
+ }
36
+ return name ? [name, options] : null;
37
+ });
38
+ for (const plugin of items) {
26
39
  if (plugin) {
27
- let method = require(plugin[0]), options = plugin[1];
40
+ let method = typeof plugin[0] === 'function' ? plugin[0] : require(plugin[0]), options = plugin[1];
28
41
  if ((0, types_1.isPlainObject)(method)) {
29
42
  const attr = options?.__default__;
30
43
  if ((0, types_1.isString)(attr)) {
@@ -207,7 +220,7 @@ function getModuleName(err) {
207
220
  function removeInternalProperties(value, retaining) {
208
221
  if ((0, types_1.isObject)(value)) {
209
222
  for (const prop in value) {
210
- if (Object.hasOwn(value, prop)) {
223
+ if (Object.prototype.hasOwnProperty.call(value, prop)) {
211
224
  if (retaining) {
212
225
  if (!retaining.includes(prop)) {
213
226
  delete value[prop];