@e-mc/document 0.8.19 → 0.8.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.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2024 An Pham
1
+ Copyright 2023 An Pham
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/index.d.ts
12
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/index.d.ts
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, ViewEngine } from "./squared";
@@ -85,14 +85,14 @@ interface DocumentConstructor extends ModuleConstructor {
85
85
 
86
86
  ## References
87
87
 
88
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/squared.d.ts
89
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/asset.d.ts
90
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/core.d.ts
91
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/document.d.ts
92
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/filemanager.d.ts
93
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/logger.d.ts
94
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/settings.d.ts
95
- - https://www.unpkg.com/@e-mc/types@0.8.19/lib/watch.d.ts
88
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/squared.d.ts
89
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/asset.d.ts
90
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/core.d.ts
91
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/document.d.ts
92
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/filemanager.d.ts
93
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/logger.d.ts
94
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/settings.d.ts
95
+ - https://www.unpkg.com/@e-mc/types@0.8.21/lib/watch.d.ts
96
96
 
97
97
  ## LICENSE
98
98
 
package/index.js CHANGED
@@ -5,12 +5,12 @@ const fs = require("fs");
5
5
  const pm = require("picomatch");
6
6
  const yaml = require("js-yaml");
7
7
  const chalk = require("chalk");
8
- const types_1 = require("@e-mc/types");
9
8
  const core_1 = require("@e-mc/core");
10
9
  const db_1 = require("@e-mc/db");
11
- const util_1 = require("@e-mc/document/util");
10
+ const types_1 = require("@e-mc/types");
12
11
  const transform_1 = require("@e-mc/document/transform");
13
12
  const parse_1 = require("@e-mc/document/parse");
13
+ const util_1 = require("@e-mc/document/util");
14
14
  const PLATFORM_WIN32 = process.platform === 'win32';
15
15
  const CACHE_PACKAGE = {};
16
16
  const CACHE_REQUIRE = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/document",
3
- "version": "0.8.19",
3
+ "version": "0.8.21",
4
4
  "description": "Document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,10 +20,12 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.8.19",
24
- "@e-mc/db": "0.8.19",
25
- "@e-mc/types": "0.8.19",
23
+ "@e-mc/core": "0.8.21",
24
+ "@e-mc/db": "0.8.21",
25
+ "@e-mc/types": "0.8.21",
26
26
  "chalk": "4.1.2",
27
+ "domhandler": "^5.0.3",
28
+ "domutils": "^3.1.0",
27
29
  "htmlparser2": "^9.1.0",
28
30
  "js-yaml": "^4.1.0",
29
31
  "picomatch": "^3.0.1"
package/util.js CHANGED
@@ -27,13 +27,20 @@ function loadPlugins(name, plugins = []) {
27
27
  plugins = name;
28
28
  }
29
29
  const result = [];
30
- for (const plugin of plugins.map(item => (0, types_1.isString)(item) ? [item] : Array.isArray(item) && (0, types_1.isString)(item[0]) ? item : null)) {
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)) {
31
31
  if (plugin) {
32
- const [pkg, options] = plugin;
33
- result.push(require(pkg)(options));
32
+ let method = require(plugin[0]), options = plugin[1];
33
+ if ((0, types_1.isPlainObject)(method)) {
34
+ const attr = options === null || options === void 0 ? void 0 : options.__default__;
35
+ if ((0, types_1.isString)(attr)) {
36
+ method = method[attr];
37
+ options = { ...options };
38
+ delete options.__default__;
39
+ }
40
+ }
41
+ result.push(method(options));
34
42
  }
35
43
  }
36
- return result;
37
44
  }
38
45
  exports.loadPlugins = loadPlugins;
39
46
  function replaceAll(source, valueOf, opening = '{{', closing = '}}') {