@e-mc/document 0.10.12 → 0.10.14
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 +3 -7
- package/README.md +10 -10
- package/index.js +16 -4
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
Copyright 2024 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
|
|
|
5
|
-
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
6
|
|
|
7
|
-
|
|
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
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.14/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.
|
|
187
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
188
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
189
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
190
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
191
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
192
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
193
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
186
|
+
- https://www.unpkg.com/@e-mc/types@0.10.14/lib/squared.d.ts
|
|
187
|
+
- https://www.unpkg.com/@e-mc/types@0.10.14/lib/asset.d.ts
|
|
188
|
+
- https://www.unpkg.com/@e-mc/types@0.10.14/lib/core.d.ts
|
|
189
|
+
- https://www.unpkg.com/@e-mc/types@0.10.14/lib/document.d.ts
|
|
190
|
+
- https://www.unpkg.com/@e-mc/types@0.10.14/lib/filemanager.d.ts
|
|
191
|
+
- https://www.unpkg.com/@e-mc/types@0.10.14/lib/logger.d.ts
|
|
192
|
+
- https://www.unpkg.com/@e-mc/types@0.10.14/lib/settings.d.ts
|
|
193
|
+
- https://www.unpkg.com/@e-mc/types@0.10.14/lib/watch.d.ts
|
|
194
194
|
|
|
195
195
|
## LICENSE
|
|
196
196
|
|
|
197
|
-
|
|
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 (
|
|
1091
|
-
|
|
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"));
|
|
@@ -1111,7 +1117,13 @@ class Document extends core_1.Client {
|
|
|
1111
1117
|
}
|
|
1112
1118
|
try {
|
|
1113
1119
|
const name = target.name;
|
|
1114
|
-
|
|
1120
|
+
let context;
|
|
1121
|
+
try {
|
|
1122
|
+
context = require(name);
|
|
1123
|
+
}
|
|
1124
|
+
catch {
|
|
1125
|
+
context = await (0, types_1.importESM)(name);
|
|
1126
|
+
}
|
|
1115
1127
|
const { singleRow, options = {} } = target;
|
|
1116
1128
|
let { compile, output } = options;
|
|
1117
1129
|
if (!(0, types_1.isPlainObject)(output)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.14",
|
|
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": "
|
|
20
|
+
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.10.
|
|
24
|
-
"@e-mc/db": "0.10.
|
|
25
|
-
"@e-mc/types": "0.10.
|
|
23
|
+
"@e-mc/core": "0.10.14",
|
|
24
|
+
"@e-mc/db": "0.10.14",
|
|
25
|
+
"@e-mc/types": "0.10.14",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
27
|
"domhandler": "^5.0.3",
|
|
28
28
|
"domutils": "^3.1.0",
|