@e-mc/document 0.5.20 → 0.5.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 (2) hide show
  1. package/index.js +9 -3
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -35,6 +35,7 @@ const CACHE_ETAG = {};
35
35
  const CACHE_CODE = {};
36
36
  const CACHE_HASH = {};
37
37
  const CACHE_TEMPLATE = {};
38
+ const CACHE_VIEWENGINE = new Map();
38
39
  const CACHE_EXTERNAL = {};
39
40
  const CACHE_PICOMATCH = new Map();
40
41
  let CACHE_TOTAL = 0;
@@ -82,6 +83,7 @@ class Document extends core_1.Client {
82
83
  delete cache[name];
83
84
  }
84
85
  }
86
+ CACHE_VIEWENGINE.clear();
85
87
  CACHE_PICOMATCH.clear();
86
88
  CACHE_TOTAL = 0;
87
89
  }
@@ -831,8 +833,12 @@ class Document extends core_1.Client {
831
833
  const username = (_b = this.host) === null || _b === void 0 ? void 0 : _b.username;
832
834
  const userConfig = username && ((_e = (_d = (_c = this.settings.users) === null || _c === void 0 ? void 0 : _c[username]) === null || _d === void 0 ? void 0 : _d.view_engine) === null || _e === void 0 ? void 0 : _e[viewEngine]);
833
835
  if ((0, types_1.isPlainObject)(userConfig)) {
834
- if ((0, types_1.isPlainObject)(target)) {
835
- (0, types_1.cloneObject)(userConfig, { target, deep: true, preserve: true });
836
+ if (CACHE_VIEWENGINE.has(userConfig)) {
837
+ target = CACHE_VIEWENGINE.get(userConfig);
838
+ }
839
+ else if ((0, types_1.isPlainObject)(target)) {
840
+ target = (0, types_1.cloneObject)(userConfig, { target: { ...target }, deep: true, preserve: true });
841
+ CACHE_VIEWENGINE.set(userConfig, target);
836
842
  }
837
843
  else {
838
844
  target = userConfig;
@@ -843,7 +849,7 @@ class Document extends core_1.Client {
843
849
  else {
844
850
  target = viewEngine;
845
851
  }
846
- if (!((0, types_1.isPlainObject)(target) && target.name)) {
852
+ if (!((0, types_1.isPlainObject)(target) && (0, types_1.isString)(target.name))) {
847
853
  this.abort('view_engine');
848
854
  const from = typeof viewEngine === 'string' ? viewEngine : this.moduleName;
849
855
  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.5.20",
3
+ "version": "0.5.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.5.20",
24
- "@e-mc/db": "0.5.20",
25
- "@e-mc/types": "0.5.20",
23
+ "@e-mc/core": "0.5.21",
24
+ "@e-mc/db": "0.5.21",
25
+ "@e-mc/types": "0.5.21",
26
26
  "chalk": "4.1.2",
27
27
  "htmlparser2": "^9.1.0",
28
28
  "js-yaml": "^4.1.0",