@e-mc/document 0.13.7 → 0.13.8
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/README.md +10 -10
- package/index.js +8 -7
- package/package.json +4 -4
- package/transform/index.js +15 -6
- package/util.js +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @e-mc/document
|
|
2
2
|
|
|
3
|
-
* NodeJS 18.20
|
|
3
|
+
* NodeJS 18.20 LTS
|
|
4
4
|
* ES2022
|
|
5
5
|
|
|
6
6
|
## General Usage
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.8/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { DataSource, ViewEngine } from "./squared";
|
|
@@ -185,14 +185,14 @@ NOTE: **@e-mc/document** is an abstract base class and cannot be instantiated. *
|
|
|
185
185
|
|
|
186
186
|
## References
|
|
187
187
|
|
|
188
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
189
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
190
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
191
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
192
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
193
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
194
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
195
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
188
|
+
- https://www.unpkg.com/@e-mc/types@0.13.8/lib/squared.d.ts
|
|
189
|
+
- https://www.unpkg.com/@e-mc/types@0.13.8/lib/asset.d.ts
|
|
190
|
+
- https://www.unpkg.com/@e-mc/types@0.13.8/lib/core.d.ts
|
|
191
|
+
- https://www.unpkg.com/@e-mc/types@0.13.8/lib/document.d.ts
|
|
192
|
+
- https://www.unpkg.com/@e-mc/types@0.13.8/lib/filemanager.d.ts
|
|
193
|
+
- https://www.unpkg.com/@e-mc/types@0.13.8/lib/logger.d.ts
|
|
194
|
+
- https://www.unpkg.com/@e-mc/types@0.13.8/lib/settings.d.ts
|
|
195
|
+
- https://www.unpkg.com/@e-mc/types@0.13.8/lib/watch.d.ts
|
|
196
196
|
|
|
197
197
|
## LICENSE
|
|
198
198
|
|
package/index.js
CHANGED
|
@@ -761,13 +761,13 @@ class Document extends core_1.Client {
|
|
|
761
761
|
const cache = CACHE_CONFIG.get(data);
|
|
762
762
|
cacheKey = type ? `${name}::${type}` : name;
|
|
763
763
|
if (cache) {
|
|
764
|
-
const items = cache[username]?.[
|
|
764
|
+
const items = cache[username]?.[cacheKey];
|
|
765
765
|
if (items) {
|
|
766
766
|
return cloneConfigItems(items);
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
769
|
else {
|
|
770
|
-
CACHE_CONFIG.set(data,
|
|
770
|
+
CACHE_CONFIG.set(data, Object.create(null));
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
773
|
for (const plugin in data) {
|
|
@@ -779,7 +779,7 @@ class Document extends core_1.Client {
|
|
|
779
779
|
if (options || output) {
|
|
780
780
|
const result = [plugin, options, output, true];
|
|
781
781
|
if (cacheKey) {
|
|
782
|
-
const cache = CACHE_CONFIG.get(data)[username] ||=
|
|
782
|
+
const cache = CACHE_CONFIG.get(data)[username] ||= Object.create(null);
|
|
783
783
|
cache[cacheKey] = cloneConfigItems(result);
|
|
784
784
|
}
|
|
785
785
|
return result;
|
|
@@ -1126,7 +1126,7 @@ class Document extends core_1.Client {
|
|
|
1126
1126
|
this.writeFail(["Unable to load configuration", from], (0, types_1.errorMessage)('view-engine', from, "Unknown"));
|
|
1127
1127
|
return null;
|
|
1128
1128
|
}
|
|
1129
|
-
if (
|
|
1129
|
+
if (!target.outputEmpty && !(0, types_1.isArray)(data)) {
|
|
1130
1130
|
return '';
|
|
1131
1131
|
}
|
|
1132
1132
|
try {
|
|
@@ -1183,7 +1183,7 @@ class Document extends core_1.Client {
|
|
|
1183
1183
|
const writeRow = async (row) => {
|
|
1184
1184
|
const content = await render.call(context, row);
|
|
1185
1185
|
if (content != null) {
|
|
1186
|
-
result += content;
|
|
1186
|
+
result += typeof content === 'string' ? content : JSON.stringify(content);
|
|
1187
1187
|
valid = true;
|
|
1188
1188
|
}
|
|
1189
1189
|
};
|
|
@@ -1216,8 +1216,9 @@ class Document extends core_1.Client {
|
|
|
1216
1216
|
return null;
|
|
1217
1217
|
}
|
|
1218
1218
|
async transform(type, code, format, options = {}) {
|
|
1219
|
-
let transform = this.settings.transform
|
|
1220
|
-
|
|
1219
|
+
let transform = this.settings.transform;
|
|
1220
|
+
const data = transform?.[type];
|
|
1221
|
+
if (!(0, types_1.isObject)(data)) {
|
|
1221
1222
|
return;
|
|
1222
1223
|
}
|
|
1223
1224
|
if (typeof format === 'string') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.8",
|
|
4
4
|
"description": "Document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"license": "BSD-3-Clause",
|
|
20
20
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@e-mc/core": "0.13.
|
|
23
|
-
"@e-mc/db": "0.13.
|
|
24
|
-
"@e-mc/types": "0.13.
|
|
22
|
+
"@e-mc/core": "0.13.8",
|
|
23
|
+
"@e-mc/db": "0.13.8",
|
|
24
|
+
"@e-mc/types": "0.13.8",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"domhandler": "^5.0.3",
|
|
27
27
|
"domutils": "^3.2.2",
|
package/transform/index.js
CHANGED
|
@@ -22,6 +22,19 @@ function toJSON(data) {
|
|
|
22
22
|
catch {
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
function parseModuleArgs(startDir, packageName, version) {
|
|
26
|
+
if ((0, types_1.isObject)(startDir)) {
|
|
27
|
+
({ startDir, packageName, version } = startDir);
|
|
28
|
+
}
|
|
29
|
+
if (!startDir && packageName && version && version !== 'latest') {
|
|
30
|
+
try {
|
|
31
|
+
startDir = path.dirname(require.resolve(packageName));
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return [startDir, packageName, version];
|
|
37
|
+
}
|
|
25
38
|
class Out {
|
|
26
39
|
sourceFiles;
|
|
27
40
|
ignoreCache;
|
|
@@ -127,9 +140,7 @@ class TransformSeries extends core_1.Module {
|
|
|
127
140
|
return baseConfig;
|
|
128
141
|
}
|
|
129
142
|
upgrade(context, startDir, packageName, version) {
|
|
130
|
-
|
|
131
|
-
({ startDir, packageName, version } = startDir);
|
|
132
|
-
}
|
|
143
|
+
[startDir, packageName, version] = parseModuleArgs(startDir, packageName, version);
|
|
133
144
|
try {
|
|
134
145
|
const pathname = startDir && this.findModule(startDir, packageName, version || this.version) || packageName;
|
|
135
146
|
if (pathname) {
|
|
@@ -141,9 +152,7 @@ class TransformSeries extends core_1.Module {
|
|
|
141
152
|
return context;
|
|
142
153
|
}
|
|
143
154
|
async upgradeESM(context, startDir, packageName, version) {
|
|
144
|
-
|
|
145
|
-
({ startDir, packageName, version } = startDir);
|
|
146
|
-
}
|
|
155
|
+
[startDir, packageName, version] = parseModuleArgs(startDir, packageName, version);
|
|
147
156
|
try {
|
|
148
157
|
const pathname = startDir && this.findModule(startDir, packageName, version || this.version);
|
|
149
158
|
let result;
|
package/util.js
CHANGED
|
@@ -187,7 +187,7 @@ function trimQuote(value) {
|
|
|
187
187
|
value = value.trim();
|
|
188
188
|
const first = value[0];
|
|
189
189
|
const last = value.at(-1);
|
|
190
|
-
return first === last && (first === '"' || first === "'") ? value.
|
|
190
|
+
return first === last && (first === '"' || first === "'") ? value.slice(1, -1).trim() : value;
|
|
191
191
|
}
|
|
192
192
|
function wrapQuote(value, quote = '"') {
|
|
193
193
|
return quote + value.replace(new RegExp(`(?<!\\\\)${quote}`, 'g'), `\\${quote}`) + quote;
|