@e-mc/document 0.9.18 → 0.9.20

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,7 @@
1
- Copyright 2024 An Pham
1
+ Copyright 2025 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
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
- 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.9.18/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.20/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.18/lib/squared.d.ts
187
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/asset.d.ts
188
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/core.d.ts
189
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/document.d.ts
190
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/filemanager.d.ts
191
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/logger.d.ts
192
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/settings.d.ts
193
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/watch.d.ts
186
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/squared.d.ts
187
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/asset.d.ts
188
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/core.d.ts
189
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/document.d.ts
190
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/filemanager.d.ts
191
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/logger.d.ts
192
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/settings.d.ts
193
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/watch.d.ts
194
194
 
195
195
  ## LICENSE
196
196
 
package/index.js CHANGED
@@ -737,7 +737,7 @@ class Document extends core_1.Client {
737
737
  if (!(0, types_1.isPlainObject)(imports)) {
738
738
  return;
739
739
  }
740
- const toPosix = (value) => value.replace(/(?:^\\|\\+)/g, '/');
740
+ const toPosix = (value) => PLATFORM_WIN32 ? value.trim().replace(/(?:^\\|\\+)/g, '/') : value;
741
741
  const normalizeDir = (value, check) => {
742
742
  const sep = !check && value.includes('\\') && !value.includes('/') ? '\\' : '/';
743
743
  if (check) {
@@ -747,34 +747,33 @@ class Document extends core_1.Client {
747
747
  };
748
748
  const importsStrict = this.getUserSettings()?.imports_strict ?? this.settings.imports_strict;
749
749
  const scopes = (importsStrict ? this.findSourceScope(uri, imports) : []).concat([imports]);
750
- const isDir = /[\\/]$/;
750
+ const protocol = core_1.Client.isURL(uri);
751
751
  let result;
752
752
  for (const scope of scopes) {
753
753
  for (const url in scope) {
754
754
  if (uri === url && (0, types_1.isString)(result = scope[url])) {
755
755
  if (importsStrict) {
756
- if (isDir.test(url) || !core_1.Client.isPath(result)) {
757
- continue;
756
+ if (core_1.Client.isPath(result) && !(protocol ? url : toPosix(url)).endsWith('/')) {
757
+ return toPosix(result);
758
758
  }
759
- return toPosix(result);
759
+ continue;
760
760
  }
761
761
  return result;
762
762
  }
763
763
  }
764
764
  }
765
- const remote = toPosix(uri);
766
765
  const found = [];
767
766
  if (importsStrict) {
768
- const protocol = core_1.Client.isURL(remote);
767
+ const remote = protocol ? uri : toPosix(uri);
769
768
  for (const scope of scopes) {
770
769
  for (const url in scope) {
771
770
  const local = protocol ? url : toPosix(url);
772
- if (isDir.test(local) && remote.startsWith(local) && (result = scope[url]) && isDir.test(result)) {
771
+ if (local.endsWith('/') && remote.startsWith(local) && (result = scope[url]) && result.endsWith('/')) {
773
772
  if (protocol) {
774
773
  found.push([url, result]);
775
774
  }
776
775
  else if (core_1.Client.isPath(result = path.join(result, remote.substring(local.length)))) {
777
- return PLATFORM_WIN32 ? toPosix(result) : result;
776
+ return toPosix(result);
778
777
  }
779
778
  }
780
779
  }
@@ -810,7 +809,7 @@ class Document extends core_1.Client {
810
809
  result = toPath(found[0]);
811
810
  }
812
811
  if (result) {
813
- return PLATFORM_WIN32 ? toPosix(result) : result;
812
+ return toPosix(result);
814
813
  }
815
814
  }
816
815
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/document",
3
- "version": "0.9.18",
3
+ "version": "0.9.20",
4
4
  "description": "Document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,12 +17,12 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD-3-Clause",
20
+ "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.9.18",
24
- "@e-mc/db": "0.9.18",
25
- "@e-mc/types": "0.9.18",
23
+ "@e-mc/core": "0.9.20",
24
+ "@e-mc/db": "0.9.20",
25
+ "@e-mc/types": "0.9.20",
26
26
  "chalk": "4.1.2",
27
27
  "domhandler": "^5.0.3",
28
28
  "domutils": "^3.1.0",
package/util.js CHANGED
@@ -215,7 +215,7 @@ function hasValue(target, ...values) {
215
215
  }
216
216
  exports.hasValue = hasValue;
217
217
  function getModuleName(err) {
218
- const match = err instanceof Error && /Cannot find module '([^']+)'/.exec(err.message);
218
+ const match = err instanceof Error && /Cannot find (?:module|package) '([^']+)'/.exec(err.message);
219
219
  if (match) {
220
220
  return match[1];
221
221
  }