elit 3.0.1 → 3.0.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.
- package/dist/build.d.ts +4 -12
- package/dist/build.d.ts.map +1 -0
- package/dist/chokidar.d.ts +7 -9
- package/dist/chokidar.d.ts.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +250 -21
- package/dist/config.d.ts +29 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/dom.d.ts +7 -14
- package/dist/dom.d.ts.map +1 -0
- package/dist/el.d.ts +19 -191
- package/dist/el.d.ts.map +1 -0
- package/dist/fs.d.ts +35 -35
- package/dist/fs.d.ts.map +1 -0
- package/dist/hmr.d.ts +3 -3
- package/dist/hmr.d.ts.map +1 -0
- package/dist/http.d.ts +20 -22
- package/dist/http.d.ts.map +1 -0
- package/dist/https.d.ts +12 -15
- package/dist/https.d.ts.map +1 -0
- package/dist/index.d.ts +10 -629
- package/dist/index.d.ts.map +1 -0
- package/dist/mime-types.d.ts +9 -9
- package/dist/mime-types.d.ts.map +1 -0
- package/dist/path.d.ts +22 -19
- package/dist/path.d.ts.map +1 -0
- package/dist/router.d.ts +10 -17
- package/dist/router.d.ts.map +1 -0
- package/dist/runtime.d.ts +5 -6
- package/dist/runtime.d.ts.map +1 -0
- package/dist/server.d.ts +109 -7
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +712 -137
- package/dist/server.mjs +711 -137
- package/dist/state.d.ts +21 -27
- package/dist/state.d.ts.map +1 -0
- package/dist/style.d.ts +14 -55
- package/dist/style.d.ts.map +1 -0
- package/dist/types.d.ts +26 -240
- package/dist/types.d.ts.map +1 -0
- package/dist/ws.d.ts +14 -17
- package/dist/ws.d.ts.map +1 -0
- package/dist/wss.d.ts +16 -16
- package/dist/wss.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/build.ts +337 -0
- package/src/chokidar.ts +401 -0
- package/src/cli.ts +638 -0
- package/src/config.ts +205 -0
- package/src/dom.ts +817 -0
- package/src/el.ts +164 -0
- package/src/fs.ts +727 -0
- package/src/hmr.ts +137 -0
- package/src/http.ts +775 -0
- package/src/https.ts +411 -0
- package/src/index.ts +14 -0
- package/src/mime-types.ts +222 -0
- package/src/path.ts +493 -0
- package/src/router.ts +237 -0
- package/src/runtime.ts +97 -0
- package/src/server.ts +1593 -0
- package/src/state.ts +468 -0
- package/src/style.ts +524 -0
- package/{dist/types-Du6kfwTm.d.ts → src/types.ts} +58 -141
- package/src/ws.ts +506 -0
- package/src/wss.ts +241 -0
- package/dist/build.d.mts +0 -20
- package/dist/chokidar.d.mts +0 -134
- package/dist/dom.d.mts +0 -87
- package/dist/el.d.mts +0 -207
- package/dist/fs.d.mts +0 -255
- package/dist/hmr.d.mts +0 -38
- package/dist/http.d.mts +0 -163
- package/dist/https.d.mts +0 -108
- package/dist/index.d.mts +0 -629
- package/dist/mime-types.d.mts +0 -48
- package/dist/path.d.mts +0 -163
- package/dist/router.d.mts +0 -47
- package/dist/runtime.d.mts +0 -97
- package/dist/server.d.mts +0 -7
- package/dist/state.d.mts +0 -111
- package/dist/style.d.mts +0 -159
- package/dist/types-C0nGi6MX.d.mts +0 -346
- package/dist/types.d.mts +0 -452
- package/dist/ws.d.mts +0 -195
- package/dist/wss.d.mts +0 -108
package/src/path.ts
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path module with unified API across runtimes
|
|
3
|
+
* Pure implementation without external dependencies
|
|
4
|
+
* Compatible with Node.js 'path' module API
|
|
5
|
+
* Works on Node.js, Bun, and Deno
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { isBun, isDeno, isNode, runtime } from './runtime';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Helper: Get path separator for platform (eliminates duplication in separator logic)
|
|
12
|
+
*/
|
|
13
|
+
function getSeparator(isWin: boolean): string {
|
|
14
|
+
return isWin ? '\\' : '/';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Helper: Get current working directory (eliminates duplication in resolvePaths)
|
|
19
|
+
*/
|
|
20
|
+
function getCwd(): string {
|
|
21
|
+
if (isNode || isBun) {
|
|
22
|
+
return process.cwd();
|
|
23
|
+
} else if (isDeno) {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
return Deno.cwd();
|
|
26
|
+
}
|
|
27
|
+
return '/';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Helper: Find last separator index (eliminates duplication in getExtname and getBasename)
|
|
32
|
+
*/
|
|
33
|
+
function findLastSeparator(path: string): number {
|
|
34
|
+
return Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Helper: Create path operation object (eliminates duplication in posix and win32)
|
|
39
|
+
*/
|
|
40
|
+
function createPathOps(isWin: boolean) {
|
|
41
|
+
return {
|
|
42
|
+
sep: getSeparator(isWin),
|
|
43
|
+
delimiter: isWin ? ';' : ':',
|
|
44
|
+
normalize: (path: string) => normalizePath(path, isWin),
|
|
45
|
+
join: (...paths: string[]) => joinPaths(paths, isWin),
|
|
46
|
+
resolve: (...paths: string[]) => resolvePaths(paths, isWin),
|
|
47
|
+
isAbsolute: (path: string) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
48
|
+
relative: (from: string, to: string) => relativePath(from, to, isWin),
|
|
49
|
+
dirname: (path: string) => getDirname(path, isWin),
|
|
50
|
+
basename: (path: string, ext?: string) => getBasename(path, ext, isWin),
|
|
51
|
+
extname: (path: string) => getExtname(path),
|
|
52
|
+
parse: (path: string) => parsePath(path, isWin),
|
|
53
|
+
format: (pathObject: FormatInputPathObject) => formatPath(pathObject, isWin)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Helper: Check if path is absolute (POSIX)
|
|
59
|
+
*/
|
|
60
|
+
function isAbsolutePosix(path: string): boolean {
|
|
61
|
+
return path.length > 0 && path[0] === '/';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Helper: Check if path is absolute (Windows)
|
|
66
|
+
*/
|
|
67
|
+
function isAbsoluteWin(path: string): boolean {
|
|
68
|
+
const len = path.length;
|
|
69
|
+
if (len === 0) return false;
|
|
70
|
+
|
|
71
|
+
const code = path.charCodeAt(0);
|
|
72
|
+
if (code === 47 /* / */ || code === 92 /* \ */) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Check for drive letter
|
|
77
|
+
if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122)) {
|
|
78
|
+
if (len > 2 && path.charCodeAt(1) === 58 /* : */) {
|
|
79
|
+
const code2 = path.charCodeAt(2);
|
|
80
|
+
if (code2 === 47 /* / */ || code2 === 92 /* \ */) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Platform detection
|
|
91
|
+
*/
|
|
92
|
+
const isWindows = (() => {
|
|
93
|
+
if (isNode) {
|
|
94
|
+
return process.platform === 'win32';
|
|
95
|
+
} else if (isDeno) {
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
return Deno.build.os === 'windows';
|
|
98
|
+
}
|
|
99
|
+
// Bun uses process.platform like Node
|
|
100
|
+
return typeof process !== 'undefined' && process.platform === 'win32';
|
|
101
|
+
})();
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Path separator
|
|
105
|
+
*/
|
|
106
|
+
export const sep = isWindows ? '\\' : '/';
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Path delimiter
|
|
110
|
+
*/
|
|
111
|
+
export const delimiter = isWindows ? ';' : ':';
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* POSIX path operations
|
|
115
|
+
*/
|
|
116
|
+
const posix = createPathOps(false);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Windows path operations
|
|
120
|
+
*/
|
|
121
|
+
const win32 = createPathOps(true);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Path object interface
|
|
125
|
+
*/
|
|
126
|
+
export interface ParsedPath {
|
|
127
|
+
root: string;
|
|
128
|
+
dir: string;
|
|
129
|
+
base: string;
|
|
130
|
+
ext: string;
|
|
131
|
+
name: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface FormatInputPathObject {
|
|
135
|
+
root?: string;
|
|
136
|
+
dir?: string;
|
|
137
|
+
base?: string;
|
|
138
|
+
ext?: string;
|
|
139
|
+
name?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Normalize a path
|
|
144
|
+
*/
|
|
145
|
+
function normalizePath(path: string, isWin: boolean): string {
|
|
146
|
+
if (path.length === 0) return '.';
|
|
147
|
+
|
|
148
|
+
const separator = getSeparator(isWin);
|
|
149
|
+
const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
150
|
+
const trailingSeparator = path[path.length - 1] === separator || (isWin && path[path.length - 1] === '/');
|
|
151
|
+
|
|
152
|
+
// Normalize slashes
|
|
153
|
+
let normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
|
|
154
|
+
|
|
155
|
+
// Split path
|
|
156
|
+
const parts = normalized.split(separator);
|
|
157
|
+
const result: string[] = [];
|
|
158
|
+
|
|
159
|
+
for (let i = 0; i < parts.length; i++) {
|
|
160
|
+
const part = parts[i];
|
|
161
|
+
|
|
162
|
+
if (part === '' || part === '.') {
|
|
163
|
+
if (i === 0 && isAbsolute) result.push('');
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (part === '..') {
|
|
168
|
+
if (result.length > 0 && result[result.length - 1] !== '..') {
|
|
169
|
+
if (!(result.length === 1 && result[0] === '')) {
|
|
170
|
+
result.pop();
|
|
171
|
+
}
|
|
172
|
+
} else if (!isAbsolute) {
|
|
173
|
+
result.push('..');
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
result.push(part);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let final = result.join(separator);
|
|
181
|
+
|
|
182
|
+
if (final.length === 0) {
|
|
183
|
+
return isAbsolute ? separator : '.';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (trailingSeparator && final[final.length - 1] !== separator) {
|
|
187
|
+
final += separator;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return final;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Join paths
|
|
195
|
+
*/
|
|
196
|
+
function joinPaths(paths: string[], isWin: boolean): string {
|
|
197
|
+
if (paths.length === 0) return '.';
|
|
198
|
+
|
|
199
|
+
const separator = getSeparator(isWin);
|
|
200
|
+
let joined = '';
|
|
201
|
+
for (let i = 0; i < paths.length; i++) {
|
|
202
|
+
const path = paths[i];
|
|
203
|
+
if (path && path.length > 0) {
|
|
204
|
+
if (joined.length === 0) {
|
|
205
|
+
joined = path;
|
|
206
|
+
} else {
|
|
207
|
+
joined += separator + path;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (joined.length === 0) return '.';
|
|
213
|
+
|
|
214
|
+
return normalizePath(joined, isWin);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Resolve paths to absolute path
|
|
219
|
+
*/
|
|
220
|
+
function resolvePaths(paths: string[], isWin: boolean): string {
|
|
221
|
+
const separator = getSeparator(isWin);
|
|
222
|
+
let resolved = '';
|
|
223
|
+
let isAbsolute = false;
|
|
224
|
+
|
|
225
|
+
for (let i = paths.length - 1; i >= 0 && !isAbsolute; i--) {
|
|
226
|
+
const path = paths[i];
|
|
227
|
+
if (path && path.length > 0) {
|
|
228
|
+
resolved = path + (resolved.length > 0 ? separator + resolved : '');
|
|
229
|
+
isAbsolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (!isAbsolute) {
|
|
234
|
+
const cwd = getCwd();
|
|
235
|
+
resolved = cwd + (resolved.length > 0 ? separator + resolved : '');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return normalizePath(resolved, isWin);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Get relative path
|
|
243
|
+
*/
|
|
244
|
+
function relativePath(from: string, to: string, isWin: boolean): string {
|
|
245
|
+
from = resolvePaths([from], isWin);
|
|
246
|
+
to = resolvePaths([to], isWin);
|
|
247
|
+
|
|
248
|
+
if (from === to) return '';
|
|
249
|
+
|
|
250
|
+
const separator = getSeparator(isWin);
|
|
251
|
+
const fromParts = from.split(separator).filter(p => p.length > 0);
|
|
252
|
+
const toParts = to.split(separator).filter(p => p.length > 0);
|
|
253
|
+
|
|
254
|
+
let commonLength = 0;
|
|
255
|
+
const minLength = Math.min(fromParts.length, toParts.length);
|
|
256
|
+
|
|
257
|
+
for (let i = 0; i < minLength; i++) {
|
|
258
|
+
if (fromParts[i] === toParts[i]) {
|
|
259
|
+
commonLength++;
|
|
260
|
+
} else {
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const upCount = fromParts.length - commonLength;
|
|
266
|
+
const result: string[] = [];
|
|
267
|
+
|
|
268
|
+
for (let i = 0; i < upCount; i++) {
|
|
269
|
+
result.push('..');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
for (let i = commonLength; i < toParts.length; i++) {
|
|
273
|
+
result.push(toParts[i]);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return result.join(separator) || '.';
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Get directory name
|
|
281
|
+
*/
|
|
282
|
+
function getDirname(path: string, isWin: boolean): string {
|
|
283
|
+
if (path.length === 0) return '.';
|
|
284
|
+
|
|
285
|
+
const separator = getSeparator(isWin);
|
|
286
|
+
const normalized = normalizePath(path, isWin);
|
|
287
|
+
const lastSepIndex = normalized.lastIndexOf(separator);
|
|
288
|
+
|
|
289
|
+
if (lastSepIndex === -1) return '.';
|
|
290
|
+
if (lastSepIndex === 0) return separator;
|
|
291
|
+
|
|
292
|
+
return normalized.slice(0, lastSepIndex);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Get base name
|
|
297
|
+
*/
|
|
298
|
+
function getBasename(path: string, ext?: string, isWin?: boolean): string {
|
|
299
|
+
if (path.length === 0) return '';
|
|
300
|
+
|
|
301
|
+
const lastSepIndex = isWin ? findLastSeparator(path) : path.lastIndexOf('/');
|
|
302
|
+
let base = lastSepIndex === -1 ? path : path.slice(lastSepIndex + 1);
|
|
303
|
+
|
|
304
|
+
if (ext && base.endsWith(ext)) {
|
|
305
|
+
base = base.slice(0, base.length - ext.length);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return base;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Get extension name
|
|
313
|
+
*/
|
|
314
|
+
function getExtname(path: string): string {
|
|
315
|
+
const lastDotIndex = path.lastIndexOf('.');
|
|
316
|
+
const lastSepIndex = findLastSeparator(path);
|
|
317
|
+
|
|
318
|
+
if (lastDotIndex === -1 || lastDotIndex < lastSepIndex || lastDotIndex === path.length - 1) {
|
|
319
|
+
return '';
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return path.slice(lastDotIndex);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Parse path into components
|
|
327
|
+
*/
|
|
328
|
+
function parsePath(path: string, isWin: boolean): ParsedPath {
|
|
329
|
+
let root = '';
|
|
330
|
+
if (isWin) {
|
|
331
|
+
// Check for Windows drive letter
|
|
332
|
+
if (path.length >= 2 && path[1] === ':') {
|
|
333
|
+
root = path.slice(0, 2);
|
|
334
|
+
if (path.length > 2 && (path[2] === '\\' || path[2] === '/')) {
|
|
335
|
+
root += '\\';
|
|
336
|
+
}
|
|
337
|
+
} else if (path[0] === '\\' || path[0] === '/') {
|
|
338
|
+
root = '\\';
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
if (path[0] === '/') {
|
|
342
|
+
root = '/';
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const dir = getDirname(path, isWin);
|
|
347
|
+
const base = getBasename(path, undefined, isWin);
|
|
348
|
+
const ext = getExtname(path);
|
|
349
|
+
const name = ext ? base.slice(0, base.length - ext.length) : base;
|
|
350
|
+
|
|
351
|
+
return { root, dir, base, ext, name };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Format path from components
|
|
356
|
+
*/
|
|
357
|
+
function formatPath(pathObject: FormatInputPathObject, isWin: boolean): string {
|
|
358
|
+
const separator = getSeparator(isWin);
|
|
359
|
+
const dir = pathObject.dir || pathObject.root || '';
|
|
360
|
+
const base = pathObject.base || ((pathObject.name || '') + (pathObject.ext || ''));
|
|
361
|
+
|
|
362
|
+
if (!dir) return base;
|
|
363
|
+
if (dir === pathObject.root) return dir + base;
|
|
364
|
+
|
|
365
|
+
return dir + separator + base;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Normalize a path (platform-specific)
|
|
370
|
+
*/
|
|
371
|
+
export function normalize(path: string): string {
|
|
372
|
+
return normalizePath(path, isWindows);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Join paths (platform-specific)
|
|
377
|
+
*/
|
|
378
|
+
export function join(...paths: string[]): string {
|
|
379
|
+
return joinPaths(paths, isWindows);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Resolve paths to absolute path (platform-specific)
|
|
384
|
+
*/
|
|
385
|
+
export function resolve(...paths: string[]): string {
|
|
386
|
+
return resolvePaths(paths, isWindows);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Check if path is absolute (platform-specific)
|
|
391
|
+
*/
|
|
392
|
+
export function isAbsolute(path: string): boolean {
|
|
393
|
+
return isWindows ? win32.isAbsolute(path) : posix.isAbsolute(path);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Get relative path (platform-specific)
|
|
398
|
+
*/
|
|
399
|
+
export function relative(from: string, to: string): string {
|
|
400
|
+
return relativePath(from, to, isWindows);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Get directory name (platform-specific)
|
|
405
|
+
*/
|
|
406
|
+
export function dirname(path: string): string {
|
|
407
|
+
return getDirname(path, isWindows);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Get base name (platform-specific)
|
|
412
|
+
*/
|
|
413
|
+
export function basename(path: string, ext?: string): string {
|
|
414
|
+
return getBasename(path, ext, isWindows);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Get extension name
|
|
419
|
+
*/
|
|
420
|
+
export function extname(path: string): string {
|
|
421
|
+
return getExtname(path);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Parse path into components (platform-specific)
|
|
426
|
+
*/
|
|
427
|
+
export function parse(path: string): ParsedPath {
|
|
428
|
+
return parsePath(path, isWindows);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Format path from components (platform-specific)
|
|
433
|
+
*/
|
|
434
|
+
export function format(pathObject: FormatInputPathObject): string {
|
|
435
|
+
return formatPath(pathObject, isWindows);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Convert to namespaced path (Windows only)
|
|
440
|
+
*/
|
|
441
|
+
export function toNamespacedPath(path: string): string {
|
|
442
|
+
if (!isWindows || path.length === 0) return path;
|
|
443
|
+
|
|
444
|
+
const resolved = resolve(path);
|
|
445
|
+
|
|
446
|
+
if (resolved.length >= 3) {
|
|
447
|
+
if (resolved[0] === '\\') {
|
|
448
|
+
// UNC path
|
|
449
|
+
if (resolved[1] === '\\' && resolved[2] !== '?') {
|
|
450
|
+
return '\\\\?\\UNC\\' + resolved.slice(2);
|
|
451
|
+
}
|
|
452
|
+
} else if (resolved[1] === ':' && resolved[2] === '\\') {
|
|
453
|
+
// Drive letter
|
|
454
|
+
return '\\\\?\\' + resolved;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return path;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Get current runtime
|
|
463
|
+
*/
|
|
464
|
+
export function getRuntime(): 'node' | 'bun' | 'deno' {
|
|
465
|
+
return runtime;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Export POSIX and Win32 implementations
|
|
470
|
+
*/
|
|
471
|
+
export { posix, win32 };
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Default export
|
|
475
|
+
*/
|
|
476
|
+
export default {
|
|
477
|
+
sep,
|
|
478
|
+
delimiter,
|
|
479
|
+
normalize,
|
|
480
|
+
join,
|
|
481
|
+
resolve,
|
|
482
|
+
isAbsolute,
|
|
483
|
+
relative,
|
|
484
|
+
dirname,
|
|
485
|
+
basename,
|
|
486
|
+
extname,
|
|
487
|
+
parse,
|
|
488
|
+
format,
|
|
489
|
+
toNamespacedPath,
|
|
490
|
+
posix,
|
|
491
|
+
win32,
|
|
492
|
+
getRuntime,
|
|
493
|
+
};
|