@e-mc/document 0.12.14 → 0.12.16
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 +11 -9
- package/index.js +23 -24
- package/package.json +5 -5
- package/parse/index.js +5 -5
- 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.12.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.12.16/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { DataSource, ViewEngine } from "./squared";
|
|
@@ -76,7 +76,9 @@ interface DocumentConstructor extends ModuleConstructor {
|
|
|
76
76
|
createSourceMap(code: string, remove: boolean): SourceMap;
|
|
77
77
|
createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap;
|
|
78
78
|
writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): string | undefined;
|
|
79
|
+
/** @deprecated */
|
|
79
80
|
updateGradle(source: string, namespaces: string[], value: string, upgrade: boolean): string;
|
|
81
|
+
/** @deprecated */
|
|
80
82
|
updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions): string;
|
|
81
83
|
generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[];
|
|
82
84
|
cleanup?(this: IFileManager, instance: IDocument): Promise<unknown>;
|
|
@@ -185,14 +187,14 @@ NOTE: **@e-mc/document** is an abstract base class and cannot be instantiated. *
|
|
|
185
187
|
|
|
186
188
|
## References
|
|
187
189
|
|
|
188
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
189
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
190
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
191
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
192
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
193
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
194
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
195
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
190
|
+
- https://www.unpkg.com/@e-mc/types@0.12.16/lib/squared.d.ts
|
|
191
|
+
- https://www.unpkg.com/@e-mc/types@0.12.16/lib/asset.d.ts
|
|
192
|
+
- https://www.unpkg.com/@e-mc/types@0.12.16/lib/core.d.ts
|
|
193
|
+
- https://www.unpkg.com/@e-mc/types@0.12.16/lib/document.d.ts
|
|
194
|
+
- https://www.unpkg.com/@e-mc/types@0.12.16/lib/filemanager.d.ts
|
|
195
|
+
- https://www.unpkg.com/@e-mc/types@0.12.16/lib/logger.d.ts
|
|
196
|
+
- https://www.unpkg.com/@e-mc/types@0.12.16/lib/settings.d.ts
|
|
197
|
+
- https://www.unpkg.com/@e-mc/types@0.12.16/lib/watch.d.ts
|
|
196
198
|
|
|
197
199
|
## LICENSE
|
|
198
200
|
|
package/index.js
CHANGED
|
@@ -687,7 +687,7 @@ class Document extends core_1.Client {
|
|
|
687
687
|
let instance;
|
|
688
688
|
if (handler && handler !== "@e-mc/db") {
|
|
689
689
|
try {
|
|
690
|
-
const Module =
|
|
690
|
+
const Module = (0, types_1.requireESM)(handler);
|
|
691
691
|
if (core_1.Client.constructorOf(Module, 'clientdb')) {
|
|
692
692
|
instance = new Module(db, database);
|
|
693
693
|
}
|
|
@@ -828,33 +828,25 @@ class Document extends core_1.Client {
|
|
|
828
828
|
let encoding, cache;
|
|
829
829
|
if (typeof options === 'boolean') {
|
|
830
830
|
cache = options;
|
|
831
|
+
options = undefined;
|
|
831
832
|
}
|
|
832
|
-
else if (
|
|
833
|
+
else if (options) {
|
|
833
834
|
({ encoding, cache } = options);
|
|
834
835
|
}
|
|
835
|
-
let result;
|
|
836
|
-
|
|
837
|
-
if (
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
const pkgName = value.substring(4);
|
|
841
|
-
if (!result) {
|
|
842
|
-
try {
|
|
843
|
-
result = require(pkgName);
|
|
844
|
-
if (typeof result === 'function') {
|
|
845
|
-
return Object.defineProperty(result, "__cjs__", { value: true });
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
catch (err) {
|
|
849
|
-
this.checkPackage(err, pkgName, "Unknown");
|
|
850
|
-
}
|
|
851
|
-
if (!result) {
|
|
836
|
+
let result, pkgName;
|
|
837
|
+
try {
|
|
838
|
+
if (value.startsWith('npm:')) {
|
|
839
|
+
if (!core_1.Client.enabled("node.require.npm")) {
|
|
852
840
|
return null;
|
|
853
841
|
}
|
|
842
|
+
pkgName = value.substring(4);
|
|
843
|
+
result = options?.default ? (0, types_1.requireESM)(pkgName, options.url) : require(pkgName);
|
|
844
|
+
if (typeof result === 'function') {
|
|
845
|
+
return Object.defineProperty(result, "__cjs__", { value: true, writable: false, enumerable: false });
|
|
846
|
+
}
|
|
847
|
+
return result;
|
|
854
848
|
}
|
|
855
|
-
|
|
856
|
-
try {
|
|
857
|
-
const source = (result || this.readFile(value, { ownPermissionOnly: true, absolutePath: this.hasEval('absolute'), requireExt: true, encoding: (0, types_1.getEncoding)(encoding), cache })) || value;
|
|
849
|
+
const source = this.readFile(value, { ownPermissionOnly: true, absolutePath: this.hasEval('absolute'), requireExt: true, encoding: (0, types_1.getEncoding)(encoding), cache }) || value;
|
|
858
850
|
if (typeof source !== 'string') {
|
|
859
851
|
result = source;
|
|
860
852
|
}
|
|
@@ -870,7 +862,9 @@ class Document extends core_1.Client {
|
|
|
870
862
|
}
|
|
871
863
|
}
|
|
872
864
|
catch (err) {
|
|
873
|
-
|
|
865
|
+
if (!pkgName || this.checkPackage(err, pkgName)) {
|
|
866
|
+
this.writeFail(["Unable to read file", path.basename(value)], err, 8192);
|
|
867
|
+
}
|
|
874
868
|
}
|
|
875
869
|
return null;
|
|
876
870
|
}
|
|
@@ -1058,7 +1052,12 @@ class Document extends core_1.Client {
|
|
|
1058
1052
|
case 'xml':
|
|
1059
1053
|
return new (require('fast-xml-parser').XMLParser)(options).parse(source);
|
|
1060
1054
|
case 'toml':
|
|
1061
|
-
|
|
1055
|
+
try {
|
|
1056
|
+
return require('smol-toml').parse(source, options);
|
|
1057
|
+
}
|
|
1058
|
+
catch {
|
|
1059
|
+
return require('toml').parse(source);
|
|
1060
|
+
}
|
|
1062
1061
|
default:
|
|
1063
1062
|
return JSON.parse(source);
|
|
1064
1063
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.16",
|
|
4
4
|
"description": "Document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"license": "BSD-3-Clause",
|
|
20
20
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@e-mc/core": "0.12.
|
|
23
|
-
"@e-mc/db": "0.12.
|
|
24
|
-
"@e-mc/types": "0.12.
|
|
22
|
+
"@e-mc/core": "0.12.16",
|
|
23
|
+
"@e-mc/db": "0.12.16",
|
|
24
|
+
"@e-mc/types": "0.12.16",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"domhandler": "^5.0.3",
|
|
27
27
|
"domutils": "^3.2.2",
|
|
28
28
|
"htmlparser2": "^10.0.0",
|
|
29
29
|
"js-yaml": "^4.1.1",
|
|
30
|
-
"picomatch": "^4.0.
|
|
30
|
+
"picomatch": "^4.0.4"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/parse/index.js
CHANGED
|
@@ -179,12 +179,13 @@ class XmlWriter {
|
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
static escapeAttributes(source) {
|
|
182
|
-
let
|
|
182
|
+
let match, attribute;
|
|
183
183
|
while (match = REGEXP_TAGATTR.exec(source)) {
|
|
184
184
|
let output = match[0], modified = false;
|
|
185
|
-
while (attribute = REGEXP_ATTRVALUE.exec(
|
|
185
|
+
while (attribute = REGEXP_ATTRVALUE.exec(output)) {
|
|
186
186
|
const value = attribute[2] || attribute[3] || attribute[4];
|
|
187
|
-
|
|
187
|
+
const escaped = this.escapeXmlString(value);
|
|
188
|
+
if (value !== escaped) {
|
|
188
189
|
output = (0, util_1.spliceMatch)(output, attribute, attribute[1] + `="${escaped}"`, REGEXP_ATTRVALUE);
|
|
189
190
|
modified = true;
|
|
190
191
|
}
|
|
@@ -400,7 +401,6 @@ class XmlWriter {
|
|
|
400
401
|
const result = [];
|
|
401
402
|
const flags = ignoreCase ? 'gi' : 'g';
|
|
402
403
|
let pattern = CACHE_TAGNAME[tagPattern + flags] ||= new RegExp(`<(?:(!--[\\S\\s]*?--)|(!\\[CDATA\\[[\\S\\s]*?\\]\\])` + (tagPattern ? '|' + `(${tagPattern})${this.PATTERN_TAGOPEN}*` : '') + ')>', flags), match;
|
|
403
|
-
pattern.lastIndex = 0;
|
|
404
404
|
while (match = pattern.exec(source)) {
|
|
405
405
|
if (stripXml) {
|
|
406
406
|
source = this.replaceMatch(match, source, '', { pattern, trimLeading: true });
|
|
@@ -417,6 +417,7 @@ class XmlWriter {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
pattern.lastIndex = 0;
|
|
420
421
|
if (stripXml) {
|
|
421
422
|
return source;
|
|
422
423
|
}
|
|
@@ -1135,7 +1136,6 @@ class XmlElement {
|
|
|
1135
1136
|
}
|
|
1136
1137
|
this._tagVoid = isVoid;
|
|
1137
1138
|
REGEXP_ATTRVALUE.lastIndex = 0;
|
|
1138
|
-
REGEXP_ATTRNAME.lastIndex = 0;
|
|
1139
1139
|
}
|
|
1140
1140
|
else if (tagVoid) {
|
|
1141
1141
|
this._tagVoid = true;
|
package/util.js
CHANGED
|
@@ -42,7 +42,7 @@ function loadPlugins(plugins, map) {
|
|
|
42
42
|
});
|
|
43
43
|
for (const plugin of items) {
|
|
44
44
|
if (plugin) {
|
|
45
|
-
let method = typeof plugin[0] === 'function' ? plugin[0] :
|
|
45
|
+
let method = typeof plugin[0] === 'function' ? plugin[0] : (0, types_1.requireESM)(plugin[0]), options = plugin[1];
|
|
46
46
|
if ((0, types_1.isPlainObject)(method)) {
|
|
47
47
|
const attr = options?.__default__;
|
|
48
48
|
if ((0, types_1.isString)(attr)) {
|