ventojs 0.7.1 → 0.7.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.
Files changed (145) hide show
  1. package/esm/_dnt.shims.js +0 -1
  2. package/esm/deps/deno.land/std@0.201.0/assert/assert.d.ts +2 -0
  3. package/esm/deps/deno.land/std@0.201.0/assert/assert.js +8 -0
  4. package/esm/deps/deno.land/std@0.201.0/assert/assertion_error.d.ts +4 -0
  5. package/esm/deps/deno.land/std@0.201.0/assert/assertion_error.js +7 -0
  6. package/esm/deps/deno.land/std@0.201.0/path/_basename.d.ts +16 -0
  7. package/esm/deps/deno.land/std@0.201.0/path/_basename.js +78 -0
  8. package/esm/deps/deno.land/std@0.201.0/path/_dirname.d.ts +10 -0
  9. package/esm/deps/deno.land/std@0.201.0/path/_dirname.js +132 -0
  10. package/esm/deps/deno.land/std@0.201.0/path/_extname.d.ts +12 -0
  11. package/esm/deps/deno.land/std@0.201.0/path/_extname.js +121 -0
  12. package/esm/deps/deno.land/std@0.201.0/path/_format.d.ts +11 -0
  13. package/esm/deps/deno.land/std@0.201.0/path/_format.js +35 -0
  14. package/esm/deps/deno.land/std@0.201.0/path/_from_file_url.d.ts +25 -0
  15. package/esm/deps/deno.land/std@0.201.0/path/_from_file_url.js +46 -0
  16. package/esm/deps/deno.land/std@0.201.0/path/_is_absolute.d.ts +10 -0
  17. package/esm/deps/deno.land/std@0.201.0/path/_is_absolute.js +34 -0
  18. package/esm/deps/deno.land/std@0.201.0/path/_join.d.ts +10 -0
  19. package/esm/deps/deno.land/std@0.201.0/path/_join.js +93 -0
  20. package/esm/deps/deno.land/std@0.201.0/path/_normalize.d.ts +14 -0
  21. package/esm/deps/deno.land/std@0.201.0/path/_normalize.js +153 -0
  22. package/esm/deps/deno.land/std@0.201.0/path/_parse.d.ts +11 -0
  23. package/esm/deps/deno.land/std@0.201.0/path/_parse.js +250 -0
  24. package/esm/deps/deno.land/std@0.201.0/path/_relative.d.ts +19 -0
  25. package/esm/deps/deno.land/std@0.201.0/path/_relative.js +216 -0
  26. package/esm/deps/deno.land/std@0.201.0/path/_resolve.d.ts +10 -0
  27. package/esm/deps/deno.land/std@0.201.0/path/_resolve.js +183 -0
  28. package/esm/deps/deno.land/std@0.201.0/path/_to_file_url.d.ts +25 -0
  29. package/esm/deps/deno.land/std@0.201.0/path/_to_file_url.js +61 -0
  30. package/esm/deps/deno.land/std@0.201.0/path/_to_namespaced_path.d.ts +10 -0
  31. package/esm/deps/deno.land/std@0.201.0/path/_to_namespaced_path.js +46 -0
  32. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_util.d.ts +0 -5
  33. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_util.js +0 -54
  34. package/esm/deps/deno.land/std@0.201.0/path/basename.d.ts +8 -0
  35. package/esm/deps/deno.land/std@0.201.0/path/basename.js +16 -0
  36. package/esm/deps/deno.land/std@0.201.0/path/dirname.d.ts +5 -0
  37. package/esm/deps/deno.land/std@0.201.0/path/dirname.js +11 -0
  38. package/esm/deps/deno.land/std@0.201.0/path/extname.d.ts +6 -0
  39. package/esm/deps/deno.land/std@0.201.0/path/extname.js +12 -0
  40. package/esm/deps/deno.land/std@0.201.0/path/format.d.ts +6 -0
  41. package/esm/deps/deno.land/std@0.201.0/path/format.js +11 -0
  42. package/esm/deps/deno.land/std@0.201.0/path/from_file_url.d.ts +18 -0
  43. package/esm/deps/deno.land/std@0.201.0/path/from_file_url.js +23 -0
  44. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/glob.d.ts +1 -1
  45. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/glob.js +50 -50
  46. package/esm/deps/deno.land/std@0.201.0/path/is_absolute.d.ts +5 -0
  47. package/esm/deps/deno.land/std@0.201.0/path/is_absolute.js +11 -0
  48. package/esm/deps/deno.land/std@0.201.0/path/join.d.ts +5 -0
  49. package/esm/deps/deno.land/std@0.201.0/path/join.js +11 -0
  50. package/esm/deps/deno.land/std@0.201.0/path/mod.d.ts +22 -0
  51. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/mod.js +17 -4
  52. package/esm/deps/deno.land/std@0.201.0/path/normalize.d.ts +7 -0
  53. package/esm/deps/deno.land/std@0.201.0/path/normalize.js +13 -0
  54. package/esm/deps/deno.land/std@0.201.0/path/parse.d.ts +6 -0
  55. package/esm/deps/deno.land/std@0.201.0/path/parse.js +11 -0
  56. package/esm/deps/deno.land/std@0.201.0/path/posix.d.ts +15 -0
  57. package/esm/deps/deno.land/std@0.201.0/path/posix.js +19 -0
  58. package/esm/deps/deno.land/std@0.201.0/path/relative.d.ts +12 -0
  59. package/esm/deps/deno.land/std@0.201.0/path/relative.js +18 -0
  60. package/esm/deps/deno.land/std@0.201.0/path/resolve.d.ts +5 -0
  61. package/esm/deps/deno.land/std@0.201.0/path/resolve.js +13 -0
  62. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/separator.js +1 -1
  63. package/esm/deps/deno.land/std@0.201.0/path/to_file_url.d.ts +18 -0
  64. package/esm/deps/deno.land/std@0.201.0/path/to_file_url.js +23 -0
  65. package/esm/deps/deno.land/std@0.201.0/path/to_namespaced_path.d.ts +5 -0
  66. package/esm/deps/deno.land/std@0.201.0/path/to_namespaced_path.js +13 -0
  67. package/esm/deps/deno.land/std@0.201.0/path/win32.d.ts +15 -0
  68. package/esm/deps/deno.land/std@0.201.0/path/win32.js +19 -0
  69. package/esm/deps.d.ts +1 -1
  70. package/esm/deps.js +1 -1
  71. package/esm/src/environment.js +1 -1
  72. package/package.json +1 -1
  73. package/esm/_dnt.test_polyfills.d.ts +0 -11
  74. package/esm/_dnt.test_shims.d.ts +0 -5
  75. package/esm/deps/deno.land/std@0.178.0/_util/asserts.d.ts +0 -10
  76. package/esm/deps/deno.land/std@0.178.0/_util/asserts.js +0 -21
  77. package/esm/deps/deno.land/std@0.178.0/path/mod.d.ts +0 -9
  78. package/esm/deps/deno.land/std@0.178.0/path/posix.d.ts +0 -86
  79. package/esm/deps/deno.land/std@0.178.0/path/posix.js +0 -442
  80. package/esm/deps/deno.land/std@0.178.0/path/win32.d.ts +0 -91
  81. package/esm/deps/deno.land/std@0.178.0/path/win32.js +0 -909
  82. package/esm/deps/deno.land/std@0.190.0/_util/asserts.d.ts +0 -10
  83. package/esm/deps/deno.land/std@0.190.0/bytes/copy.d.ts +0 -27
  84. package/esm/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
  85. package/esm/deps/deno.land/std@0.190.0/front_matter/mod.d.ts +0 -78
  86. package/esm/deps/deno.land/std@0.190.0/front_matter/yaml.d.ts +0 -4
  87. package/esm/deps/deno.land/std@0.190.0/io/buffer.d.ts +0 -81
  88. package/esm/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
  89. package/esm/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
  90. package/esm/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
  91. package/esm/deps/deno.land/std@0.190.0/yaml/_error.d.ts +0 -6
  92. package/esm/deps/deno.land/std@0.190.0/yaml/_loader/loader.d.ts +0 -4
  93. package/esm/deps/deno.land/std@0.190.0/yaml/_loader/loader_state.d.ts +0 -43
  94. package/esm/deps/deno.land/std@0.190.0/yaml/_mark.d.ts +0 -10
  95. package/esm/deps/deno.land/std@0.190.0/yaml/_state.d.ts +0 -5
  96. package/esm/deps/deno.land/std@0.190.0/yaml/_type/binary.d.ts +0 -2
  97. package/esm/deps/deno.land/std@0.190.0/yaml/_type/bool.d.ts +0 -2
  98. package/esm/deps/deno.land/std@0.190.0/yaml/_type/float.d.ts +0 -2
  99. package/esm/deps/deno.land/std@0.190.0/yaml/_type/function.d.ts +0 -2
  100. package/esm/deps/deno.land/std@0.190.0/yaml/_type/int.d.ts +0 -2
  101. package/esm/deps/deno.land/std@0.190.0/yaml/_type/map.d.ts +0 -2
  102. package/esm/deps/deno.land/std@0.190.0/yaml/_type/merge.d.ts +0 -2
  103. package/esm/deps/deno.land/std@0.190.0/yaml/_type/mod.d.ts +0 -16
  104. package/esm/deps/deno.land/std@0.190.0/yaml/_type/nil.d.ts +0 -2
  105. package/esm/deps/deno.land/std@0.190.0/yaml/_type/omap.d.ts +0 -2
  106. package/esm/deps/deno.land/std@0.190.0/yaml/_type/pairs.d.ts +0 -2
  107. package/esm/deps/deno.land/std@0.190.0/yaml/_type/regexp.d.ts +0 -2
  108. package/esm/deps/deno.land/std@0.190.0/yaml/_type/seq.d.ts +0 -2
  109. package/esm/deps/deno.land/std@0.190.0/yaml/_type/set.d.ts +0 -2
  110. package/esm/deps/deno.land/std@0.190.0/yaml/_type/str.d.ts +0 -2
  111. package/esm/deps/deno.land/std@0.190.0/yaml/_type/timestamp.d.ts +0 -2
  112. package/esm/deps/deno.land/std@0.190.0/yaml/_type/undefined.d.ts +0 -2
  113. package/esm/deps/deno.land/std@0.190.0/yaml/_utils.d.ts +0 -19
  114. package/esm/deps/deno.land/std@0.190.0/yaml/parse.d.ts +0 -35
  115. package/esm/deps/deno.land/std@0.190.0/yaml/schema/core.d.ts +0 -2
  116. package/esm/deps/deno.land/std@0.190.0/yaml/schema/default.d.ts +0 -2
  117. package/esm/deps/deno.land/std@0.190.0/yaml/schema/extended.d.ts +0 -30
  118. package/esm/deps/deno.land/std@0.190.0/yaml/schema/failsafe.d.ts +0 -2
  119. package/esm/deps/deno.land/std@0.190.0/yaml/schema/json.d.ts +0 -2
  120. package/esm/deps/deno.land/std@0.190.0/yaml/schema/mod.d.ts +0 -5
  121. package/esm/deps/deno.land/std@0.190.0/yaml/schema.d.ts +0 -22
  122. package/esm/deps/deno.land/std@0.190.0/yaml/type.d.ts +0 -28
  123. package/esm/test/comment.test.d.ts +0 -1
  124. package/esm/test/escape.test.d.ts +0 -1
  125. package/esm/test/for.test.d.ts +0 -1
  126. package/esm/test/function.test.d.ts +0 -1
  127. package/esm/test/if.test.d.ts +0 -1
  128. package/esm/test/import.test.d.ts +0 -1
  129. package/esm/test/include.test.d.ts +0 -1
  130. package/esm/test/js.test.d.ts +0 -1
  131. package/esm/test/layout.test.d.ts +0 -1
  132. package/esm/test/print.test.d.ts +0 -1
  133. package/esm/test/raw.test.d.ts +0 -1
  134. package/esm/test/set.test.d.ts +0 -1
  135. package/esm/test/tokenizer.test.d.ts +0 -1
  136. package/esm/test/utils.d.ts +0 -24
  137. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_constants.d.ts +0 -0
  138. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_constants.js +0 -0
  139. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_interface.d.ts +0 -0
  140. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_interface.js +0 -0
  141. /package/esm/deps/deno.land/{std@0.178.0/_util/os.d.ts → std@0.201.0/path/_os.d.ts} +0 -0
  142. /package/esm/deps/deno.land/{std@0.178.0/_util/os.js → std@0.201.0/path/_os.js} +0 -0
  143. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/common.d.ts +0 -0
  144. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/common.js +0 -0
  145. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/separator.d.ts +0 -0
@@ -0,0 +1,93 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { assert } from "../assert/assert.js";
4
+ import { assertPath, isPathSeparator } from "./_util.js";
5
+ import { posixNormalize, windowsNormalize } from "./_normalize.js";
6
+ /**
7
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
8
+ * @param paths to be joined and normalized
9
+ */
10
+ export function posixJoin(...paths) {
11
+ if (paths.length === 0)
12
+ return ".";
13
+ let joined;
14
+ for (let i = 0, len = paths.length; i < len; ++i) {
15
+ const path = paths[i];
16
+ assertPath(path);
17
+ if (path.length > 0) {
18
+ if (!joined)
19
+ joined = path;
20
+ else
21
+ joined += `/${path}`;
22
+ }
23
+ }
24
+ if (!joined)
25
+ return ".";
26
+ return posixNormalize(joined);
27
+ }
28
+ /**
29
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
30
+ * @param paths to be joined and normalized
31
+ */
32
+ export function windowsJoin(...paths) {
33
+ if (paths.length === 0)
34
+ return ".";
35
+ let joined;
36
+ let firstPart = null;
37
+ for (let i = 0; i < paths.length; ++i) {
38
+ const path = paths[i];
39
+ assertPath(path);
40
+ if (path.length > 0) {
41
+ if (joined === undefined)
42
+ joined = firstPart = path;
43
+ else
44
+ joined += `\\${path}`;
45
+ }
46
+ }
47
+ if (joined === undefined)
48
+ return ".";
49
+ // Make sure that the joined path doesn't start with two slashes, because
50
+ // normalize() will mistake it for an UNC path then.
51
+ //
52
+ // This step is skipped when it is very clear that the user actually
53
+ // intended to point at an UNC path. This is assumed when the first
54
+ // non-empty string arguments starts with exactly two slashes followed by
55
+ // at least one more non-slash character.
56
+ //
57
+ // Note that for normalize() to treat a path as an UNC path it needs to
58
+ // have at least 2 components, so we don't filter for that here.
59
+ // This means that the user can use join to construct UNC paths from
60
+ // a server name and a share name; for example:
61
+ // path.join('//server', 'share') -> '\\\\server\\share\\')
62
+ let needsReplace = true;
63
+ let slashCount = 0;
64
+ assert(firstPart !== null);
65
+ if (isPathSeparator(firstPart.charCodeAt(0))) {
66
+ ++slashCount;
67
+ const firstLen = firstPart.length;
68
+ if (firstLen > 1) {
69
+ if (isPathSeparator(firstPart.charCodeAt(1))) {
70
+ ++slashCount;
71
+ if (firstLen > 2) {
72
+ if (isPathSeparator(firstPart.charCodeAt(2)))
73
+ ++slashCount;
74
+ else {
75
+ // We matched a UNC path in the first part
76
+ needsReplace = false;
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ if (needsReplace) {
83
+ // Find any more consecutive slashes we need to replace
84
+ for (; slashCount < joined.length; ++slashCount) {
85
+ if (!isPathSeparator(joined.charCodeAt(slashCount)))
86
+ break;
87
+ }
88
+ // Replace the slashes if needed
89
+ if (slashCount >= 2)
90
+ joined = `\\${joined.slice(slashCount)}`;
91
+ }
92
+ return windowsNormalize(joined);
93
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
3
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
4
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
5
+ * @param path to be normalized
6
+ */
7
+ export declare function posixNormalize(path: string): string;
8
+ /**
9
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
10
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
11
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
12
+ * @param path to be normalized
13
+ */
14
+ export declare function windowsNormalize(path: string): string;
@@ -0,0 +1,153 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { CHAR_COLON } from "./_constants.js";
4
+ import { assertPath, isPathSeparator, isPosixPathSeparator, isWindowsDeviceRoot, normalizeString, } from "./_util.js";
5
+ function assertArg(path) {
6
+ assertPath(path);
7
+ if (path.length === 0)
8
+ return ".";
9
+ }
10
+ /**
11
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
12
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
13
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
14
+ * @param path to be normalized
15
+ */
16
+ export function posixNormalize(path) {
17
+ assertArg(path);
18
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
19
+ const trailingSeparator = isPosixPathSeparator(path.charCodeAt(path.length - 1));
20
+ // Normalize the path
21
+ path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
22
+ if (path.length === 0 && !isAbsolute)
23
+ path = ".";
24
+ if (path.length > 0 && trailingSeparator)
25
+ path += "/";
26
+ if (isAbsolute)
27
+ return `/${path}`;
28
+ return path;
29
+ }
30
+ /**
31
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
32
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
33
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
34
+ * @param path to be normalized
35
+ */
36
+ export function windowsNormalize(path) {
37
+ assertArg(path);
38
+ const len = path.length;
39
+ let rootEnd = 0;
40
+ let device;
41
+ let isAbsolute = false;
42
+ const code = path.charCodeAt(0);
43
+ // Try to match a root
44
+ if (len > 1) {
45
+ if (isPathSeparator(code)) {
46
+ // Possible UNC root
47
+ // If we started with a separator, we know we at least have an absolute
48
+ // path of some kind (UNC or otherwise)
49
+ isAbsolute = true;
50
+ if (isPathSeparator(path.charCodeAt(1))) {
51
+ // Matched double path separator at beginning
52
+ let j = 2;
53
+ let last = j;
54
+ // Match 1 or more non-path separators
55
+ for (; j < len; ++j) {
56
+ if (isPathSeparator(path.charCodeAt(j)))
57
+ break;
58
+ }
59
+ if (j < len && j !== last) {
60
+ const firstPart = path.slice(last, j);
61
+ // Matched!
62
+ last = j;
63
+ // Match 1 or more path separators
64
+ for (; j < len; ++j) {
65
+ if (!isPathSeparator(path.charCodeAt(j)))
66
+ break;
67
+ }
68
+ if (j < len && j !== last) {
69
+ // Matched!
70
+ last = j;
71
+ // Match 1 or more non-path separators
72
+ for (; j < len; ++j) {
73
+ if (isPathSeparator(path.charCodeAt(j)))
74
+ break;
75
+ }
76
+ if (j === len) {
77
+ // We matched a UNC root only
78
+ // Return the normalized version of the UNC root since there
79
+ // is nothing left to process
80
+ return `\\\\${firstPart}\\${path.slice(last)}\\`;
81
+ }
82
+ else if (j !== last) {
83
+ // We matched a UNC root with leftovers
84
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
85
+ rootEnd = j;
86
+ }
87
+ }
88
+ }
89
+ }
90
+ else {
91
+ rootEnd = 1;
92
+ }
93
+ }
94
+ else if (isWindowsDeviceRoot(code)) {
95
+ // Possible device root
96
+ if (path.charCodeAt(1) === CHAR_COLON) {
97
+ device = path.slice(0, 2);
98
+ rootEnd = 2;
99
+ if (len > 2) {
100
+ if (isPathSeparator(path.charCodeAt(2))) {
101
+ // Treat separator following drive name as an absolute path
102
+ // indicator
103
+ isAbsolute = true;
104
+ rootEnd = 3;
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+ else if (isPathSeparator(code)) {
111
+ // `path` contains just a path separator, exit early to avoid unnecessary
112
+ // work
113
+ return "\\";
114
+ }
115
+ let tail;
116
+ if (rootEnd < len) {
117
+ tail = normalizeString(path.slice(rootEnd), !isAbsolute, "\\", isPathSeparator);
118
+ }
119
+ else {
120
+ tail = "";
121
+ }
122
+ if (tail.length === 0 && !isAbsolute)
123
+ tail = ".";
124
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
125
+ tail += "\\";
126
+ }
127
+ if (device === undefined) {
128
+ if (isAbsolute) {
129
+ if (tail.length > 0)
130
+ return `\\${tail}`;
131
+ else
132
+ return "\\";
133
+ }
134
+ else if (tail.length > 0) {
135
+ return tail;
136
+ }
137
+ else {
138
+ return "";
139
+ }
140
+ }
141
+ else if (isAbsolute) {
142
+ if (tail.length > 0)
143
+ return `${device}\\${tail}`;
144
+ else
145
+ return `${device}\\`;
146
+ }
147
+ else if (tail.length > 0) {
148
+ return device + tail;
149
+ }
150
+ else {
151
+ return device;
152
+ }
153
+ }
@@ -0,0 +1,11 @@
1
+ import { ParsedPath } from "./_interface.js";
2
+ /**
3
+ * Return a `ParsedPath` object of the `path`.
4
+ * @param path to process
5
+ */
6
+ export declare function posixParse(path: string): ParsedPath;
7
+ /**
8
+ * Return a `ParsedPath` object of the `path`.
9
+ * @param path to process
10
+ */
11
+ export declare function windowsParse(path: string): ParsedPath;
@@ -0,0 +1,250 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { CHAR_COLON, CHAR_DOT } from "./_constants.js";
4
+ import { assertPath, isPathSeparator, isPosixPathSeparator, isWindowsDeviceRoot, stripTrailingSeparators, } from "./_util.js";
5
+ /**
6
+ * Return a `ParsedPath` object of the `path`.
7
+ * @param path to process
8
+ */
9
+ export function posixParse(path) {
10
+ assertPath(path);
11
+ const ret = { root: "", dir: "", base: "", ext: "", name: "" };
12
+ if (path.length === 0)
13
+ return ret;
14
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
15
+ let start;
16
+ if (isAbsolute) {
17
+ ret.root = "/";
18
+ start = 1;
19
+ }
20
+ else {
21
+ start = 0;
22
+ }
23
+ let startDot = -1;
24
+ let startPart = 0;
25
+ let end = -1;
26
+ let matchedSlash = true;
27
+ let i = path.length - 1;
28
+ // Track the state of characters (if any) we see before our first dot and
29
+ // after any path separator we find
30
+ let preDotState = 0;
31
+ // Get non-dir info
32
+ for (; i >= start; --i) {
33
+ const code = path.charCodeAt(i);
34
+ if (isPosixPathSeparator(code)) {
35
+ // If we reached a path separator that was not part of a set of path
36
+ // separators at the end of the string, stop now
37
+ if (!matchedSlash) {
38
+ startPart = i + 1;
39
+ break;
40
+ }
41
+ continue;
42
+ }
43
+ if (end === -1) {
44
+ // We saw the first non-path separator, mark this as the end of our
45
+ // extension
46
+ matchedSlash = false;
47
+ end = i + 1;
48
+ }
49
+ if (code === CHAR_DOT) {
50
+ // If this is our first dot, mark it as the start of our extension
51
+ if (startDot === -1)
52
+ startDot = i;
53
+ else if (preDotState !== 1)
54
+ preDotState = 1;
55
+ }
56
+ else if (startDot !== -1) {
57
+ // We saw a non-dot and non-path separator before our dot, so we should
58
+ // have a good chance at having a non-empty extension
59
+ preDotState = -1;
60
+ }
61
+ }
62
+ if (startDot === -1 ||
63
+ end === -1 ||
64
+ // We saw a non-dot character immediately before the dot
65
+ preDotState === 0 ||
66
+ // The (right-most) trimmed path component is exactly '..'
67
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
68
+ if (end !== -1) {
69
+ if (startPart === 0 && isAbsolute) {
70
+ ret.base = ret.name = path.slice(1, end);
71
+ }
72
+ else {
73
+ ret.base = ret.name = path.slice(startPart, end);
74
+ }
75
+ }
76
+ // Fallback to '/' in case there is no basename
77
+ ret.base = ret.base || "/";
78
+ }
79
+ else {
80
+ if (startPart === 0 && isAbsolute) {
81
+ ret.name = path.slice(1, startDot);
82
+ ret.base = path.slice(1, end);
83
+ }
84
+ else {
85
+ ret.name = path.slice(startPart, startDot);
86
+ ret.base = path.slice(startPart, end);
87
+ }
88
+ ret.ext = path.slice(startDot, end);
89
+ }
90
+ if (startPart > 0) {
91
+ ret.dir = stripTrailingSeparators(path.slice(0, startPart - 1), isPosixPathSeparator);
92
+ }
93
+ else if (isAbsolute)
94
+ ret.dir = "/";
95
+ return ret;
96
+ }
97
+ /**
98
+ * Return a `ParsedPath` object of the `path`.
99
+ * @param path to process
100
+ */
101
+ export function windowsParse(path) {
102
+ assertPath(path);
103
+ const ret = { root: "", dir: "", base: "", ext: "", name: "" };
104
+ const len = path.length;
105
+ if (len === 0)
106
+ return ret;
107
+ let rootEnd = 0;
108
+ let code = path.charCodeAt(0);
109
+ // Try to match a root
110
+ if (len > 1) {
111
+ if (isPathSeparator(code)) {
112
+ // Possible UNC root
113
+ rootEnd = 1;
114
+ if (isPathSeparator(path.charCodeAt(1))) {
115
+ // Matched double path separator at beginning
116
+ let j = 2;
117
+ let last = j;
118
+ // Match 1 or more non-path separators
119
+ for (; j < len; ++j) {
120
+ if (isPathSeparator(path.charCodeAt(j)))
121
+ break;
122
+ }
123
+ if (j < len && j !== last) {
124
+ // Matched!
125
+ last = j;
126
+ // Match 1 or more path separators
127
+ for (; j < len; ++j) {
128
+ if (!isPathSeparator(path.charCodeAt(j)))
129
+ break;
130
+ }
131
+ if (j < len && j !== last) {
132
+ // Matched!
133
+ last = j;
134
+ // Match 1 or more non-path separators
135
+ for (; j < len; ++j) {
136
+ if (isPathSeparator(path.charCodeAt(j)))
137
+ break;
138
+ }
139
+ if (j === len) {
140
+ // We matched a UNC root only
141
+ rootEnd = j;
142
+ }
143
+ else if (j !== last) {
144
+ // We matched a UNC root with leftovers
145
+ rootEnd = j + 1;
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ else if (isWindowsDeviceRoot(code)) {
152
+ // Possible device root
153
+ if (path.charCodeAt(1) === CHAR_COLON) {
154
+ rootEnd = 2;
155
+ if (len > 2) {
156
+ if (isPathSeparator(path.charCodeAt(2))) {
157
+ if (len === 3) {
158
+ // `path` contains just a drive root, exit early to avoid
159
+ // unnecessary work
160
+ ret.root = ret.dir = path;
161
+ ret.base = "\\";
162
+ return ret;
163
+ }
164
+ rootEnd = 3;
165
+ }
166
+ }
167
+ else {
168
+ // `path` contains just a relative drive root, exit early to avoid
169
+ // unnecessary work
170
+ ret.root = ret.dir = path;
171
+ return ret;
172
+ }
173
+ }
174
+ }
175
+ }
176
+ else if (isPathSeparator(code)) {
177
+ // `path` contains just a path separator, exit early to avoid
178
+ // unnecessary work
179
+ ret.root = ret.dir = path;
180
+ ret.base = "\\";
181
+ return ret;
182
+ }
183
+ if (rootEnd > 0)
184
+ ret.root = path.slice(0, rootEnd);
185
+ let startDot = -1;
186
+ let startPart = rootEnd;
187
+ let end = -1;
188
+ let matchedSlash = true;
189
+ let i = path.length - 1;
190
+ // Track the state of characters (if any) we see before our first dot and
191
+ // after any path separator we find
192
+ let preDotState = 0;
193
+ // Get non-dir info
194
+ for (; i >= rootEnd; --i) {
195
+ code = path.charCodeAt(i);
196
+ if (isPathSeparator(code)) {
197
+ // If we reached a path separator that was not part of a set of path
198
+ // separators at the end of the string, stop now
199
+ if (!matchedSlash) {
200
+ startPart = i + 1;
201
+ break;
202
+ }
203
+ continue;
204
+ }
205
+ if (end === -1) {
206
+ // We saw the first non-path separator, mark this as the end of our
207
+ // extension
208
+ matchedSlash = false;
209
+ end = i + 1;
210
+ }
211
+ if (code === CHAR_DOT) {
212
+ // If this is our first dot, mark it as the start of our extension
213
+ if (startDot === -1)
214
+ startDot = i;
215
+ else if (preDotState !== 1)
216
+ preDotState = 1;
217
+ }
218
+ else if (startDot !== -1) {
219
+ // We saw a non-dot and non-path separator before our dot, so we should
220
+ // have a good chance at having a non-empty extension
221
+ preDotState = -1;
222
+ }
223
+ }
224
+ if (startDot === -1 ||
225
+ end === -1 ||
226
+ // We saw a non-dot character immediately before the dot
227
+ preDotState === 0 ||
228
+ // The (right-most) trimmed path component is exactly '..'
229
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
230
+ if (end !== -1) {
231
+ ret.base = ret.name = path.slice(startPart, end);
232
+ }
233
+ }
234
+ else {
235
+ ret.name = path.slice(startPart, startDot);
236
+ ret.base = path.slice(startPart, end);
237
+ ret.ext = path.slice(startDot, end);
238
+ }
239
+ // Fallback to '\' in case there is no basename
240
+ ret.base = ret.base || "\\";
241
+ // If the directory is the root, use the entire root as the `dir` including
242
+ // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
243
+ // trailing slash (`C:\abc\def` -> `C:\abc`).
244
+ if (startPart > 0 && startPart !== rootEnd) {
245
+ ret.dir = path.slice(0, startPart - 1);
246
+ }
247
+ else
248
+ ret.dir = ret.root;
249
+ return ret;
250
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Return the relative path from `from` to `to` based on current working directory.
3
+ *
4
+ * @param from path in current working directory
5
+ * @param to path in current working directory
6
+ */
7
+ export declare function posixRelative(from: string, to: string): string;
8
+ /**
9
+ * Return the relative path from `from` to `to` based on current working directory.
10
+ *
11
+ * An example in windws, for instance:
12
+ * from = 'C:\\orandea\\test\\aaa'
13
+ * to = 'C:\\orandea\\impl\\bbb'
14
+ * The output of the function should be: '..\\..\\impl\\bbb'
15
+ *
16
+ * @param from path in current working directory
17
+ * @param to path in current working directory
18
+ */
19
+ export declare function windowsRelative(from: string, to: string): string;