@e-mc/document 0.10.12 → 0.10.13

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 (4) hide show
  1. package/LICENSE +3 -7
  2. package/README.md +10 -10
  3. package/index.js +9 -3
  4. package/package.json +5 -5
package/LICENSE CHANGED
@@ -1,11 +1,7 @@
1
1
  Copyright 2024 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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
 
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.10.12/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.13/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.10.12/lib/squared.d.ts
187
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/asset.d.ts
188
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/core.d.ts
189
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/document.d.ts
190
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/filemanager.d.ts
191
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/logger.d.ts
192
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/settings.d.ts
193
- - https://www.unpkg.com/@e-mc/types@0.10.12/lib/watch.d.ts
186
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/squared.d.ts
187
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/asset.d.ts
188
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/core.d.ts
189
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/document.d.ts
190
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/filemanager.d.ts
191
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/logger.d.ts
192
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/settings.d.ts
193
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/watch.d.ts
194
194
 
195
195
  ## LICENSE
196
196
 
197
- BSD 3-Clause
197
+ MIT
package/index.js CHANGED
@@ -16,6 +16,7 @@ const CACHE_ETAG = {};
16
16
  const CACHE_CODE = {};
17
17
  const CACHE_HASH = {};
18
18
  const CACHE_TEMPLATE = {};
19
+ const CACHE_VIEWENGINE = new Map();
19
20
  const CACHE_EXTERNAL = {};
20
21
  const CACHE_PICOMATCH = new Map();
21
22
  let CACHE_TOTAL = 0;
@@ -348,6 +349,7 @@ class Document extends core_1.Client {
348
349
  delete cache[name];
349
350
  }
350
351
  }
352
+ CACHE_VIEWENGINE.clear();
351
353
  CACHE_PICOMATCH.clear();
352
354
  CACHE_TOTAL = 0;
353
355
  }
@@ -1087,8 +1089,12 @@ class Document extends core_1.Client {
1087
1089
  target = this.settings.view_engine?.[viewEngine];
1088
1090
  const userConfig = this.getUserSettings()?.view_engine?.[viewEngine];
1089
1091
  if ((0, types_1.isPlainObject)(userConfig)) {
1090
- if ((0, types_1.isPlainObject)(target)) {
1091
- (0, types_1.cloneObject)(userConfig, { target, deep: true, preserve: true });
1092
+ if (CACHE_VIEWENGINE.has(userConfig)) {
1093
+ target = CACHE_VIEWENGINE.get(userConfig);
1094
+ }
1095
+ else if ((0, types_1.isPlainObject)(target)) {
1096
+ target = (0, types_1.cloneObject)(userConfig, { target: { ...target }, deep: true, preserve: true });
1097
+ CACHE_VIEWENGINE.set(userConfig, target);
1092
1098
  }
1093
1099
  else {
1094
1100
  target = userConfig;
@@ -1099,7 +1105,7 @@ class Document extends core_1.Client {
1099
1105
  else {
1100
1106
  target = viewEngine;
1101
1107
  }
1102
- if (!((0, types_1.isPlainObject)(target) && target.name)) {
1108
+ if (!((0, types_1.isPlainObject)(target) && (0, types_1.isString)(target.name))) {
1103
1109
  this.abort('view_engine');
1104
1110
  const from = typeof viewEngine === 'string' ? viewEngine : this.moduleName;
1105
1111
  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.10.12",
3
+ "version": "0.10.13",
4
4
  "description": "Document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,12 +17,12 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD-3-Clause",
20
+ "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.10.12",
24
- "@e-mc/db": "0.10.12",
25
- "@e-mc/types": "0.10.12",
23
+ "@e-mc/core": "0.10.13",
24
+ "@e-mc/db": "0.10.13",
25
+ "@e-mc/types": "0.10.13",
26
26
  "chalk": "4.1.2",
27
27
  "domhandler": "^5.0.3",
28
28
  "domutils": "^3.1.0",