@gjsify/path 0.3.16 → 0.3.17

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/win32.js CHANGED
@@ -1,573 +1 @@
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
- });
21
- const sep = "\\";
22
- const delimiter = ";";
23
- function resolve(...pathSegments) {
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 || ".";
107
- }
108
- function normalize(path) {
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;
182
- }
183
- function isAbsolute(path) {
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;
193
- }
194
- function join(...paths) {
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);
232
- }
233
- function relative(from, to) {
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);
304
- }
305
- function toNamespacedPath(path) {
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;
322
- }
323
- function dirname(path) {
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);
382
- }
383
- function basename(path, ext) {
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
- }
438
- }
439
- function extname(path) {
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);
474
- }
475
- function 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);
480
- }
481
- function parse(path) {
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;
570
- }
571
-
572
- //#endregion
573
- export { basename, delimiter, dirname, extname, format, isAbsolute, join, normalize, parse, relative, resolve, sep, toNamespacedPath, win32_exports };
1
+ import{__exportAll as e}from"./_virtual/_rolldown/runtime.js";import"./constants.js";import{_format as t,assertPath as n,isPathSeparator as r,isWindowsDeviceRoot as i,normalizeString as a}from"./util.js";var o=e({basename:()=>g,delimiter:()=>`;`,dirname:()=>h,extname:()=>_,format:()=>v,isAbsolute:()=>d,join:()=>f,normalize:()=>u,parse:()=>y,relative:()=>p,resolve:()=>l,sep:()=>`\\`,toNamespacedPath:()=>m});const s=`\\`,c=`;`;function l(...e){let t=``,o=``,s=!1;for(let a=e.length-1;a>=-1;a--){let c;if(a>=0){if(c=e[a],n(c),c.length===0)continue}else c=(t.length,typeof globalThis.process?.cwd==`function`?globalThis.process.cwd():`/`);let l=c.length,u=0,d=``,f=!1,p=c.charCodeAt(0);if(l>1)if(r(p))if(f=!0,r(c.charCodeAt(1))){let e=2,t=e;for(;e<l&&!r(c.charCodeAt(e));++e);if(e<l&&e!==t){let n=c.slice(t,e);for(t=e;e<l&&r(c.charCodeAt(e));++e);if(e<l&&e!==t){for(t=e;e<l&&!r(c.charCodeAt(e));++e);e===l?(d=`\\\\${n}\\${c.slice(t)}`,u=e):e!==t&&(d=`\\\\${n}\\${c.slice(t,e)}`,u=e)}}}else u=1;else i(p)&&c.charCodeAt(1)===58&&(d=c.slice(0,2),u=2,l>2&&r(c.charCodeAt(2))&&(f=!0,u=3));else r(p)&&(u=1,f=!0);if(!(d.length>0&&t.length>0&&d.toLowerCase()!==t.toLowerCase())&&(t.length===0&&d.length>0&&(t=d),s||=(o=`${c.slice(u)}\\${o}`,f),t.length>0&&s))break}return o=a(o,!s,`\\`,r),t+(s?`\\`:``)+o||`.`}function u(e){n(e);let t=e.length;if(t===0)return`.`;let o=0,s,c=!1,l=e.charCodeAt(0);if(t>1)if(r(l))if(c=!0,r(e.charCodeAt(1))){let n=2,i=n;for(;n<t&&!r(e.charCodeAt(n));++n);if(n<t&&n!==i){let a=e.slice(i,n);for(i=n;n<t&&r(e.charCodeAt(n));++n);if(n<t&&n!==i){for(i=n;n<t&&!r(e.charCodeAt(n));++n);if(n===t)return`\\\\${a}\\${e.slice(i)}\\`;n!==i&&(s=`\\\\${a}\\${e.slice(i,n)}`,o=n)}}}else o=1;else i(l)&&e.charCodeAt(1)===58&&(s=e.slice(0,2),o=2,t>2&&r(e.charCodeAt(2))&&(c=!0,o=3));else if(r(l))return`\\`;let u;return u=o<t?a(e.slice(o),!c,`\\`,r):``,u.length===0&&!c&&(u=`.`),u.length>0&&r(e.charCodeAt(t-1))&&(u+=`\\`),s===void 0?c?u.length>0?`\\${u}`:`\\`:u.length>0?u:``:c?u.length>0?`${s}\\${u}`:`${s}\\`:u.length>0?s+u:s}function d(e){n(e);let t=e.length;if(t===0)return!1;let a=e.charCodeAt(0);return!!(r(a)||i(a)&&t>2&&e.charCodeAt(1)===58&&r(e.charCodeAt(2)))}function f(...e){if(e.length===0)return`.`;let t,i;for(let r=0;r<e.length;++r){let a=e[r];n(a),a.length>0&&(t===void 0?t=i=a:t+=`\\${a}`)}if(t===void 0)return`.`;let a=!0,o=0;if(r(i.charCodeAt(0))){++o;let e=i.length;e>1&&r(i.charCodeAt(1))&&(++o,e>2&&(r(i.charCodeAt(2))?++o:a=!1))}if(a){for(;o<t.length&&r(t.charCodeAt(o));++o);o>=2&&(t=`\\${t.slice(o)}`)}return u(t)}function p(e,t){if(n(e),n(t),e===t)return``;let r=l(e),i=l(t);if(r===i||(e=r.toLowerCase(),t=i.toLowerCase(),e===t))return``;let a=0;for(;a<e.length&&e.charCodeAt(a)===92;++a);let o=e.length;for(;o-1>a&&e.charCodeAt(o-1)===92;--o);let s=o-a,c=0;for(;c<t.length&&t.charCodeAt(c)===92;++c);let u=t.length;for(;u-1>c&&t.charCodeAt(u-1)===92;--u);let d=u-c,f=s<d?s:d,p=-1,m=0;for(;m<=f;++m){if(m===f){if(d>f){if(t.charCodeAt(c+m)===92)return i.slice(c+m+1);if(m===2)return i.slice(c+m)}s>f&&(e.charCodeAt(a+m)===92?p=m:m===2&&(p=3));break}let n=e.charCodeAt(a+m);if(n!==t.charCodeAt(c+m))break;n===92&&(p=m)}if(m!==f&&p===-1)return i;let h=``;for(p===-1&&(p=0),m=a+p+1;m<=o;++m)(m===o||e.charCodeAt(m)===92)&&(h.length===0?h+=`..`:h+=`\\..`);return h.length>0?h+i.slice(c+p,u):(c+=p,i.charCodeAt(c)===92&&++c,i.slice(c,u))}function m(e){if(typeof e!=`string`)return e;if(e.length===0)return``;let t=l(e);if(t.length>=3){if(t.charCodeAt(0)===92){if(t.charCodeAt(1)===92){let e=t.charCodeAt(2);if(e!==63&&e!==46)return`\\\\?\\UNC\\${t.slice(2)}`}}else if(i(t.charCodeAt(0))&&t.charCodeAt(1)===58&&t.charCodeAt(2)===92)return`\\\\?\\${t}`}return e}function h(e){n(e);let t=e.length;if(t===0)return`.`;let a=-1,o=-1,s=!0,c=0,l=e.charCodeAt(0);if(t>1)if(r(l)){if(a=c=1,r(e.charCodeAt(1))){let n=2,i=n;for(;n<t&&!r(e.charCodeAt(n));++n);if(n<t&&n!==i){for(i=n;n<t&&r(e.charCodeAt(n));++n);if(n<t&&n!==i){for(i=n;n<t&&!r(e.charCodeAt(n));++n);if(n===t)return e;n!==i&&(a=c=n+1)}}}}else i(l)&&e.charCodeAt(1)===58&&(a=c=2,t>2&&r(e.charCodeAt(2))&&(a=c=3));else if(r(l))return e;for(let n=t-1;n>=c;--n)if(r(e.charCodeAt(n))){if(!s){o=n;break}}else s=!1;if(o===-1){if(a===-1)return`.`;o=a}return e.slice(0,o)}function g(e,t){t!==void 0&&n(t),n(e);let a=0,o=-1,s=!0;if(e.length>=2&&i(e.charCodeAt(0))&&e.charCodeAt(1)===58&&(a=2),t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let n=t.length-1,i=-1;for(let c=e.length-1;c>=a;--c){let l=e.charCodeAt(c);if(r(l)){if(!s){a=c+1;break}}else i===-1&&(s=!1,i=c+1),n>=0&&(l===t.charCodeAt(n)?--n===-1&&(o=c):(n=-1,o=i))}return a===o?o=i:o===-1&&(o=e.length),e.slice(a,o)}else{for(let t=e.length-1;t>=a;--t)if(r(e.charCodeAt(t))){if(!s){a=t+1;break}}else o===-1&&(s=!1,o=t+1);return o===-1?``:e.slice(a,o)}}function _(e){n(e);let t=0,a=-1,o=0,s=-1,c=!0,l=0;e.length>=2&&e.charCodeAt(1)===58&&i(e.charCodeAt(0))&&(t=o=2);for(let n=e.length-1;n>=t;--n){let t=e.charCodeAt(n);if(r(t)){if(!c){o=n+1;break}continue}s===-1&&(c=!1,s=n+1),t===46?a===-1?a=n:l!==1&&(l=1):a!==-1&&(l=-1)}return a===-1||s===-1||l===0||l===1&&a===s-1&&a===o+1?``:e.slice(a,s)}function v(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return t(`\\`,e)}function y(e){n(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let a=e.length,o=0,s=e.charCodeAt(0);if(a>1)if(r(s)){if(o=1,r(e.charCodeAt(1))){let t=2,n=t;for(;t<a&&!r(e.charCodeAt(t));++t);if(t<a&&t!==n){for(n=t;t<a&&r(e.charCodeAt(t));++t);if(t<a&&t!==n){for(n=t;t<a&&!r(e.charCodeAt(t));++t);t===a?o=t:t!==n&&(o=t+1)}}}}else i(s)&&e.charCodeAt(1)===58&&(o=2,a>2&&r(e.charCodeAt(2))&&(o=3));else if(r(s))return t.root=t.dir=e,t;o>0&&(t.root=e.slice(0,o));let c=-1,l=o,u=-1,d=!0,f=e.length-1,p=0;for(;f>=o;--f){if(s=e.charCodeAt(f),r(s)){if(!d){l=f+1;break}continue}u===-1&&(d=!1,u=f+1),s===46?c===-1?c=f:p!==1&&(p=1):c!==-1&&(p=-1)}return c===-1||u===-1||p===0||p===1&&c===u-1&&c===l+1?u!==-1&&(t.base=t.name=e.slice(l,u)):(t.name=e.slice(l,c),t.base=e.slice(l,u),t.ext=e.slice(c,u)),l>0&&l!==o?t.dir=e.slice(0,l-1):t.dir=t.root,t}export{g as basename,c as delimiter,h as dirname,_ as extname,v as format,d as isAbsolute,f as join,u as normalize,y as parse,p as relative,l as resolve,s as sep,m as toNamespacedPath,o as win32_exports};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/path",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "Node.js path module for Gjs",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -38,9 +38,9 @@
38
38
  "path"
39
39
  ],
40
40
  "devDependencies": {
41
- "@gjsify/cli": "^0.3.16",
42
- "@gjsify/unit": "^0.3.16",
43
- "@types/node": "^25.6.0",
41
+ "@gjsify/cli": "^0.3.17",
42
+ "@gjsify/unit": "^0.3.17",
43
+ "@types/node": "^25.6.2",
44
44
  "typescript": "^6.0.3"
45
45
  }
46
46
  }