@e-mc/document 0.9.0 → 0.9.2

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 CHANGED
@@ -1,11 +1,11 @@
1
- Copyright 2024 An Pham
2
-
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
-
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
-
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
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
-
1
+ Copyright 2024 An Pham
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
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
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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/document
2
2
 
3
- * NodeJS 14/16
3
+ * NodeJS 16
4
4
  * ES2020
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.9.0/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.2/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, ViewEngine } from "./squared";
@@ -181,32 +181,16 @@ instance.init(assets);
181
181
 
182
182
  NOTE: **@e-mc/document** is an abstract base class and cannot be instantiated. **Document** is more commonly called through [@pi-r/chrome](https://www.npmjs.com/package/@pi-r/chrome).
183
183
 
184
- ## NodeJS 14 LTS
185
-
186
- Any optional fail safe dependencies were removed as of `E-mc 0.9`. The code itself will still be *ES2020* and will continue to work equivalently when self-installing these dependencies:
187
-
188
- ### Under 15.4 + 16.0
189
-
190
- ```sh
191
- npm i abort-controller event-target-shim
192
- ```
193
-
194
- ### Under 14.17 + 15.6
195
-
196
- ```sh
197
- npm i uuid
198
- ```
199
-
200
184
  ## References
201
185
 
202
- - https://www.unpkg.com/@e-mc/types@0.9.0/lib/squared.d.ts
203
- - https://www.unpkg.com/@e-mc/types@0.9.0/lib/asset.d.ts
204
- - https://www.unpkg.com/@e-mc/types@0.9.0/lib/core.d.ts
205
- - https://www.unpkg.com/@e-mc/types@0.9.0/lib/document.d.ts
206
- - https://www.unpkg.com/@e-mc/types@0.9.0/lib/filemanager.d.ts
207
- - https://www.unpkg.com/@e-mc/types@0.9.0/lib/logger.d.ts
208
- - https://www.unpkg.com/@e-mc/types@0.9.0/lib/settings.d.ts
209
- - https://www.unpkg.com/@e-mc/types@0.9.0/lib/watch.d.ts
186
+ - https://www.unpkg.com/@e-mc/types@0.9.2/lib/squared.d.ts
187
+ - https://www.unpkg.com/@e-mc/types@0.9.2/lib/asset.d.ts
188
+ - https://www.unpkg.com/@e-mc/types@0.9.2/lib/core.d.ts
189
+ - https://www.unpkg.com/@e-mc/types@0.9.2/lib/document.d.ts
190
+ - https://www.unpkg.com/@e-mc/types@0.9.2/lib/filemanager.d.ts
191
+ - https://www.unpkg.com/@e-mc/types@0.9.2/lib/logger.d.ts
192
+ - https://www.unpkg.com/@e-mc/types@0.9.2/lib/settings.d.ts
193
+ - https://www.unpkg.com/@e-mc/types@0.9.2/lib/watch.d.ts
210
194
 
211
195
  ## LICENSE
212
196
 
package/asset.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { ExternalAsset, InitialValue } from '../types/lib/asset';
2
-
3
- declare namespace asset {
4
- function isEqual(item: ExternalAsset, other: ExternalAsset): boolean;
5
- function setInitialValue(file: ExternalAsset, cacheable?: boolean): InitialValue;
6
- }
7
-
1
+ import type { ExternalAsset, InitialValue } from '../types/lib/asset';
2
+
3
+ declare namespace asset {
4
+ function isEqual(item: ExternalAsset, other: ExternalAsset): boolean;
5
+ function setInitialValue(file: ExternalAsset, cacheable?: boolean): InitialValue;
6
+ }
7
+
8
8
  export = asset;
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { DocumentConstructor, IFileManager } from '../types/lib';
2
-
3
- declare const Document: DocumentConstructor<IFileManager>;
4
-
1
+ import type { DocumentConstructor, IFileManager } from '../types/lib';
2
+
3
+ declare const Document: DocumentConstructor<IFileManager>;
4
+
5
5
  export = Document;
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
- return this._imports || (this._imports = {});
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.0",
3
+ "version": "0.9.2",
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.0",
24
- "@e-mc/db": "0.9.0",
25
- "@e-mc/types": "0.9.0",
23
+ "@e-mc/core": "0.9.2",
24
+ "@e-mc/db": "0.9.2",
25
+ "@e-mc/types": "0.9.2",
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 = /<html[\s>]/i.exec(source);
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*>/i.exec(source);
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.lastIndex = 0;
405
- while (match = pattern.exec(source)) {
406
- const startIndex = match.index;
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.lastIndex = 0;
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, match;
1085
- while (match = REGEXP_ATTRVALUE.exec(tagStart)) {
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
- while (match = REGEXP_ATTRNAME.exec(source)) {
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);
@@ -1,8 +1,8 @@
1
- import type { SourceMapConstructor, TransformSeriesConstructor } from '../../types/lib/document';
2
-
3
- declare namespace transform {
4
- const TransformSeries: TransformSeriesConstructor;
5
- const SourceMap: SourceMapConstructor;
6
- }
7
-
1
+ import type { SourceMapConstructor, TransformSeriesConstructor } from '../../types/lib/document';
2
+
3
+ declare namespace transform {
4
+ const TransformSeries: TransformSeriesConstructor;
5
+ const SourceMap: SourceMapConstructor;
6
+ }
7
+
8
8
  export = transform;