@gjsify/path 0.3.12 → 0.3.14
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/lib/esm/_virtual/_rolldown/runtime.js +18 -0
- package/lib/esm/constants.js +4 -11
- package/lib/esm/index.js +24 -51
- package/lib/esm/posix.js +316 -312
- package/lib/esm/util.js +92 -99
- package/lib/esm/win32.js +549 -549
- package/package.json +3 -3
package/lib/esm/win32.js
CHANGED
|
@@ -1,573 +1,573 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { CHAR_BACKWARD_SLASH, CHAR_COLON, CHAR_DOT } from "./constants.js";
|
|
3
|
+
import { _format, assertPath, isPathSeparator, isWindowsDeviceRoot, normalizeString } from "./util.js";
|
|
4
|
+
|
|
5
|
+
//#region src/win32.ts
|
|
6
|
+
var win32_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
basename: () => basename,
|
|
8
|
+
delimiter: () => ";",
|
|
9
|
+
dirname: () => dirname,
|
|
10
|
+
extname: () => extname,
|
|
11
|
+
format: () => format,
|
|
12
|
+
isAbsolute: () => isAbsolute,
|
|
13
|
+
join: () => join,
|
|
14
|
+
normalize: () => normalize,
|
|
15
|
+
parse: () => parse,
|
|
16
|
+
relative: () => relative,
|
|
17
|
+
resolve: () => resolve,
|
|
18
|
+
sep: () => "\\",
|
|
19
|
+
toNamespacedPath: () => toNamespacedPath
|
|
20
|
+
});
|
|
13
21
|
const sep = "\\";
|
|
14
22
|
const delimiter = ";";
|
|
15
23
|
function resolve(...pathSegments) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
24
|
+
let resolvedDevice = "";
|
|
25
|
+
let resolvedTail = "";
|
|
26
|
+
let resolvedAbsolute = false;
|
|
27
|
+
for (let i = pathSegments.length - 1; i >= -1; i--) {
|
|
28
|
+
let path;
|
|
29
|
+
if (i >= 0) {
|
|
30
|
+
path = pathSegments[i];
|
|
31
|
+
assertPath(path);
|
|
32
|
+
if (path.length === 0) continue;
|
|
33
|
+
} else if (resolvedDevice.length === 0) {
|
|
34
|
+
path = typeof globalThis.process?.cwd === "function" ? globalThis.process.cwd() : "/";
|
|
35
|
+
} else {
|
|
36
|
+
path = typeof globalThis.process?.cwd === "function" ? globalThis.process.cwd() : "/";
|
|
37
|
+
}
|
|
38
|
+
const len = path.length;
|
|
39
|
+
let rootEnd = 0;
|
|
40
|
+
let device = "";
|
|
41
|
+
let isAbsolutePath = false;
|
|
42
|
+
const code = path.charCodeAt(0);
|
|
43
|
+
if (len > 1) {
|
|
44
|
+
if (isPathSeparator(code)) {
|
|
45
|
+
isAbsolutePath = true;
|
|
46
|
+
if (isPathSeparator(path.charCodeAt(1))) {
|
|
47
|
+
let j = 2;
|
|
48
|
+
let last = j;
|
|
49
|
+
for (; j < len; ++j) {
|
|
50
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
51
|
+
}
|
|
52
|
+
if (j < len && j !== last) {
|
|
53
|
+
const firstPart = path.slice(last, j);
|
|
54
|
+
last = j;
|
|
55
|
+
for (; j < len; ++j) {
|
|
56
|
+
if (!isPathSeparator(path.charCodeAt(j))) break;
|
|
57
|
+
}
|
|
58
|
+
if (j < len && j !== last) {
|
|
59
|
+
last = j;
|
|
60
|
+
for (; j < len; ++j) {
|
|
61
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
62
|
+
}
|
|
63
|
+
if (j === len) {
|
|
64
|
+
device = `\\\\${firstPart}\\${path.slice(last)}`;
|
|
65
|
+
rootEnd = j;
|
|
66
|
+
} else if (j !== last) {
|
|
67
|
+
device = `\\\\${firstPart}\\${path.slice(last, j)}`;
|
|
68
|
+
rootEnd = j;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
rootEnd = 1;
|
|
74
|
+
}
|
|
75
|
+
} else if (isWindowsDeviceRoot(code)) {
|
|
76
|
+
if (path.charCodeAt(1) === 58) {
|
|
77
|
+
device = path.slice(0, 2);
|
|
78
|
+
rootEnd = 2;
|
|
79
|
+
if (len > 2) {
|
|
80
|
+
if (isPathSeparator(path.charCodeAt(2))) {
|
|
81
|
+
isAbsolutePath = true;
|
|
82
|
+
rootEnd = 3;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} else if (isPathSeparator(code)) {
|
|
88
|
+
rootEnd = 1;
|
|
89
|
+
isAbsolutePath = true;
|
|
90
|
+
}
|
|
91
|
+
if (device.length > 0 && resolvedDevice.length > 0 && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (resolvedDevice.length === 0 && device.length > 0) {
|
|
95
|
+
resolvedDevice = device;
|
|
96
|
+
}
|
|
97
|
+
if (!resolvedAbsolute) {
|
|
98
|
+
resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
|
|
99
|
+
resolvedAbsolute = isAbsolutePath;
|
|
100
|
+
}
|
|
101
|
+
if (resolvedDevice.length > 0 && resolvedAbsolute) {
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
|
|
106
|
+
return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
|
|
99
107
|
}
|
|
100
108
|
function normalize(path) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
109
|
+
assertPath(path);
|
|
110
|
+
const len = path.length;
|
|
111
|
+
if (len === 0) return ".";
|
|
112
|
+
let rootEnd = 0;
|
|
113
|
+
let device;
|
|
114
|
+
let isAbsolutePath = false;
|
|
115
|
+
const code = path.charCodeAt(0);
|
|
116
|
+
if (len > 1) {
|
|
117
|
+
if (isPathSeparator(code)) {
|
|
118
|
+
isAbsolutePath = true;
|
|
119
|
+
if (isPathSeparator(path.charCodeAt(1))) {
|
|
120
|
+
let j = 2;
|
|
121
|
+
let last = j;
|
|
122
|
+
for (; j < len; ++j) {
|
|
123
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
124
|
+
}
|
|
125
|
+
if (j < len && j !== last) {
|
|
126
|
+
const firstPart = path.slice(last, j);
|
|
127
|
+
last = j;
|
|
128
|
+
for (; j < len; ++j) {
|
|
129
|
+
if (!isPathSeparator(path.charCodeAt(j))) break;
|
|
130
|
+
}
|
|
131
|
+
if (j < len && j !== last) {
|
|
132
|
+
last = j;
|
|
133
|
+
for (; j < len; ++j) {
|
|
134
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
135
|
+
}
|
|
136
|
+
if (j === len) {
|
|
137
|
+
return `\\\\${firstPart}\\${path.slice(last)}\\`;
|
|
138
|
+
} else if (j !== last) {
|
|
139
|
+
device = `\\\\${firstPart}\\${path.slice(last, j)}`;
|
|
140
|
+
rootEnd = j;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
rootEnd = 1;
|
|
146
|
+
}
|
|
147
|
+
} else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === 58) {
|
|
148
|
+
device = path.slice(0, 2);
|
|
149
|
+
rootEnd = 2;
|
|
150
|
+
if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
|
|
151
|
+
isAbsolutePath = true;
|
|
152
|
+
rootEnd = 3;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} else if (isPathSeparator(code)) {
|
|
156
|
+
return "\\";
|
|
157
|
+
}
|
|
158
|
+
let tail;
|
|
159
|
+
if (rootEnd < len) {
|
|
160
|
+
tail = normalizeString(path.slice(rootEnd), !isAbsolutePath, "\\", isPathSeparator);
|
|
161
|
+
} else {
|
|
162
|
+
tail = "";
|
|
163
|
+
}
|
|
164
|
+
if (tail.length === 0 && !isAbsolutePath) tail = ".";
|
|
165
|
+
if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
|
|
166
|
+
tail += "\\";
|
|
167
|
+
}
|
|
168
|
+
if (device === undefined) {
|
|
169
|
+
if (isAbsolutePath) {
|
|
170
|
+
if (tail.length > 0) return `\\${tail}`;
|
|
171
|
+
return "\\";
|
|
172
|
+
}
|
|
173
|
+
if (tail.length > 0) return tail;
|
|
174
|
+
return "";
|
|
175
|
+
}
|
|
176
|
+
if (isAbsolutePath) {
|
|
177
|
+
if (tail.length > 0) return `${device}\\${tail}`;
|
|
178
|
+
return `${device}\\`;
|
|
179
|
+
}
|
|
180
|
+
if (tail.length > 0) return device + tail;
|
|
181
|
+
return device;
|
|
174
182
|
}
|
|
175
183
|
function isAbsolute(path) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
assertPath(path);
|
|
185
|
+
const len = path.length;
|
|
186
|
+
if (len === 0) return false;
|
|
187
|
+
const code = path.charCodeAt(0);
|
|
188
|
+
if (isPathSeparator(code)) return true;
|
|
189
|
+
if (isWindowsDeviceRoot(code) && len > 2 && path.charCodeAt(1) === 58) {
|
|
190
|
+
if (isPathSeparator(path.charCodeAt(2))) return true;
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
185
193
|
}
|
|
186
194
|
function join(...paths) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
195
|
+
if (paths.length === 0) return ".";
|
|
196
|
+
let joined;
|
|
197
|
+
let firstPart;
|
|
198
|
+
for (let i = 0; i < paths.length; ++i) {
|
|
199
|
+
const arg = paths[i];
|
|
200
|
+
assertPath(arg);
|
|
201
|
+
if (arg.length > 0) {
|
|
202
|
+
if (joined === undefined) {
|
|
203
|
+
joined = firstPart = arg;
|
|
204
|
+
} else {
|
|
205
|
+
joined += `\\${arg}`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (joined === undefined) return ".";
|
|
210
|
+
let needsReplace = true;
|
|
211
|
+
let slashCount = 0;
|
|
212
|
+
if (isPathSeparator(firstPart.charCodeAt(0))) {
|
|
213
|
+
++slashCount;
|
|
214
|
+
const firstLen = firstPart.length;
|
|
215
|
+
if (firstLen > 1) {
|
|
216
|
+
if (isPathSeparator(firstPart.charCodeAt(1))) {
|
|
217
|
+
++slashCount;
|
|
218
|
+
if (firstLen > 2) {
|
|
219
|
+
if (isPathSeparator(firstPart.charCodeAt(2))) ++slashCount;
|
|
220
|
+
else needsReplace = false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (needsReplace) {
|
|
226
|
+
for (; slashCount < joined.length; ++slashCount) {
|
|
227
|
+
if (!isPathSeparator(joined.charCodeAt(slashCount))) break;
|
|
228
|
+
}
|
|
229
|
+
if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
|
|
230
|
+
}
|
|
231
|
+
return normalize(joined);
|
|
224
232
|
}
|
|
225
233
|
function relative(from, to) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
234
|
+
assertPath(from);
|
|
235
|
+
assertPath(to);
|
|
236
|
+
if (from === to) return "";
|
|
237
|
+
const fromOrig = resolve(from);
|
|
238
|
+
const toOrig = resolve(to);
|
|
239
|
+
if (fromOrig === toOrig) return "";
|
|
240
|
+
from = fromOrig.toLowerCase();
|
|
241
|
+
to = toOrig.toLowerCase();
|
|
242
|
+
if (from === to) return "";
|
|
243
|
+
let fromStart = 0;
|
|
244
|
+
for (; fromStart < from.length; ++fromStart) {
|
|
245
|
+
if (from.charCodeAt(fromStart) !== 92) break;
|
|
246
|
+
}
|
|
247
|
+
let fromEnd = from.length;
|
|
248
|
+
for (; fromEnd - 1 > fromStart; --fromEnd) {
|
|
249
|
+
if (from.charCodeAt(fromEnd - 1) !== 92) break;
|
|
250
|
+
}
|
|
251
|
+
const fromLen = fromEnd - fromStart;
|
|
252
|
+
let toStart = 0;
|
|
253
|
+
for (; toStart < to.length; ++toStart) {
|
|
254
|
+
if (to.charCodeAt(toStart) !== 92) break;
|
|
255
|
+
}
|
|
256
|
+
let toEnd = to.length;
|
|
257
|
+
for (; toEnd - 1 > toStart; --toEnd) {
|
|
258
|
+
if (to.charCodeAt(toEnd - 1) !== 92) break;
|
|
259
|
+
}
|
|
260
|
+
const toLen = toEnd - toStart;
|
|
261
|
+
const length = fromLen < toLen ? fromLen : toLen;
|
|
262
|
+
let lastCommonSep = -1;
|
|
263
|
+
let i = 0;
|
|
264
|
+
for (; i <= length; ++i) {
|
|
265
|
+
if (i === length) {
|
|
266
|
+
if (toLen > length) {
|
|
267
|
+
if (to.charCodeAt(toStart + i) === 92) {
|
|
268
|
+
return toOrig.slice(toStart + i + 1);
|
|
269
|
+
} else if (i === 2) {
|
|
270
|
+
return toOrig.slice(toStart + i);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (fromLen > length) {
|
|
274
|
+
if (from.charCodeAt(fromStart + i) === 92) {
|
|
275
|
+
lastCommonSep = i;
|
|
276
|
+
} else if (i === 2) {
|
|
277
|
+
lastCommonSep = 3;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
const fromCode = from.charCodeAt(fromStart + i);
|
|
283
|
+
const toCode = to.charCodeAt(toStart + i);
|
|
284
|
+
if (fromCode !== toCode) break;
|
|
285
|
+
if (fromCode === 92) lastCommonSep = i;
|
|
286
|
+
}
|
|
287
|
+
if (i !== length && lastCommonSep === -1) {
|
|
288
|
+
return toOrig;
|
|
289
|
+
}
|
|
290
|
+
let out = "";
|
|
291
|
+
if (lastCommonSep === -1) lastCommonSep = 0;
|
|
292
|
+
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
293
|
+
if (i === fromEnd || from.charCodeAt(i) === 92) {
|
|
294
|
+
if (out.length === 0) out += "..";
|
|
295
|
+
else out += "\\..";
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (out.length > 0) {
|
|
299
|
+
return out + toOrig.slice(toStart + lastCommonSep, toEnd);
|
|
300
|
+
}
|
|
301
|
+
toStart += lastCommonSep;
|
|
302
|
+
if (toOrig.charCodeAt(toStart) === 92) ++toStart;
|
|
303
|
+
return toOrig.slice(toStart, toEnd);
|
|
296
304
|
}
|
|
297
305
|
function toNamespacedPath(path) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
306
|
+
if (typeof path !== "string") return path;
|
|
307
|
+
if (path.length === 0) return "";
|
|
308
|
+
const resolvedPath = resolve(path);
|
|
309
|
+
if (resolvedPath.length >= 3) {
|
|
310
|
+
if (resolvedPath.charCodeAt(0) === 92) {
|
|
311
|
+
if (resolvedPath.charCodeAt(1) === 92) {
|
|
312
|
+
const code = resolvedPath.charCodeAt(2);
|
|
313
|
+
if (code !== 63 && code !== 46) {
|
|
314
|
+
return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0)) && resolvedPath.charCodeAt(1) === 58 && resolvedPath.charCodeAt(2) === 92) {
|
|
318
|
+
return `\\\\?\\${resolvedPath}`;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return path;
|
|
314
322
|
}
|
|
315
323
|
function dirname(path) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
324
|
+
assertPath(path);
|
|
325
|
+
const len = path.length;
|
|
326
|
+
if (len === 0) return ".";
|
|
327
|
+
let rootEnd = -1;
|
|
328
|
+
let end = -1;
|
|
329
|
+
let matchedSlash = true;
|
|
330
|
+
let offset = 0;
|
|
331
|
+
const code = path.charCodeAt(0);
|
|
332
|
+
if (len > 1) {
|
|
333
|
+
if (isPathSeparator(code)) {
|
|
334
|
+
rootEnd = offset = 1;
|
|
335
|
+
if (isPathSeparator(path.charCodeAt(1))) {
|
|
336
|
+
let j = 2;
|
|
337
|
+
let last = j;
|
|
338
|
+
for (; j < len; ++j) {
|
|
339
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
340
|
+
}
|
|
341
|
+
if (j < len && j !== last) {
|
|
342
|
+
last = j;
|
|
343
|
+
for (; j < len; ++j) {
|
|
344
|
+
if (!isPathSeparator(path.charCodeAt(j))) break;
|
|
345
|
+
}
|
|
346
|
+
if (j < len && j !== last) {
|
|
347
|
+
last = j;
|
|
348
|
+
for (; j < len; ++j) {
|
|
349
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
350
|
+
}
|
|
351
|
+
if (j === len) return path;
|
|
352
|
+
if (j !== last) rootEnd = offset = j + 1;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
} else if (isWindowsDeviceRoot(code)) {
|
|
357
|
+
if (path.charCodeAt(1) === 58) {
|
|
358
|
+
rootEnd = offset = 2;
|
|
359
|
+
if (len > 2) {
|
|
360
|
+
if (isPathSeparator(path.charCodeAt(2))) rootEnd = offset = 3;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
} else if (isPathSeparator(code)) {
|
|
365
|
+
return path;
|
|
366
|
+
}
|
|
367
|
+
for (let i = len - 1; i >= offset; --i) {
|
|
368
|
+
if (isPathSeparator(path.charCodeAt(i))) {
|
|
369
|
+
if (!matchedSlash) {
|
|
370
|
+
end = i;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
matchedSlash = false;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (end === -1) {
|
|
378
|
+
if (rootEnd === -1) return ".";
|
|
379
|
+
end = rootEnd;
|
|
380
|
+
}
|
|
381
|
+
return path.slice(0, end);
|
|
374
382
|
}
|
|
375
383
|
function basename(path, ext) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
384
|
+
if (ext !== undefined) assertPath(ext);
|
|
385
|
+
assertPath(path);
|
|
386
|
+
let start = 0;
|
|
387
|
+
let end = -1;
|
|
388
|
+
let matchedSlash = true;
|
|
389
|
+
if (path.length >= 2) {
|
|
390
|
+
if (isWindowsDeviceRoot(path.charCodeAt(0)) && path.charCodeAt(1) === 58) {
|
|
391
|
+
start = 2;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
395
|
+
if (ext.length === path.length && ext === path) return "";
|
|
396
|
+
let extIdx = ext.length - 1;
|
|
397
|
+
let firstNonSlashEnd = -1;
|
|
398
|
+
for (let i = path.length - 1; i >= start; --i) {
|
|
399
|
+
const code = path.charCodeAt(i);
|
|
400
|
+
if (isPathSeparator(code)) {
|
|
401
|
+
if (!matchedSlash) {
|
|
402
|
+
start = i + 1;
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
if (firstNonSlashEnd === -1) {
|
|
407
|
+
matchedSlash = false;
|
|
408
|
+
firstNonSlashEnd = i + 1;
|
|
409
|
+
}
|
|
410
|
+
if (extIdx >= 0) {
|
|
411
|
+
if (code === ext.charCodeAt(extIdx)) {
|
|
412
|
+
if (--extIdx === -1) end = i;
|
|
413
|
+
} else {
|
|
414
|
+
extIdx = -1;
|
|
415
|
+
end = firstNonSlashEnd;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (start === end) end = firstNonSlashEnd;
|
|
421
|
+
else if (end === -1) end = path.length;
|
|
422
|
+
return path.slice(start, end);
|
|
423
|
+
} else {
|
|
424
|
+
for (let i = path.length - 1; i >= start; --i) {
|
|
425
|
+
if (isPathSeparator(path.charCodeAt(i))) {
|
|
426
|
+
if (!matchedSlash) {
|
|
427
|
+
start = i + 1;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
} else if (end === -1) {
|
|
431
|
+
matchedSlash = false;
|
|
432
|
+
end = i + 1;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (end === -1) return "";
|
|
436
|
+
return path.slice(start, end);
|
|
437
|
+
}
|
|
430
438
|
}
|
|
431
439
|
function extname(path) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
440
|
+
assertPath(path);
|
|
441
|
+
let start = 0;
|
|
442
|
+
let startDot = -1;
|
|
443
|
+
let startPart = 0;
|
|
444
|
+
let end = -1;
|
|
445
|
+
let matchedSlash = true;
|
|
446
|
+
let preDotState = 0;
|
|
447
|
+
if (path.length >= 2 && path.charCodeAt(1) === 58 && isWindowsDeviceRoot(path.charCodeAt(0))) {
|
|
448
|
+
start = startPart = 2;
|
|
449
|
+
}
|
|
450
|
+
for (let i = path.length - 1; i >= start; --i) {
|
|
451
|
+
const code = path.charCodeAt(i);
|
|
452
|
+
if (isPathSeparator(code)) {
|
|
453
|
+
if (!matchedSlash) {
|
|
454
|
+
startPart = i + 1;
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (end === -1) {
|
|
460
|
+
matchedSlash = false;
|
|
461
|
+
end = i + 1;
|
|
462
|
+
}
|
|
463
|
+
if (code === 46) {
|
|
464
|
+
if (startDot === -1) startDot = i;
|
|
465
|
+
else if (preDotState !== 1) preDotState = 1;
|
|
466
|
+
} else if (startDot !== -1) {
|
|
467
|
+
preDotState = -1;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
471
|
+
return "";
|
|
472
|
+
}
|
|
473
|
+
return path.slice(startDot, end);
|
|
466
474
|
}
|
|
467
475
|
function format(pathObject) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
return _format("\\", pathObject);
|
|
476
|
+
if (pathObject === null || typeof pathObject !== "object") {
|
|
477
|
+
throw new TypeError("The \"pathObject\" argument must be of type Object. Received type " + typeof pathObject);
|
|
478
|
+
}
|
|
479
|
+
return _format("\\", pathObject);
|
|
474
480
|
}
|
|
475
481
|
function parse(path) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
482
|
+
assertPath(path);
|
|
483
|
+
const ret = {
|
|
484
|
+
root: "",
|
|
485
|
+
dir: "",
|
|
486
|
+
base: "",
|
|
487
|
+
ext: "",
|
|
488
|
+
name: ""
|
|
489
|
+
};
|
|
490
|
+
if (path.length === 0) return ret;
|
|
491
|
+
const len = path.length;
|
|
492
|
+
let rootEnd = 0;
|
|
493
|
+
let code = path.charCodeAt(0);
|
|
494
|
+
if (len > 1) {
|
|
495
|
+
if (isPathSeparator(code)) {
|
|
496
|
+
rootEnd = 1;
|
|
497
|
+
if (isPathSeparator(path.charCodeAt(1))) {
|
|
498
|
+
let j = 2;
|
|
499
|
+
let last = j;
|
|
500
|
+
for (; j < len; ++j) {
|
|
501
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
502
|
+
}
|
|
503
|
+
if (j < len && j !== last) {
|
|
504
|
+
last = j;
|
|
505
|
+
for (; j < len; ++j) {
|
|
506
|
+
if (!isPathSeparator(path.charCodeAt(j))) break;
|
|
507
|
+
}
|
|
508
|
+
if (j < len && j !== last) {
|
|
509
|
+
last = j;
|
|
510
|
+
for (; j < len; ++j) {
|
|
511
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
512
|
+
}
|
|
513
|
+
if (j === len) rootEnd = j;
|
|
514
|
+
else if (j !== last) rootEnd = j + 1;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
} else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === 58) {
|
|
519
|
+
rootEnd = 2;
|
|
520
|
+
if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
|
|
521
|
+
rootEnd = 3;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
} else if (isPathSeparator(code)) {
|
|
525
|
+
ret.root = ret.dir = path;
|
|
526
|
+
return ret;
|
|
527
|
+
}
|
|
528
|
+
if (rootEnd > 0) ret.root = path.slice(0, rootEnd);
|
|
529
|
+
let startDot = -1;
|
|
530
|
+
let startPart = rootEnd;
|
|
531
|
+
let end = -1;
|
|
532
|
+
let matchedSlash = true;
|
|
533
|
+
let i = path.length - 1;
|
|
534
|
+
let preDotState = 0;
|
|
535
|
+
for (; i >= rootEnd; --i) {
|
|
536
|
+
code = path.charCodeAt(i);
|
|
537
|
+
if (isPathSeparator(code)) {
|
|
538
|
+
if (!matchedSlash) {
|
|
539
|
+
startPart = i + 1;
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
if (end === -1) {
|
|
545
|
+
matchedSlash = false;
|
|
546
|
+
end = i + 1;
|
|
547
|
+
}
|
|
548
|
+
if (code === 46) {
|
|
549
|
+
if (startDot === -1) startDot = i;
|
|
550
|
+
else if (preDotState !== 1) preDotState = 1;
|
|
551
|
+
} else if (startDot !== -1) {
|
|
552
|
+
preDotState = -1;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
556
|
+
if (end !== -1) {
|
|
557
|
+
ret.base = ret.name = path.slice(startPart, end);
|
|
558
|
+
}
|
|
559
|
+
} else {
|
|
560
|
+
ret.name = path.slice(startPart, startDot);
|
|
561
|
+
ret.base = path.slice(startPart, end);
|
|
562
|
+
ret.ext = path.slice(startDot, end);
|
|
563
|
+
}
|
|
564
|
+
if (startPart > 0 && startPart !== rootEnd) {
|
|
565
|
+
ret.dir = path.slice(0, startPart - 1);
|
|
566
|
+
} else {
|
|
567
|
+
ret.dir = ret.root;
|
|
568
|
+
}
|
|
569
|
+
return ret;
|
|
558
570
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
dirname,
|
|
563
|
-
extname,
|
|
564
|
-
format,
|
|
565
|
-
isAbsolute,
|
|
566
|
-
join,
|
|
567
|
-
normalize,
|
|
568
|
-
parse,
|
|
569
|
-
relative,
|
|
570
|
-
resolve,
|
|
571
|
-
sep,
|
|
572
|
-
toNamespacedPath
|
|
573
|
-
};
|
|
571
|
+
|
|
572
|
+
//#endregion
|
|
573
|
+
export { basename, delimiter, dirname, extname, format, isAbsolute, join, normalize, parse, relative, resolve, sep, toNamespacedPath, win32_exports };
|