@e-mc/document 0.7.22 → 0.7.23

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
@@ -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;
@@ -64,6 +65,7 @@ class Document extends core_1.Client {
64
65
  delete cache[name];
65
66
  }
66
67
  }
68
+ CACHE_VIEWENGINE.clear();
67
69
  CACHE_PICOMATCH.clear();
68
70
  CACHE_TOTAL = 0;
69
71
  }
@@ -830,8 +832,12 @@ class Document extends core_1.Client {
830
832
  const username = (_b = this.host) === null || _b === void 0 ? void 0 : _b.username;
831
833
  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]);
832
834
  if ((0, types_1.isPlainObject)(userConfig)) {
833
- if ((0, types_1.isPlainObject)(target)) {
834
- (0, types_1.cloneObject)(userConfig, { target, deep: true, preserve: true });
835
+ if (CACHE_VIEWENGINE.has(userConfig)) {
836
+ target = CACHE_VIEWENGINE.get(userConfig);
837
+ }
838
+ else if ((0, types_1.isPlainObject)(target)) {
839
+ target = (0, types_1.cloneObject)(userConfig, { target: { ...target }, deep: true, preserve: true });
840
+ CACHE_VIEWENGINE.set(userConfig, target);
835
841
  }
836
842
  else {
837
843
  target = userConfig;
@@ -842,7 +848,7 @@ class Document extends core_1.Client {
842
848
  else {
843
849
  target = viewEngine;
844
850
  }
845
- if (!((0, types_1.isPlainObject)(target) && target.name)) {
851
+ if (!((0, types_1.isPlainObject)(target) && (0, types_1.isString)(target.name))) {
846
852
  this.abort('view_engine');
847
853
  const from = typeof viewEngine === 'string' ? viewEngine : this.moduleName;
848
854
  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.7.22",
3
+ "version": "0.7.23",
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.7.22",
24
- "@e-mc/db": "0.7.22",
25
- "@e-mc/types": "0.7.22",
23
+ "@e-mc/core": "0.7.23",
24
+ "@e-mc/db": "0.7.23",
25
+ "@e-mc/types": "0.7.23",
26
26
  "chalk": "4.1.2",
27
27
  "domhandler": "^5.0.3",
28
28
  "domutils": "^3.1.0",