@e-mc/document 0.9.20 → 0.9.22

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/README.md +10 -10
  2. package/index.js +9 -3
  3. package/package.json +4 -4
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.20/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.22/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, ViewEngine } from "./squared";
@@ -183,15 +183,15 @@ 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.20/lib/squared.d.ts
187
- - https://www.unpkg.com/@e-mc/types@0.9.20/lib/asset.d.ts
188
- - https://www.unpkg.com/@e-mc/types@0.9.20/lib/core.d.ts
189
- - https://www.unpkg.com/@e-mc/types@0.9.20/lib/document.d.ts
190
- - https://www.unpkg.com/@e-mc/types@0.9.20/lib/filemanager.d.ts
191
- - https://www.unpkg.com/@e-mc/types@0.9.20/lib/logger.d.ts
192
- - https://www.unpkg.com/@e-mc/types@0.9.20/lib/settings.d.ts
193
- - https://www.unpkg.com/@e-mc/types@0.9.20/lib/watch.d.ts
186
+ - https://www.unpkg.com/@e-mc/types@0.9.22/lib/squared.d.ts
187
+ - https://www.unpkg.com/@e-mc/types@0.9.22/lib/asset.d.ts
188
+ - https://www.unpkg.com/@e-mc/types@0.9.22/lib/core.d.ts
189
+ - https://www.unpkg.com/@e-mc/types@0.9.22/lib/document.d.ts
190
+ - https://www.unpkg.com/@e-mc/types@0.9.22/lib/filemanager.d.ts
191
+ - https://www.unpkg.com/@e-mc/types@0.9.22/lib/logger.d.ts
192
+ - https://www.unpkg.com/@e-mc/types@0.9.22/lib/settings.d.ts
193
+ - https://www.unpkg.com/@e-mc/types@0.9.22/lib/watch.d.ts
194
194
 
195
195
  ## LICENSE
196
196
 
197
- BSD 3-Clause
197
+ MIT
package/index.js CHANGED
@@ -17,6 +17,7 @@ const CACHE_ETAG = {};
17
17
  const CACHE_CODE = {};
18
18
  const CACHE_HASH = {};
19
19
  const CACHE_TEMPLATE = {};
20
+ const CACHE_VIEWENGINE = new Map();
20
21
  const CACHE_EXTERNAL = {};
21
22
  const CACHE_PICOMATCH = new Map();
22
23
  let CACHE_TOTAL = 0;
@@ -106,6 +107,7 @@ class Document extends core_1.Client {
106
107
  delete cache[name];
107
108
  }
108
109
  }
110
+ CACHE_VIEWENGINE.clear();
109
111
  CACHE_PICOMATCH.clear();
110
112
  CACHE_TOTAL = 0;
111
113
  }
@@ -926,8 +928,12 @@ class Document extends core_1.Client {
926
928
  target = this.settings.view_engine?.[viewEngine];
927
929
  const userConfig = this.getUserSettings()?.view_engine?.[viewEngine];
928
930
  if ((0, types_1.isPlainObject)(userConfig)) {
929
- if ((0, types_1.isPlainObject)(target)) {
930
- (0, types_1.cloneObject)(userConfig, { target, deep: true, preserve: true });
931
+ if (CACHE_VIEWENGINE.has(userConfig)) {
932
+ target = CACHE_VIEWENGINE.get(userConfig);
933
+ }
934
+ else if ((0, types_1.isPlainObject)(target)) {
935
+ target = (0, types_1.cloneObject)(userConfig, { target: { ...target }, deep: true, preserve: true });
936
+ CACHE_VIEWENGINE.set(userConfig, target);
931
937
  }
932
938
  else {
933
939
  target = userConfig;
@@ -938,7 +944,7 @@ class Document extends core_1.Client {
938
944
  else {
939
945
  target = viewEngine;
940
946
  }
941
- if (!((0, types_1.isPlainObject)(target) && target.name)) {
947
+ if (!((0, types_1.isPlainObject)(target) && (0, types_1.isString)(target.name))) {
942
948
  this.abort('view_engine');
943
949
  const from = typeof viewEngine === 'string' ? viewEngine : this.moduleName;
944
950
  this.writeFail(["Unable to load configuration", from], (0, types_1.errorMessage)('view-engine', from, "Unknown"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/document",
3
- "version": "0.9.20",
3
+ "version": "0.9.22",
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.9.20",
24
- "@e-mc/db": "0.9.20",
25
- "@e-mc/types": "0.9.20",
23
+ "@e-mc/core": "0.9.22",
24
+ "@e-mc/db": "0.9.22",
25
+ "@e-mc/types": "0.9.22",
26
26
  "chalk": "4.1.2",
27
27
  "domhandler": "^5.0.3",
28
28
  "domutils": "^3.1.0",