@e-mc/document 0.11.7 → 0.11.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 +9 -9
- package/index.js +10 -11
- package/package.json +4 -4
- package/util.js +1 -1
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.11.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.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.11.
|
|
189
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
190
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
191
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
192
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
193
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
194
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
195
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
188
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/squared.d.ts
|
|
189
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/asset.d.ts
|
|
190
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/core.d.ts
|
|
191
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/document.d.ts
|
|
192
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/filemanager.d.ts
|
|
193
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/logger.d.ts
|
|
194
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/settings.d.ts
|
|
195
|
+
- https://www.unpkg.com/@e-mc/types@0.11.8/lib/watch.d.ts
|
|
196
196
|
|
|
197
197
|
## LICENSE
|
|
198
198
|
|
package/index.js
CHANGED
|
@@ -54,7 +54,7 @@ const fixHint = (warningCount, errorCount, value) => warningCount > 0 || errorCo
|
|
|
54
54
|
const compareValue = (value) => value.replace(/["'()]/g, '').trim();
|
|
55
55
|
const toPath = (uri, hostname) => path.resolve(hostname[1], uri.substring(normalizeDir(hostname[0]).length).split('?')[0]);
|
|
56
56
|
const toBase64 = (value) => 'data:application/json;base64,' + Buffer.from(value).toString('base64');
|
|
57
|
-
const toPosix = (value) => value.replace(/(?:^\\|\\+)/g, '/');
|
|
57
|
+
const toPosix = (value) => core_1.Client.PLATFORM_WIN32 ? value.trim().replace(/(?:^\\|\\+)/g, '/') : value;
|
|
58
58
|
const joinString = (name, ...values) => (name ? name + ': ' : '') + values.reduce((a, b) => b ? a + (a ? ' -> ' : '') + b : a, '');
|
|
59
59
|
const truncateString = (value, width) => value.length > width ? value.substring(0, width - 3) + '...' : value.padStart(width);
|
|
60
60
|
const isFunction = (value) => typeof value === 'function';
|
|
@@ -900,34 +900,33 @@ class Document extends core_1.Client {
|
|
|
900
900
|
}
|
|
901
901
|
const importsStrict = this.getUserSettings()?.imports_strict ?? this.settings.imports_strict;
|
|
902
902
|
const scopes = (importsStrict ? this.findSourceScope(uri, imports) : []).concat([imports]);
|
|
903
|
-
const
|
|
903
|
+
const protocol = core_1.Client.isURL(uri);
|
|
904
904
|
let result;
|
|
905
905
|
for (const scope of scopes) {
|
|
906
906
|
for (const url in scope) {
|
|
907
907
|
if (uri === url && (0, types_1.isString)(result = scope[url])) {
|
|
908
908
|
if (importsStrict) {
|
|
909
|
-
if (
|
|
910
|
-
|
|
909
|
+
if (core_1.Client.isPath(result) && !(protocol ? url : toPosix(url)).endsWith('/')) {
|
|
910
|
+
return toPosix(result);
|
|
911
911
|
}
|
|
912
|
-
|
|
912
|
+
continue;
|
|
913
913
|
}
|
|
914
914
|
return result;
|
|
915
915
|
}
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
|
-
const remote = toPosix(uri);
|
|
919
918
|
const found = [];
|
|
920
919
|
if (importsStrict) {
|
|
921
|
-
const
|
|
920
|
+
const remote = protocol ? uri : toPosix(uri);
|
|
922
921
|
for (const scope of scopes) {
|
|
923
922
|
for (const url in scope) {
|
|
924
923
|
const local = protocol ? url : toPosix(url);
|
|
925
|
-
if (
|
|
924
|
+
if (local.endsWith('/') && remote.startsWith(local) && (result = scope[url]) && result.endsWith('/')) {
|
|
926
925
|
if (protocol) {
|
|
927
926
|
found.push([url, result]);
|
|
928
927
|
}
|
|
929
928
|
else if (core_1.Client.isPath(result = path.join(result, remote.substring(local.length)))) {
|
|
930
|
-
return
|
|
929
|
+
return toPosix(result);
|
|
931
930
|
}
|
|
932
931
|
}
|
|
933
932
|
}
|
|
@@ -962,7 +961,7 @@ class Document extends core_1.Client {
|
|
|
962
961
|
result = toPath(uri, found[0]);
|
|
963
962
|
}
|
|
964
963
|
if (result) {
|
|
965
|
-
return
|
|
964
|
+
return toPosix(result);
|
|
966
965
|
}
|
|
967
966
|
}
|
|
968
967
|
}
|
|
@@ -1131,7 +1130,7 @@ class Document extends core_1.Client {
|
|
|
1131
1130
|
if (expires !== 0) {
|
|
1132
1131
|
cache[cacheKey] = render;
|
|
1133
1132
|
if (core_1.Client.enabled("memory.settings.users", username)) {
|
|
1134
|
-
expires = typeof expires === 'number' && expires !== Infinity ? expires : 0;
|
|
1133
|
+
expires = typeof expires === 'number' && expires !== Infinity ? Math.min(expires, core_1.Client.MAX_TIMEOUT) : 0;
|
|
1135
1134
|
}
|
|
1136
1135
|
else {
|
|
1137
1136
|
expires = 60000;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
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": "BSD-3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.11.
|
|
24
|
-
"@e-mc/db": "0.11.
|
|
25
|
-
"@e-mc/types": "0.11.
|
|
23
|
+
"@e-mc/core": "0.11.8",
|
|
24
|
+
"@e-mc/db": "0.11.8",
|
|
25
|
+
"@e-mc/types": "0.11.8",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
27
|
"domhandler": "^5.0.3",
|
|
28
28
|
"domutils": "^3.2.2",
|
package/util.js
CHANGED
|
@@ -212,7 +212,7 @@ function hasValue(target, ...values) {
|
|
|
212
212
|
return false;
|
|
213
213
|
}
|
|
214
214
|
function getModuleName(err) {
|
|
215
|
-
const match = err instanceof Error && /Cannot find module '([^']+)'/.exec(err.message);
|
|
215
|
+
const match = err instanceof Error && /Cannot find (?:module|package) '([^']+)'/.exec(err.message);
|
|
216
216
|
if (match) {
|
|
217
217
|
return match[1];
|
|
218
218
|
}
|