@e-mc/document 0.12.15 → 0.12.17
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 +4 -8
- package/README.md +12 -10
- package/index.js +17 -23
- package/package.json +6 -6
- package/parse/index.js +5 -5
- package/util.js +1 -1
package/LICENSE
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2025 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.12.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.12.17/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,15 +187,15 @@ 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.17/lib/squared.d.ts
|
|
191
|
+
- https://www.unpkg.com/@e-mc/types@0.12.17/lib/asset.d.ts
|
|
192
|
+
- https://www.unpkg.com/@e-mc/types@0.12.17/lib/core.d.ts
|
|
193
|
+
- https://www.unpkg.com/@e-mc/types@0.12.17/lib/document.d.ts
|
|
194
|
+
- https://www.unpkg.com/@e-mc/types@0.12.17/lib/filemanager.d.ts
|
|
195
|
+
- https://www.unpkg.com/@e-mc/types@0.12.17/lib/logger.d.ts
|
|
196
|
+
- https://www.unpkg.com/@e-mc/types@0.12.17/lib/settings.d.ts
|
|
197
|
+
- https://www.unpkg.com/@e-mc/types@0.12.17/lib/watch.d.ts
|
|
196
198
|
|
|
197
199
|
## LICENSE
|
|
198
200
|
|
|
199
|
-
|
|
201
|
+
MIT
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.17",
|
|
4
4
|
"description": "Document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"squared"
|
|
17
17
|
],
|
|
18
18
|
"author": "An Pham <anpham6@gmail.com>",
|
|
19
|
-
"license": "
|
|
19
|
+
"license": "MIT",
|
|
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.17",
|
|
23
|
+
"@e-mc/db": "0.12.17",
|
|
24
|
+
"@e-mc/types": "0.12.17",
|
|
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)) {
|