elit 3.6.6 → 3.6.7
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/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/dist/build.cjs +421 -331
- package/dist/build.d.ts +1 -19
- package/dist/build.js +420 -330
- package/dist/build.mjs +420 -330
- package/dist/chokidar.cjs +219 -182
- package/dist/chokidar.d.ts +25 -10
- package/dist/chokidar.js +217 -182
- package/dist/chokidar.mjs +218 -183
- package/dist/cli.cjs +22439 -21563
- package/dist/cli.d.ts +19 -37
- package/dist/cli.mjs +24113 -23252
- package/dist/config.cjs +357 -350
- package/dist/config.d.ts +17 -245
- package/dist/config.js +520 -515
- package/dist/config.mjs +346 -341
- package/dist/contracts-BeW9k0yZ.d.ts +54 -0
- package/dist/contracts-D7KIS-TK.d.ts +36 -0
- package/dist/coverage.cjs +448 -485
- package/dist/coverage.d.ts +13 -62
- package/dist/coverage.js +447 -484
- package/dist/coverage.mjs +447 -484
- package/dist/database.cjs +819 -828
- package/dist/database.d.ts +8 -24
- package/dist/database.js +818 -829
- package/dist/database.mjs +818 -829
- package/dist/desktop-auto-render.cjs +1700 -1523
- package/dist/desktop-auto-render.d.ts +4 -12
- package/dist/desktop-auto-render.js +1695 -1518
- package/dist/desktop-auto-render.mjs +1696 -1519
- package/dist/desktop.cjs +3 -1
- package/dist/desktop.d.ts +4 -1
- package/dist/desktop.js +1 -1
- package/dist/desktop.mjs +1 -1
- package/dist/dev-build.cjs +830 -0
- package/dist/dev-build.d.ts +53 -0
- package/dist/dev-build.js +3318 -0
- package/dist/dev-build.mjs +797 -0
- package/dist/dom.cjs +717 -591
- package/dist/dom.d.ts +2 -17
- package/dist/dom.js +714 -588
- package/dist/dom.mjs +716 -590
- package/dist/el.cjs +62 -52
- package/dist/el.d.ts +5 -12
- package/dist/el.js +60 -52
- package/dist/el.mjs +60 -52
- package/dist/fs.cjs +72 -63
- package/dist/fs.d.ts +22 -19
- package/dist/fs.js +71 -62
- package/dist/fs.mjs +71 -62
- package/dist/hmr.cjs +40 -14
- package/dist/hmr.d.ts +11 -23
- package/dist/hmr.js +38 -14
- package/dist/hmr.mjs +38 -14
- package/dist/http.cjs +251 -99
- package/dist/http.d.ts +38 -104
- package/dist/http.js +249 -99
- package/dist/http.mjs +249 -99
- package/dist/https.cjs +524 -228
- package/dist/https.d.ts +44 -36
- package/dist/https.js +520 -226
- package/dist/https.mjs +522 -228
- package/dist/index.cjs +7502 -7691
- package/dist/index.d.ts +6 -3
- package/dist/index.js +7486 -7677
- package/dist/index.mjs +7497 -7687
- package/dist/mime-types.cjs +10 -4
- package/dist/mime-types.d.ts +8 -11
- package/dist/mime-types.js +9 -3
- package/dist/mime-types.mjs +9 -3
- package/dist/native.cjs +8616 -8870
- package/dist/native.d.ts +7 -10
- package/dist/native.js +8682 -8936
- package/dist/native.mjs +8615 -8869
- package/dist/path.cjs +83 -77
- package/dist/path.d.ts +29 -29
- package/dist/path.js +82 -76
- package/dist/path.mjs +82 -76
- package/dist/pm.cjs +3300 -0
- package/dist/pm.d.ts +256 -0
- package/dist/pm.js +5638 -0
- package/dist/pm.mjs +3196 -0
- package/dist/preview-build.cjs +712 -0
- package/dist/preview-build.d.ts +59 -0
- package/dist/preview-build.js +3194 -0
- package/dist/preview-build.mjs +676 -0
- package/dist/render-context.cjs +13 -2
- package/dist/render-context.d.ts +9 -34
- package/dist/render-context.js +11 -2
- package/dist/render-context.mjs +11 -2
- package/dist/router.cjs +787 -646
- package/dist/router.d.ts +8 -14
- package/dist/router.js +786 -645
- package/dist/router.mjs +786 -645
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/server.cjs +3254 -2684
- package/dist/server.d.ts +47 -5
- package/dist/server.js +3427 -2859
- package/dist/server.mjs +3397 -2829
- package/dist/smtp-server.cjs +16 -3
- package/dist/smtp-server.d.ts +12 -26
- package/dist/smtp-server.js +18 -5
- package/dist/smtp-server.mjs +16 -3
- package/dist/state-DvEkDehk.d.ts +195 -0
- package/dist/state.cjs +768 -659
- package/dist/state.d.ts +11 -71
- package/dist/state.js +760 -651
- package/dist/state.mjs +767 -658
- package/dist/style.cjs +1011 -968
- package/dist/style.d.ts +13 -127
- package/dist/style.js +1009 -970
- package/dist/style.mjs +1011 -971
- package/dist/test-reporter.cjs +332 -316
- package/dist/test-reporter.d.ts +28 -33
- package/dist/test-reporter.js +328 -312
- package/dist/test-reporter.mjs +328 -312
- package/dist/test-runtime.cjs +927 -968
- package/dist/test-runtime.d.ts +24 -99
- package/dist/test-runtime.js +922 -965
- package/dist/test-runtime.mjs +922 -965
- package/dist/test.cjs +4428 -4273
- package/dist/test.d.ts +2 -8
- package/dist/test.js +4307 -4154
- package/dist/test.mjs +4419 -4267
- package/dist/types-BONVzPtp.d.ts +59 -0
- package/dist/types-BR4wMiVx.d.ts +32 -0
- package/dist/types-C4gKykuG.d.ts +23 -0
- package/dist/types-CIhpN1-K.d.ts +64 -0
- package/dist/types-Ckj8md_j.d.ts +84 -0
- package/dist/types-CpjQTAkX.d.ts +24 -0
- package/dist/types-D0LjrYjS.d.ts +14 -0
- package/dist/types-DAisuVr5.d.ts +75 -0
- package/dist/types-tJn88E1N.d.ts +242 -0
- package/dist/types.d.ts +50 -237
- package/dist/universal.cjs +1 -1
- package/dist/universal.d.ts +1 -7
- package/dist/universal.js +1 -1
- package/dist/universal.mjs +1 -1
- package/dist/websocket-XfyK23zD.d.ts +119 -0
- package/dist/ws.cjs +129 -108
- package/dist/ws.d.ts +21 -131
- package/dist/ws.js +128 -109
- package/dist/ws.mjs +128 -109
- package/dist/wss.cjs +757 -479
- package/dist/wss.d.ts +31 -28
- package/dist/wss.js +755 -479
- package/dist/wss.mjs +758 -482
- package/package.json +8 -1
- package/vendor/epaint-0.31.1/src/image.rs +418 -0
- package/dist/server-uMQvZAll.d.ts +0 -458
package/dist/path.cjs
CHANGED
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/path.ts
|
|
20
|
+
// src/server/path/index.ts
|
|
21
21
|
var path_exports = {};
|
|
22
22
|
__export(path_exports, {
|
|
23
23
|
basename: () => basename,
|
|
@@ -40,7 +40,7 @@ __export(path_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(path_exports);
|
|
42
42
|
|
|
43
|
-
// src/runtime.ts
|
|
43
|
+
// src/shares/runtime.ts
|
|
44
44
|
var runtime = (() => {
|
|
45
45
|
if (typeof Deno !== "undefined") return "deno";
|
|
46
46
|
if (typeof Bun !== "undefined") return "bun";
|
|
@@ -50,37 +50,35 @@ var isNode = runtime === "node";
|
|
|
50
50
|
var isBun = runtime === "bun";
|
|
51
51
|
var isDeno = runtime === "deno";
|
|
52
52
|
|
|
53
|
-
// src/path.ts
|
|
53
|
+
// src/server/path/platform.ts
|
|
54
54
|
function getSeparator(isWin) {
|
|
55
55
|
return isWin ? "\\" : "/";
|
|
56
56
|
}
|
|
57
57
|
function getCwd() {
|
|
58
58
|
if (isNode || isBun) {
|
|
59
59
|
return process.cwd();
|
|
60
|
-
}
|
|
60
|
+
}
|
|
61
|
+
if (isDeno) {
|
|
61
62
|
return Deno.cwd();
|
|
62
63
|
}
|
|
63
64
|
return "/";
|
|
64
65
|
}
|
|
66
|
+
var isWindows = (() => {
|
|
67
|
+
if (isNode) {
|
|
68
|
+
return process.platform === "win32";
|
|
69
|
+
}
|
|
70
|
+
if (isDeno) {
|
|
71
|
+
return Deno.build.os === "windows";
|
|
72
|
+
}
|
|
73
|
+
return typeof process !== "undefined" && process.platform === "win32";
|
|
74
|
+
})();
|
|
75
|
+
var sep = isWindows ? "\\" : "/";
|
|
76
|
+
var delimiter = isWindows ? ";" : ":";
|
|
77
|
+
|
|
78
|
+
// src/server/path/operations.ts
|
|
65
79
|
function findLastSeparator(path) {
|
|
66
80
|
return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
67
81
|
}
|
|
68
|
-
function createPathOps(isWin) {
|
|
69
|
-
return {
|
|
70
|
-
sep: getSeparator(isWin),
|
|
71
|
-
delimiter: isWin ? ";" : ":",
|
|
72
|
-
normalize: (path) => normalizePath(path, isWin),
|
|
73
|
-
join: (...paths) => joinPaths(paths, isWin),
|
|
74
|
-
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
75
|
-
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
76
|
-
relative: (from, to) => relativePath(from, to, isWin),
|
|
77
|
-
dirname: (path) => getDirname(path, isWin),
|
|
78
|
-
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
79
|
-
extname: (path) => getExtname(path),
|
|
80
|
-
parse: (path) => parsePath(path, isWin),
|
|
81
|
-
format: (pathObject) => formatPath(pathObject, isWin)
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
82
|
function isAbsolutePosix(path) {
|
|
85
83
|
return path.length > 0 && path[0] === "/";
|
|
86
84
|
}
|
|
@@ -101,30 +99,18 @@ function isAbsoluteWin(path) {
|
|
|
101
99
|
}
|
|
102
100
|
return false;
|
|
103
101
|
}
|
|
104
|
-
var isWindows = (() => {
|
|
105
|
-
if (isNode) {
|
|
106
|
-
return process.platform === "win32";
|
|
107
|
-
} else if (isDeno) {
|
|
108
|
-
return Deno.build.os === "windows";
|
|
109
|
-
}
|
|
110
|
-
return typeof process !== "undefined" && process.platform === "win32";
|
|
111
|
-
})();
|
|
112
|
-
var sep = isWindows ? "\\" : "/";
|
|
113
|
-
var delimiter = isWindows ? ";" : ":";
|
|
114
|
-
var posix = createPathOps(false);
|
|
115
|
-
var win32 = createPathOps(true);
|
|
116
102
|
function normalizePath(path, isWin) {
|
|
117
103
|
if (path.length === 0) return ".";
|
|
118
104
|
const separator = getSeparator(isWin);
|
|
119
105
|
const isAbsolute2 = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
120
106
|
const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
|
|
121
|
-
|
|
107
|
+
const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
|
|
122
108
|
const parts = normalized.split(separator);
|
|
123
109
|
const result = [];
|
|
124
|
-
for (let
|
|
125
|
-
const part = parts[
|
|
110
|
+
for (let index = 0; index < parts.length; index++) {
|
|
111
|
+
const part = parts[index];
|
|
126
112
|
if (part === "" || part === ".") {
|
|
127
|
-
if (
|
|
113
|
+
if (index === 0 && isAbsolute2) result.push("");
|
|
128
114
|
continue;
|
|
129
115
|
}
|
|
130
116
|
if (part === "..") {
|
|
@@ -139,21 +125,21 @@ function normalizePath(path, isWin) {
|
|
|
139
125
|
result.push(part);
|
|
140
126
|
}
|
|
141
127
|
}
|
|
142
|
-
let
|
|
143
|
-
if (
|
|
128
|
+
let finalPath = result.join(separator);
|
|
129
|
+
if (finalPath.length === 0) {
|
|
144
130
|
return isAbsolute2 ? separator : ".";
|
|
145
131
|
}
|
|
146
|
-
if (trailingSeparator &&
|
|
147
|
-
|
|
132
|
+
if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
|
|
133
|
+
finalPath += separator;
|
|
148
134
|
}
|
|
149
|
-
return
|
|
135
|
+
return finalPath;
|
|
150
136
|
}
|
|
151
137
|
function joinPaths(paths, isWin) {
|
|
152
138
|
if (paths.length === 0) return ".";
|
|
153
139
|
const separator = getSeparator(isWin);
|
|
154
140
|
let joined = "";
|
|
155
|
-
for (let
|
|
156
|
-
const path = paths[
|
|
141
|
+
for (let index = 0; index < paths.length; index++) {
|
|
142
|
+
const path = paths[index];
|
|
157
143
|
if (path && path.length > 0) {
|
|
158
144
|
if (joined.length === 0) {
|
|
159
145
|
joined = path;
|
|
@@ -168,43 +154,43 @@ function joinPaths(paths, isWin) {
|
|
|
168
154
|
function resolvePaths(paths, isWin) {
|
|
169
155
|
const separator = getSeparator(isWin);
|
|
170
156
|
let resolved = "";
|
|
171
|
-
let
|
|
172
|
-
for (let
|
|
173
|
-
const path = paths[
|
|
157
|
+
let absolute = false;
|
|
158
|
+
for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
|
|
159
|
+
const path = paths[index];
|
|
174
160
|
if (path && path.length > 0) {
|
|
175
161
|
resolved = path + (resolved.length > 0 ? separator + resolved : "");
|
|
176
|
-
|
|
162
|
+
absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
|
|
177
163
|
}
|
|
178
164
|
}
|
|
179
|
-
if (!
|
|
165
|
+
if (!absolute) {
|
|
180
166
|
const cwd = getCwd();
|
|
181
167
|
resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
|
|
182
168
|
}
|
|
183
169
|
return normalizePath(resolved, isWin);
|
|
184
170
|
}
|
|
185
171
|
function relativePath(from, to, isWin) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (
|
|
172
|
+
const resolvedFrom = resolvePaths([from], isWin);
|
|
173
|
+
const resolvedTo = resolvePaths([to], isWin);
|
|
174
|
+
if (resolvedFrom === resolvedTo) return "";
|
|
189
175
|
const separator = getSeparator(isWin);
|
|
190
|
-
const fromParts =
|
|
191
|
-
const toParts =
|
|
192
|
-
let commonLength = 0;
|
|
176
|
+
const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
|
|
177
|
+
const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
|
|
193
178
|
const minLength = Math.min(fromParts.length, toParts.length);
|
|
194
|
-
|
|
195
|
-
|
|
179
|
+
let commonLength = 0;
|
|
180
|
+
for (let index = 0; index < minLength; index++) {
|
|
181
|
+
if (fromParts[index] === toParts[index]) {
|
|
196
182
|
commonLength++;
|
|
197
183
|
} else {
|
|
198
184
|
break;
|
|
199
185
|
}
|
|
200
186
|
}
|
|
201
|
-
const upCount = fromParts.length - commonLength;
|
|
202
187
|
const result = [];
|
|
203
|
-
|
|
188
|
+
const upCount = fromParts.length - commonLength;
|
|
189
|
+
for (let index = 0; index < upCount; index++) {
|
|
204
190
|
result.push("..");
|
|
205
191
|
}
|
|
206
|
-
for (let
|
|
207
|
-
result.push(toParts[
|
|
192
|
+
for (let index = commonLength; index < toParts.length; index++) {
|
|
193
|
+
result.push(toParts[index]);
|
|
208
194
|
}
|
|
209
195
|
return result.join(separator) || ".";
|
|
210
196
|
}
|
|
@@ -212,15 +198,15 @@ function getDirname(path, isWin) {
|
|
|
212
198
|
if (path.length === 0) return ".";
|
|
213
199
|
const separator = getSeparator(isWin);
|
|
214
200
|
const normalized = normalizePath(path, isWin);
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
if (
|
|
218
|
-
return normalized.slice(0,
|
|
201
|
+
const lastSeparatorIndex = normalized.lastIndexOf(separator);
|
|
202
|
+
if (lastSeparatorIndex === -1) return ".";
|
|
203
|
+
if (lastSeparatorIndex === 0) return separator;
|
|
204
|
+
return normalized.slice(0, lastSeparatorIndex);
|
|
219
205
|
}
|
|
220
206
|
function getBasename(path, ext, isWin) {
|
|
221
207
|
if (path.length === 0) return "";
|
|
222
|
-
const
|
|
223
|
-
let base =
|
|
208
|
+
const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
|
|
209
|
+
let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
|
|
224
210
|
if (ext && base.endsWith(ext)) {
|
|
225
211
|
base = base.slice(0, base.length - ext.length);
|
|
226
212
|
}
|
|
@@ -228,8 +214,8 @@ function getBasename(path, ext, isWin) {
|
|
|
228
214
|
}
|
|
229
215
|
function getExtname(path) {
|
|
230
216
|
const lastDotIndex = path.lastIndexOf(".");
|
|
231
|
-
const
|
|
232
|
-
if (lastDotIndex === -1 || lastDotIndex <
|
|
217
|
+
const lastSeparatorIndex = findLastSeparator(path);
|
|
218
|
+
if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
|
|
233
219
|
return "";
|
|
234
220
|
}
|
|
235
221
|
return path.slice(lastDotIndex);
|
|
@@ -245,10 +231,8 @@ function parsePath(path, isWin) {
|
|
|
245
231
|
} else if (path[0] === "\\" || path[0] === "/") {
|
|
246
232
|
root = "\\";
|
|
247
233
|
}
|
|
248
|
-
} else {
|
|
249
|
-
|
|
250
|
-
root = "/";
|
|
251
|
-
}
|
|
234
|
+
} else if (path[0] === "/") {
|
|
235
|
+
root = "/";
|
|
252
236
|
}
|
|
253
237
|
const dir = getDirname(path, isWin);
|
|
254
238
|
const base = getBasename(path, void 0, isWin);
|
|
@@ -264,6 +248,31 @@ function formatPath(pathObject, isWin) {
|
|
|
264
248
|
if (dir === pathObject.root) return dir + base;
|
|
265
249
|
return dir + separator + base;
|
|
266
250
|
}
|
|
251
|
+
function createPathOps(isWin) {
|
|
252
|
+
return {
|
|
253
|
+
sep: getSeparator(isWin),
|
|
254
|
+
delimiter: isWin ? ";" : ":",
|
|
255
|
+
normalize: (path) => normalizePath(path, isWin),
|
|
256
|
+
join: (...paths) => joinPaths(paths, isWin),
|
|
257
|
+
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
258
|
+
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
259
|
+
relative: (from, to) => relativePath(from, to, isWin),
|
|
260
|
+
dirname: (path) => getDirname(path, isWin),
|
|
261
|
+
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
262
|
+
extname: (path) => getExtname(path),
|
|
263
|
+
parse: (path) => parsePath(path, isWin),
|
|
264
|
+
format: (pathObject) => formatPath(pathObject, isWin)
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/server/path/runtime.ts
|
|
269
|
+
function getRuntime() {
|
|
270
|
+
return runtime;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/server/path/index.ts
|
|
274
|
+
var posix = createPathOps(false);
|
|
275
|
+
var win32 = createPathOps(true);
|
|
267
276
|
function normalize(path) {
|
|
268
277
|
return normalizePath(path, isWindows);
|
|
269
278
|
}
|
|
@@ -274,7 +283,7 @@ function resolve(...paths) {
|
|
|
274
283
|
return resolvePaths(paths, isWindows);
|
|
275
284
|
}
|
|
276
285
|
function isAbsolute(path) {
|
|
277
|
-
return isWindows ?
|
|
286
|
+
return isWindows ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
278
287
|
}
|
|
279
288
|
function relative(from, to) {
|
|
280
289
|
return relativePath(from, to, isWindows);
|
|
@@ -296,7 +305,7 @@ function format(pathObject) {
|
|
|
296
305
|
}
|
|
297
306
|
function toNamespacedPath(path) {
|
|
298
307
|
if (!isWindows || path.length === 0) return path;
|
|
299
|
-
const resolved =
|
|
308
|
+
const resolved = resolvePaths([path], true);
|
|
300
309
|
if (resolved.length >= 3) {
|
|
301
310
|
if (resolved[0] === "\\") {
|
|
302
311
|
if (resolved[1] === "\\" && resolved[2] !== "?") {
|
|
@@ -308,9 +317,6 @@ function toNamespacedPath(path) {
|
|
|
308
317
|
}
|
|
309
318
|
return path;
|
|
310
319
|
}
|
|
311
|
-
function getRuntime() {
|
|
312
|
-
return runtime;
|
|
313
|
-
}
|
|
314
320
|
var path_default = {
|
|
315
321
|
sep,
|
|
316
322
|
delimiter,
|
package/dist/path.d.ts
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Pure implementation without external dependencies
|
|
4
|
-
* Compatible with Node.js 'path' module API
|
|
5
|
-
* Works on Node.js, Bun, and Deno
|
|
2
|
+
* Get current runtime
|
|
6
3
|
*/
|
|
4
|
+
declare function getRuntime(): 'node' | 'bun' | 'deno';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Path object interface
|
|
8
|
+
*/
|
|
9
|
+
interface ParsedPath {
|
|
10
|
+
root: string;
|
|
11
|
+
dir: string;
|
|
12
|
+
base: string;
|
|
13
|
+
ext: string;
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
interface FormatInputPathObject {
|
|
17
|
+
root?: string;
|
|
18
|
+
dir?: string;
|
|
19
|
+
base?: string;
|
|
20
|
+
ext?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
7
24
|
/**
|
|
8
25
|
* Path separator
|
|
9
26
|
*/
|
|
@@ -12,6 +29,14 @@ declare const sep: string;
|
|
|
12
29
|
* Path delimiter
|
|
13
30
|
*/
|
|
14
31
|
declare const delimiter: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Path module with unified API across runtimes
|
|
35
|
+
* Pure implementation without external dependencies
|
|
36
|
+
* Compatible with Node.js 'path' module API
|
|
37
|
+
* Works on Node.js, Bun, and Deno
|
|
38
|
+
*/
|
|
39
|
+
|
|
15
40
|
/**
|
|
16
41
|
* POSIX path operations
|
|
17
42
|
*/
|
|
@@ -46,23 +71,6 @@ declare const win32: {
|
|
|
46
71
|
parse: (path: string) => ParsedPath;
|
|
47
72
|
format: (pathObject: FormatInputPathObject) => string;
|
|
48
73
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Path object interface
|
|
51
|
-
*/
|
|
52
|
-
interface ParsedPath {
|
|
53
|
-
root: string;
|
|
54
|
-
dir: string;
|
|
55
|
-
base: string;
|
|
56
|
-
ext: string;
|
|
57
|
-
name: string;
|
|
58
|
-
}
|
|
59
|
-
interface FormatInputPathObject {
|
|
60
|
-
root?: string;
|
|
61
|
-
dir?: string;
|
|
62
|
-
base?: string;
|
|
63
|
-
ext?: string;
|
|
64
|
-
name?: string;
|
|
65
|
-
}
|
|
66
74
|
/**
|
|
67
75
|
* Normalize a path (platform-specific)
|
|
68
76
|
*/
|
|
@@ -107,14 +115,6 @@ declare function format(pathObject: FormatInputPathObject): string;
|
|
|
107
115
|
* Convert to namespaced path (Windows only)
|
|
108
116
|
*/
|
|
109
117
|
declare function toNamespacedPath(path: string): string;
|
|
110
|
-
/**
|
|
111
|
-
* Get current runtime
|
|
112
|
-
*/
|
|
113
|
-
declare function getRuntime(): 'node' | 'bun' | 'deno';
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Default export
|
|
117
|
-
*/
|
|
118
118
|
declare const _default: {
|
|
119
119
|
sep: string;
|
|
120
120
|
delimiter: string;
|
package/dist/path.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
// src/runtime.ts
|
|
3
|
+
// src/shares/runtime.ts
|
|
4
4
|
var runtime = (() => {
|
|
5
5
|
if (typeof Deno !== "undefined") return "deno";
|
|
6
6
|
if (typeof Bun !== "undefined") return "bun";
|
|
@@ -10,37 +10,35 @@
|
|
|
10
10
|
var isBun = runtime === "bun";
|
|
11
11
|
var isDeno = runtime === "deno";
|
|
12
12
|
|
|
13
|
-
// src/path.ts
|
|
13
|
+
// src/server/path/platform.ts
|
|
14
14
|
function getSeparator(isWin) {
|
|
15
15
|
return isWin ? "\\" : "/";
|
|
16
16
|
}
|
|
17
17
|
function getCwd() {
|
|
18
18
|
if (isNode || isBun) {
|
|
19
19
|
return process.cwd();
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
|
+
if (isDeno) {
|
|
21
22
|
return Deno.cwd();
|
|
22
23
|
}
|
|
23
24
|
return "/";
|
|
24
25
|
}
|
|
26
|
+
var isWindows = (() => {
|
|
27
|
+
if (isNode) {
|
|
28
|
+
return process.platform === "win32";
|
|
29
|
+
}
|
|
30
|
+
if (isDeno) {
|
|
31
|
+
return Deno.build.os === "windows";
|
|
32
|
+
}
|
|
33
|
+
return typeof process !== "undefined" && process.platform === "win32";
|
|
34
|
+
})();
|
|
35
|
+
var sep = isWindows ? "\\" : "/";
|
|
36
|
+
var delimiter = isWindows ? ";" : ":";
|
|
37
|
+
|
|
38
|
+
// src/server/path/operations.ts
|
|
25
39
|
function findLastSeparator(path) {
|
|
26
40
|
return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
27
41
|
}
|
|
28
|
-
function createPathOps(isWin) {
|
|
29
|
-
return {
|
|
30
|
-
sep: getSeparator(isWin),
|
|
31
|
-
delimiter: isWin ? ";" : ":",
|
|
32
|
-
normalize: (path) => normalizePath(path, isWin),
|
|
33
|
-
join: (...paths) => joinPaths(paths, isWin),
|
|
34
|
-
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
35
|
-
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
36
|
-
relative: (from, to) => relativePath(from, to, isWin),
|
|
37
|
-
dirname: (path) => getDirname(path, isWin),
|
|
38
|
-
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
39
|
-
extname: (path) => getExtname(path),
|
|
40
|
-
parse: (path) => parsePath(path, isWin),
|
|
41
|
-
format: (pathObject) => formatPath(pathObject, isWin)
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
42
|
function isAbsolutePosix(path) {
|
|
45
43
|
return path.length > 0 && path[0] === "/";
|
|
46
44
|
}
|
|
@@ -61,30 +59,18 @@
|
|
|
61
59
|
}
|
|
62
60
|
return false;
|
|
63
61
|
}
|
|
64
|
-
var isWindows = (() => {
|
|
65
|
-
if (isNode) {
|
|
66
|
-
return process.platform === "win32";
|
|
67
|
-
} else if (isDeno) {
|
|
68
|
-
return Deno.build.os === "windows";
|
|
69
|
-
}
|
|
70
|
-
return typeof process !== "undefined" && process.platform === "win32";
|
|
71
|
-
})();
|
|
72
|
-
var sep = isWindows ? "\\" : "/";
|
|
73
|
-
var delimiter = isWindows ? ";" : ":";
|
|
74
|
-
var posix = createPathOps(false);
|
|
75
|
-
var win32 = createPathOps(true);
|
|
76
62
|
function normalizePath(path, isWin) {
|
|
77
63
|
if (path.length === 0) return ".";
|
|
78
64
|
const separator = getSeparator(isWin);
|
|
79
65
|
const isAbsolute2 = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
80
66
|
const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
|
|
81
|
-
|
|
67
|
+
const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
|
|
82
68
|
const parts = normalized.split(separator);
|
|
83
69
|
const result = [];
|
|
84
|
-
for (let
|
|
85
|
-
const part = parts[
|
|
70
|
+
for (let index = 0; index < parts.length; index++) {
|
|
71
|
+
const part = parts[index];
|
|
86
72
|
if (part === "" || part === ".") {
|
|
87
|
-
if (
|
|
73
|
+
if (index === 0 && isAbsolute2) result.push("");
|
|
88
74
|
continue;
|
|
89
75
|
}
|
|
90
76
|
if (part === "..") {
|
|
@@ -99,21 +85,21 @@
|
|
|
99
85
|
result.push(part);
|
|
100
86
|
}
|
|
101
87
|
}
|
|
102
|
-
let
|
|
103
|
-
if (
|
|
88
|
+
let finalPath = result.join(separator);
|
|
89
|
+
if (finalPath.length === 0) {
|
|
104
90
|
return isAbsolute2 ? separator : ".";
|
|
105
91
|
}
|
|
106
|
-
if (trailingSeparator &&
|
|
107
|
-
|
|
92
|
+
if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
|
|
93
|
+
finalPath += separator;
|
|
108
94
|
}
|
|
109
|
-
return
|
|
95
|
+
return finalPath;
|
|
110
96
|
}
|
|
111
97
|
function joinPaths(paths, isWin) {
|
|
112
98
|
if (paths.length === 0) return ".";
|
|
113
99
|
const separator = getSeparator(isWin);
|
|
114
100
|
let joined = "";
|
|
115
|
-
for (let
|
|
116
|
-
const path = paths[
|
|
101
|
+
for (let index = 0; index < paths.length; index++) {
|
|
102
|
+
const path = paths[index];
|
|
117
103
|
if (path && path.length > 0) {
|
|
118
104
|
if (joined.length === 0) {
|
|
119
105
|
joined = path;
|
|
@@ -128,43 +114,43 @@
|
|
|
128
114
|
function resolvePaths(paths, isWin) {
|
|
129
115
|
const separator = getSeparator(isWin);
|
|
130
116
|
let resolved = "";
|
|
131
|
-
let
|
|
132
|
-
for (let
|
|
133
|
-
const path = paths[
|
|
117
|
+
let absolute = false;
|
|
118
|
+
for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
|
|
119
|
+
const path = paths[index];
|
|
134
120
|
if (path && path.length > 0) {
|
|
135
121
|
resolved = path + (resolved.length > 0 ? separator + resolved : "");
|
|
136
|
-
|
|
122
|
+
absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
|
|
137
123
|
}
|
|
138
124
|
}
|
|
139
|
-
if (!
|
|
125
|
+
if (!absolute) {
|
|
140
126
|
const cwd = getCwd();
|
|
141
127
|
resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
|
|
142
128
|
}
|
|
143
129
|
return normalizePath(resolved, isWin);
|
|
144
130
|
}
|
|
145
131
|
function relativePath(from, to, isWin) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (
|
|
132
|
+
const resolvedFrom = resolvePaths([from], isWin);
|
|
133
|
+
const resolvedTo = resolvePaths([to], isWin);
|
|
134
|
+
if (resolvedFrom === resolvedTo) return "";
|
|
149
135
|
const separator = getSeparator(isWin);
|
|
150
|
-
const fromParts =
|
|
151
|
-
const toParts =
|
|
152
|
-
let commonLength = 0;
|
|
136
|
+
const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
|
|
137
|
+
const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
|
|
153
138
|
const minLength = Math.min(fromParts.length, toParts.length);
|
|
154
|
-
|
|
155
|
-
|
|
139
|
+
let commonLength = 0;
|
|
140
|
+
for (let index = 0; index < minLength; index++) {
|
|
141
|
+
if (fromParts[index] === toParts[index]) {
|
|
156
142
|
commonLength++;
|
|
157
143
|
} else {
|
|
158
144
|
break;
|
|
159
145
|
}
|
|
160
146
|
}
|
|
161
|
-
const upCount = fromParts.length - commonLength;
|
|
162
147
|
const result = [];
|
|
163
|
-
|
|
148
|
+
const upCount = fromParts.length - commonLength;
|
|
149
|
+
for (let index = 0; index < upCount; index++) {
|
|
164
150
|
result.push("..");
|
|
165
151
|
}
|
|
166
|
-
for (let
|
|
167
|
-
result.push(toParts[
|
|
152
|
+
for (let index = commonLength; index < toParts.length; index++) {
|
|
153
|
+
result.push(toParts[index]);
|
|
168
154
|
}
|
|
169
155
|
return result.join(separator) || ".";
|
|
170
156
|
}
|
|
@@ -172,15 +158,15 @@
|
|
|
172
158
|
if (path.length === 0) return ".";
|
|
173
159
|
const separator = getSeparator(isWin);
|
|
174
160
|
const normalized = normalizePath(path, isWin);
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
if (
|
|
178
|
-
return normalized.slice(0,
|
|
161
|
+
const lastSeparatorIndex = normalized.lastIndexOf(separator);
|
|
162
|
+
if (lastSeparatorIndex === -1) return ".";
|
|
163
|
+
if (lastSeparatorIndex === 0) return separator;
|
|
164
|
+
return normalized.slice(0, lastSeparatorIndex);
|
|
179
165
|
}
|
|
180
166
|
function getBasename(path, ext, isWin) {
|
|
181
167
|
if (path.length === 0) return "";
|
|
182
|
-
const
|
|
183
|
-
let base =
|
|
168
|
+
const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
|
|
169
|
+
let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
|
|
184
170
|
if (ext && base.endsWith(ext)) {
|
|
185
171
|
base = base.slice(0, base.length - ext.length);
|
|
186
172
|
}
|
|
@@ -188,8 +174,8 @@
|
|
|
188
174
|
}
|
|
189
175
|
function getExtname(path) {
|
|
190
176
|
const lastDotIndex = path.lastIndexOf(".");
|
|
191
|
-
const
|
|
192
|
-
if (lastDotIndex === -1 || lastDotIndex <
|
|
177
|
+
const lastSeparatorIndex = findLastSeparator(path);
|
|
178
|
+
if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
|
|
193
179
|
return "";
|
|
194
180
|
}
|
|
195
181
|
return path.slice(lastDotIndex);
|
|
@@ -205,10 +191,8 @@
|
|
|
205
191
|
} else if (path[0] === "\\" || path[0] === "/") {
|
|
206
192
|
root = "\\";
|
|
207
193
|
}
|
|
208
|
-
} else {
|
|
209
|
-
|
|
210
|
-
root = "/";
|
|
211
|
-
}
|
|
194
|
+
} else if (path[0] === "/") {
|
|
195
|
+
root = "/";
|
|
212
196
|
}
|
|
213
197
|
const dir = getDirname(path, isWin);
|
|
214
198
|
const base = getBasename(path, void 0, isWin);
|
|
@@ -224,6 +208,31 @@
|
|
|
224
208
|
if (dir === pathObject.root) return dir + base;
|
|
225
209
|
return dir + separator + base;
|
|
226
210
|
}
|
|
211
|
+
function createPathOps(isWin) {
|
|
212
|
+
return {
|
|
213
|
+
sep: getSeparator(isWin),
|
|
214
|
+
delimiter: isWin ? ";" : ":",
|
|
215
|
+
normalize: (path) => normalizePath(path, isWin),
|
|
216
|
+
join: (...paths) => joinPaths(paths, isWin),
|
|
217
|
+
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
218
|
+
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
219
|
+
relative: (from, to) => relativePath(from, to, isWin),
|
|
220
|
+
dirname: (path) => getDirname(path, isWin),
|
|
221
|
+
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
222
|
+
extname: (path) => getExtname(path),
|
|
223
|
+
parse: (path) => parsePath(path, isWin),
|
|
224
|
+
format: (pathObject) => formatPath(pathObject, isWin)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/server/path/runtime.ts
|
|
229
|
+
function getRuntime() {
|
|
230
|
+
return runtime;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/server/path/index.ts
|
|
234
|
+
var posix = createPathOps(false);
|
|
235
|
+
var win32 = createPathOps(true);
|
|
227
236
|
function normalize(path) {
|
|
228
237
|
return normalizePath(path, isWindows);
|
|
229
238
|
}
|
|
@@ -234,7 +243,7 @@
|
|
|
234
243
|
return resolvePaths(paths, isWindows);
|
|
235
244
|
}
|
|
236
245
|
function isAbsolute(path) {
|
|
237
|
-
return isWindows ?
|
|
246
|
+
return isWindows ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
238
247
|
}
|
|
239
248
|
function relative(from, to) {
|
|
240
249
|
return relativePath(from, to, isWindows);
|
|
@@ -256,7 +265,7 @@
|
|
|
256
265
|
}
|
|
257
266
|
function toNamespacedPath(path) {
|
|
258
267
|
if (!isWindows || path.length === 0) return path;
|
|
259
|
-
const resolved =
|
|
268
|
+
const resolved = resolvePaths([path], true);
|
|
260
269
|
if (resolved.length >= 3) {
|
|
261
270
|
if (resolved[0] === "\\") {
|
|
262
271
|
if (resolved[1] === "\\" && resolved[2] !== "?") {
|
|
@@ -268,9 +277,6 @@
|
|
|
268
277
|
}
|
|
269
278
|
return path;
|
|
270
279
|
}
|
|
271
|
-
function getRuntime() {
|
|
272
|
-
return runtime;
|
|
273
|
-
}
|
|
274
280
|
var path_default = {
|
|
275
281
|
sep,
|
|
276
282
|
delimiter,
|