@e-mc/document 0.9.1 → 0.9.3
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 +8 -5
- package/package.json +4 -4
- package/parse/dom.js +2 -2
- package/parse/index.js +7 -10
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.9.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.3/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { DataSource, ViewEngine } from "./squared";
|
|
@@ -183,14 +183,14 @@ 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.9.
|
|
187
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
188
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
189
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
190
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
191
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
192
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
193
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
186
|
+
- https://www.unpkg.com/@e-mc/types@0.9.3/lib/squared.d.ts
|
|
187
|
+
- https://www.unpkg.com/@e-mc/types@0.9.3/lib/asset.d.ts
|
|
188
|
+
- https://www.unpkg.com/@e-mc/types@0.9.3/lib/core.d.ts
|
|
189
|
+
- https://www.unpkg.com/@e-mc/types@0.9.3/lib/document.d.ts
|
|
190
|
+
- https://www.unpkg.com/@e-mc/types@0.9.3/lib/filemanager.d.ts
|
|
191
|
+
- https://www.unpkg.com/@e-mc/types@0.9.3/lib/logger.d.ts
|
|
192
|
+
- https://www.unpkg.com/@e-mc/types@0.9.3/lib/settings.d.ts
|
|
193
|
+
- https://www.unpkg.com/@e-mc/types@0.9.3/lib/watch.d.ts
|
|
194
194
|
|
|
195
195
|
## LICENSE
|
|
196
196
|
|
package/index.js
CHANGED
|
@@ -657,14 +657,14 @@ class Document extends core_1.Client {
|
|
|
657
657
|
}
|
|
658
658
|
let result;
|
|
659
659
|
if ((value = value.trim()).startsWith('npm:')) {
|
|
660
|
+
if (!core_1.Client.enabled("node.require.npm")) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
660
663
|
const pkgName = value.substring(4);
|
|
661
664
|
if (persist) {
|
|
662
665
|
result = CACHE_REQUIRE[pkgName];
|
|
663
666
|
}
|
|
664
667
|
if (!result) {
|
|
665
|
-
if (!core_1.Client.enabled("node.require.npm")) {
|
|
666
|
-
return null;
|
|
667
|
-
}
|
|
668
668
|
try {
|
|
669
669
|
result = require(pkgName);
|
|
670
670
|
if (persist && result) {
|
|
@@ -683,7 +683,7 @@ class Document extends core_1.Client {
|
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
685
|
try {
|
|
686
|
-
const source = result || this.readFile(value, { ownPermissionOnly: true, absolutePath: this.hasEval('absolute'), requireExt: true, encoding, cache }) || value;
|
|
686
|
+
const source = (result || this.readFile(value, { ownPermissionOnly: true, absolutePath: this.hasEval('absolute'), requireExt: true, encoding: (0, types_1.getEncoding)(encoding), cache })) || value;
|
|
687
687
|
if (typeof source !== 'string') {
|
|
688
688
|
result = source;
|
|
689
689
|
}
|
|
@@ -1364,7 +1364,10 @@ class Document extends core_1.Client {
|
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
1366
|
get imports() {
|
|
1367
|
-
|
|
1367
|
+
if (!this._imports) {
|
|
1368
|
+
this.imports = {};
|
|
1369
|
+
}
|
|
1370
|
+
return this._imports;
|
|
1368
1371
|
}
|
|
1369
1372
|
get watching() {
|
|
1370
1373
|
return this.assets.some(item => item.watch);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/document",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
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.9.
|
|
24
|
-
"@e-mc/db": "0.9.
|
|
25
|
-
"@e-mc/types": "0.9.
|
|
23
|
+
"@e-mc/core": "0.9.3",
|
|
24
|
+
"@e-mc/db": "0.9.3",
|
|
25
|
+
"@e-mc/types": "0.9.3",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
27
|
"htmlparser2": "^9.1.0",
|
|
28
28
|
"js-yaml": "^4.1.0",
|
package/parse/dom.js
CHANGED
|
@@ -139,7 +139,7 @@ class DomWriter extends index_1.XmlWriter {
|
|
|
139
139
|
else {
|
|
140
140
|
setNewline(documentElement.innerXml);
|
|
141
141
|
}
|
|
142
|
-
const html =
|
|
142
|
+
const html = /^(\s*(?:<\?xml[^>]+>\s*)?(?:<!DOCTYPE[^>]+>\s*)?)<html[\s>]/i.exec(source) || /^(.*)<html[\s>]/is.exec(source);
|
|
143
143
|
if (html) {
|
|
144
144
|
const endIndex = index_1.XmlWriter.findCloseTag(source, html.index);
|
|
145
145
|
if (endIndex !== -1) {
|
|
@@ -168,7 +168,7 @@ class DomWriter extends index_1.XmlWriter {
|
|
|
168
168
|
else {
|
|
169
169
|
const trailing = items.filter(item => item.textContent);
|
|
170
170
|
if (trailing.length) {
|
|
171
|
-
const match = /<\/body\s
|
|
171
|
+
const match = /<\/body\s*>\s*<\/html\s*>.*$/is.exec(source) || /<\/body\s*>.*$/is.exec(source);
|
|
172
172
|
if (match) {
|
|
173
173
|
const textContent = trailing.reduce((a, b) => a + b.textContent, '');
|
|
174
174
|
offsetMap = index_1.XmlWriter.getTagOffset(textContent, { ignoreCase: this.ignoreCaseTagName, ignoreTagName: this.ignoreTagName, parser: this.parser });
|
package/parse/index.js
CHANGED
|
@@ -401,10 +401,9 @@ class XmlWriter {
|
|
|
401
401
|
const end = tagGroup[i + 1];
|
|
402
402
|
if (end) {
|
|
403
403
|
pattern = CACHE_TAGNAME[_b = start + end] || (CACHE_TAGNAME[_b] = new RegExp(escapeTagName(start) + '[\\S\\s]*?' + escapeTagName(end), 'g'));
|
|
404
|
-
pattern
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
result.push({ type: 'block', outerXml: match[0], startIndex, endIndex: startIndex + match[0].length - 1 });
|
|
404
|
+
for (const tag of source.matchAll(pattern)) {
|
|
405
|
+
const startIndex = tag.index;
|
|
406
|
+
result.push({ type: 'block', outerXml: tag[0], startIndex, endIndex: startIndex + tag[0].length - 1 });
|
|
408
407
|
}
|
|
409
408
|
}
|
|
410
409
|
}
|
|
@@ -963,9 +962,7 @@ class XmlWriter {
|
|
|
963
962
|
const patternId = XmlWriter.getPatternId(this.nameOfId);
|
|
964
963
|
const flags = ignoreCase ? 'gi' : 'g';
|
|
965
964
|
const pattern = CACHE_TAGNAME[_a = tagName + flags + '3'] || (CACHE_TAGNAME[_a] = new RegExp(`<${escapeTagName(tagName) + PATTERN_TAGOPEN}*>`, flags));
|
|
966
|
-
pattern
|
|
967
|
-
let match;
|
|
968
|
-
while (match = pattern.exec(source)) {
|
|
965
|
+
for (const match of source.matchAll(pattern)) {
|
|
969
966
|
const startIndex = match.index;
|
|
970
967
|
let outerXml = match[0], endIndex = startIndex + outerXml.length - 1;
|
|
971
968
|
if (!invalid || isValidIndex(invalid, startIndex, endIndex)) {
|
|
@@ -1081,15 +1078,15 @@ class XmlElement {
|
|
|
1081
1078
|
this._modified = attrs.size > 0;
|
|
1082
1079
|
if (node.outerXml) {
|
|
1083
1080
|
const [tagStart, innerXml, isVoid] = this.parseOuterXml(node.outerXml, tagVoid);
|
|
1084
|
-
let source = tagStart
|
|
1085
|
-
|
|
1081
|
+
let source = tagStart;
|
|
1082
|
+
for (const match of tagStart.matchAll(REGEXP_ATTRVALUE)) {
|
|
1086
1083
|
const attr = ignoreCase ? match[1].toLowerCase() : match[1];
|
|
1087
1084
|
if (!attrs.has(attr)) {
|
|
1088
1085
|
attrs.set(attr, match[2] || match[3] || match[4] || '');
|
|
1089
1086
|
}
|
|
1090
1087
|
source = source.replace(match[0], '');
|
|
1091
1088
|
}
|
|
1092
|
-
|
|
1089
|
+
for (const match of source.matchAll(REGEXP_ATTRNAME)) {
|
|
1093
1090
|
const attr = ignoreCase ? match[1].toLowerCase() : match[1];
|
|
1094
1091
|
if (!attrs.has(attr)) {
|
|
1095
1092
|
attrs.set(attr, null);
|