elit 3.6.5 → 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/README.md +6 -0
- package/dist/build.cjs +421 -331
- package/dist/build.d.ts +1 -16
- 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 +21608 -20241
- package/dist/cli.d.ts +19 -37
- package/dist/cli.mjs +21262 -19910
- package/dist/config.cjs +357 -350
- package/dist/config.d.ts +19 -240
- 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 -59
- 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 -1522
- package/dist/desktop-auto-render.d.ts +4 -9
- package/dist/desktop-auto-render.js +1695 -1517
- package/dist/desktop-auto-render.mjs +1696 -1518
- 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 -590
- package/dist/dom.d.ts +2 -15
- package/dist/dom.js +714 -587
- package/dist/dom.mjs +716 -589
- package/dist/el.cjs +62 -52
- package/dist/el.d.ts +5 -10
- 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 -7690
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7486 -7676
- package/dist/index.mjs +7497 -7686
- 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 -8869
- package/dist/native.d.ts +7 -8
- package/dist/native.js +8682 -8935
- package/dist/native.mjs +8615 -8868
- 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 -31
- package/dist/render-context.js +11 -2
- package/dist/render-context.mjs +11 -2
- package/dist/router.cjs +787 -645
- package/dist/router.d.ts +8 -12
- package/dist/router.js +786 -644
- package/dist/router.mjs +786 -644
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/server.cjs +3315 -2603
- package/dist/server.d.ts +49 -4
- package/dist/server.js +7611 -2834
- package/dist/server.mjs +3317 -2607
- package/dist/smtp-server.cjs +128 -0
- package/dist/smtp-server.d.ts +27 -0
- package/dist/smtp-server.js +4199 -0
- package/dist/smtp-server.mjs +100 -0
- package/dist/state-DvEkDehk.d.ts +195 -0
- package/dist/state.cjs +768 -658
- package/dist/state.d.ts +11 -69
- package/dist/state.js +760 -650
- package/dist/state.mjs +767 -657
- 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 +71 -226
- package/dist/universal.cjs +1 -1
- package/dist/universal.d.ts +1 -5
- 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 +16 -1
- package/vendor/epaint-0.31.1/src/image.rs +418 -0
- package/dist/server-CcBFc2F5.d.ts +0 -449
package/dist/chokidar.cjs
CHANGED
|
@@ -17,18 +17,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/chokidar.ts
|
|
20
|
+
// src/server/chokidar/index.ts
|
|
21
21
|
var chokidar_exports = {};
|
|
22
22
|
__export(chokidar_exports, {
|
|
23
23
|
FSWatcher: () => FSWatcher,
|
|
24
24
|
default: () => chokidar_default,
|
|
25
|
-
getRuntime: () =>
|
|
25
|
+
getRuntime: () => getRuntime2,
|
|
26
26
|
watch: () => watch
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(chokidar_exports);
|
|
29
|
-
var import_events = require("events");
|
|
30
29
|
|
|
31
|
-
// src/runtime.ts
|
|
30
|
+
// src/shares/runtime.ts
|
|
32
31
|
var runtime = (() => {
|
|
33
32
|
if (typeof Deno !== "undefined") return "deno";
|
|
34
33
|
if (typeof Bun !== "undefined") return "bun";
|
|
@@ -38,30 +37,15 @@ var isNode = runtime === "node";
|
|
|
38
37
|
var isBun = runtime === "bun";
|
|
39
38
|
var isDeno = runtime === "deno";
|
|
40
39
|
|
|
41
|
-
// src/fs.ts
|
|
40
|
+
// src/server/fs/node-modules.ts
|
|
42
41
|
var fs;
|
|
43
42
|
var fsPromises;
|
|
44
43
|
if (isNode || isBun) {
|
|
45
44
|
fs = require("fs");
|
|
46
45
|
fsPromises = require("fs/promises");
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
statSync(path);
|
|
51
|
-
return true;
|
|
52
|
-
} catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function statSync(path) {
|
|
57
|
-
if (isNode || isBun) {
|
|
58
|
-
return fs.statSync(path);
|
|
59
|
-
} else if (isDeno) {
|
|
60
|
-
const info = Deno.statSync(path);
|
|
61
|
-
return createStatsFromDenoFileInfo(info);
|
|
62
|
-
}
|
|
63
|
-
throw new Error("Unsupported runtime");
|
|
64
|
-
}
|
|
47
|
+
|
|
48
|
+
// src/server/fs/utils.ts
|
|
65
49
|
function createStatsFromDenoFileInfo(info) {
|
|
66
50
|
return {
|
|
67
51
|
isFile: () => info.isFile,
|
|
@@ -92,37 +76,52 @@ function createStatsFromDenoFileInfo(info) {
|
|
|
92
76
|
};
|
|
93
77
|
}
|
|
94
78
|
|
|
95
|
-
// src/
|
|
79
|
+
// src/server/fs/file-ops.ts
|
|
80
|
+
function existsSync(path) {
|
|
81
|
+
try {
|
|
82
|
+
statSync(path);
|
|
83
|
+
return true;
|
|
84
|
+
} catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function statSync(path) {
|
|
89
|
+
if (isNode || isBun) {
|
|
90
|
+
return fs.statSync(path);
|
|
91
|
+
} else if (isDeno) {
|
|
92
|
+
const info = Deno.statSync(path);
|
|
93
|
+
return createStatsFromDenoFileInfo(info);
|
|
94
|
+
}
|
|
95
|
+
throw new Error("Unsupported runtime");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/server/path/platform.ts
|
|
96
99
|
function getSeparator(isWin) {
|
|
97
100
|
return isWin ? "\\" : "/";
|
|
98
101
|
}
|
|
99
102
|
function getCwd() {
|
|
100
103
|
if (isNode || isBun) {
|
|
101
104
|
return process.cwd();
|
|
102
|
-
}
|
|
105
|
+
}
|
|
106
|
+
if (isDeno) {
|
|
103
107
|
return Deno.cwd();
|
|
104
108
|
}
|
|
105
109
|
return "/";
|
|
106
110
|
}
|
|
111
|
+
var isWindows = (() => {
|
|
112
|
+
if (isNode) {
|
|
113
|
+
return process.platform === "win32";
|
|
114
|
+
}
|
|
115
|
+
if (isDeno) {
|
|
116
|
+
return Deno.build.os === "windows";
|
|
117
|
+
}
|
|
118
|
+
return typeof process !== "undefined" && process.platform === "win32";
|
|
119
|
+
})();
|
|
120
|
+
|
|
121
|
+
// src/server/path/operations.ts
|
|
107
122
|
function findLastSeparator(path) {
|
|
108
123
|
return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
109
124
|
}
|
|
110
|
-
function createPathOps(isWin) {
|
|
111
|
-
return {
|
|
112
|
-
sep: getSeparator(isWin),
|
|
113
|
-
delimiter: isWin ? ";" : ":",
|
|
114
|
-
normalize: (path) => normalizePath(path, isWin),
|
|
115
|
-
join: (...paths) => joinPaths(paths, isWin),
|
|
116
|
-
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
117
|
-
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
118
|
-
relative: (from, to) => relativePath(from, to, isWin),
|
|
119
|
-
dirname: (path) => getDirname(path, isWin),
|
|
120
|
-
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
121
|
-
extname: (path) => getExtname(path),
|
|
122
|
-
parse: (path) => parsePath(path, isWin),
|
|
123
|
-
format: (pathObject) => formatPath(pathObject, isWin)
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
125
|
function isAbsolutePosix(path) {
|
|
127
126
|
return path.length > 0 && path[0] === "/";
|
|
128
127
|
}
|
|
@@ -143,28 +142,18 @@ function isAbsoluteWin(path) {
|
|
|
143
142
|
}
|
|
144
143
|
return false;
|
|
145
144
|
}
|
|
146
|
-
var isWindows = (() => {
|
|
147
|
-
if (isNode) {
|
|
148
|
-
return process.platform === "win32";
|
|
149
|
-
} else if (isDeno) {
|
|
150
|
-
return Deno.build.os === "windows";
|
|
151
|
-
}
|
|
152
|
-
return typeof process !== "undefined" && process.platform === "win32";
|
|
153
|
-
})();
|
|
154
|
-
var posix = createPathOps(false);
|
|
155
|
-
var win32 = createPathOps(true);
|
|
156
145
|
function normalizePath(path, isWin) {
|
|
157
146
|
if (path.length === 0) return ".";
|
|
158
147
|
const separator = getSeparator(isWin);
|
|
159
148
|
const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
160
149
|
const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
|
|
161
|
-
|
|
150
|
+
const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
|
|
162
151
|
const parts = normalized.split(separator);
|
|
163
152
|
const result = [];
|
|
164
|
-
for (let
|
|
165
|
-
const part = parts[
|
|
153
|
+
for (let index = 0; index < parts.length; index++) {
|
|
154
|
+
const part = parts[index];
|
|
166
155
|
if (part === "" || part === ".") {
|
|
167
|
-
if (
|
|
156
|
+
if (index === 0 && isAbsolute) result.push("");
|
|
168
157
|
continue;
|
|
169
158
|
}
|
|
170
159
|
if (part === "..") {
|
|
@@ -179,21 +168,21 @@ function normalizePath(path, isWin) {
|
|
|
179
168
|
result.push(part);
|
|
180
169
|
}
|
|
181
170
|
}
|
|
182
|
-
let
|
|
183
|
-
if (
|
|
171
|
+
let finalPath = result.join(separator);
|
|
172
|
+
if (finalPath.length === 0) {
|
|
184
173
|
return isAbsolute ? separator : ".";
|
|
185
174
|
}
|
|
186
|
-
if (trailingSeparator &&
|
|
187
|
-
|
|
175
|
+
if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
|
|
176
|
+
finalPath += separator;
|
|
188
177
|
}
|
|
189
|
-
return
|
|
178
|
+
return finalPath;
|
|
190
179
|
}
|
|
191
180
|
function joinPaths(paths, isWin) {
|
|
192
181
|
if (paths.length === 0) return ".";
|
|
193
182
|
const separator = getSeparator(isWin);
|
|
194
183
|
let joined = "";
|
|
195
|
-
for (let
|
|
196
|
-
const path = paths[
|
|
184
|
+
for (let index = 0; index < paths.length; index++) {
|
|
185
|
+
const path = paths[index];
|
|
197
186
|
if (path && path.length > 0) {
|
|
198
187
|
if (joined.length === 0) {
|
|
199
188
|
joined = path;
|
|
@@ -208,43 +197,43 @@ function joinPaths(paths, isWin) {
|
|
|
208
197
|
function resolvePaths(paths, isWin) {
|
|
209
198
|
const separator = getSeparator(isWin);
|
|
210
199
|
let resolved = "";
|
|
211
|
-
let
|
|
212
|
-
for (let
|
|
213
|
-
const path = paths[
|
|
200
|
+
let absolute = false;
|
|
201
|
+
for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
|
|
202
|
+
const path = paths[index];
|
|
214
203
|
if (path && path.length > 0) {
|
|
215
204
|
resolved = path + (resolved.length > 0 ? separator + resolved : "");
|
|
216
|
-
|
|
205
|
+
absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
|
|
217
206
|
}
|
|
218
207
|
}
|
|
219
|
-
if (!
|
|
208
|
+
if (!absolute) {
|
|
220
209
|
const cwd = getCwd();
|
|
221
210
|
resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
|
|
222
211
|
}
|
|
223
212
|
return normalizePath(resolved, isWin);
|
|
224
213
|
}
|
|
225
214
|
function relativePath(from, to, isWin) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (
|
|
215
|
+
const resolvedFrom = resolvePaths([from], isWin);
|
|
216
|
+
const resolvedTo = resolvePaths([to], isWin);
|
|
217
|
+
if (resolvedFrom === resolvedTo) return "";
|
|
229
218
|
const separator = getSeparator(isWin);
|
|
230
|
-
const fromParts =
|
|
231
|
-
const toParts =
|
|
232
|
-
let commonLength = 0;
|
|
219
|
+
const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
|
|
220
|
+
const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
|
|
233
221
|
const minLength = Math.min(fromParts.length, toParts.length);
|
|
234
|
-
|
|
235
|
-
|
|
222
|
+
let commonLength = 0;
|
|
223
|
+
for (let index = 0; index < minLength; index++) {
|
|
224
|
+
if (fromParts[index] === toParts[index]) {
|
|
236
225
|
commonLength++;
|
|
237
226
|
} else {
|
|
238
227
|
break;
|
|
239
228
|
}
|
|
240
229
|
}
|
|
241
|
-
const upCount = fromParts.length - commonLength;
|
|
242
230
|
const result = [];
|
|
243
|
-
|
|
231
|
+
const upCount = fromParts.length - commonLength;
|
|
232
|
+
for (let index = 0; index < upCount; index++) {
|
|
244
233
|
result.push("..");
|
|
245
234
|
}
|
|
246
|
-
for (let
|
|
247
|
-
result.push(toParts[
|
|
235
|
+
for (let index = commonLength; index < toParts.length; index++) {
|
|
236
|
+
result.push(toParts[index]);
|
|
248
237
|
}
|
|
249
238
|
return result.join(separator) || ".";
|
|
250
239
|
}
|
|
@@ -252,15 +241,15 @@ function getDirname(path, isWin) {
|
|
|
252
241
|
if (path.length === 0) return ".";
|
|
253
242
|
const separator = getSeparator(isWin);
|
|
254
243
|
const normalized = normalizePath(path, isWin);
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
if (
|
|
258
|
-
return normalized.slice(0,
|
|
244
|
+
const lastSeparatorIndex = normalized.lastIndexOf(separator);
|
|
245
|
+
if (lastSeparatorIndex === -1) return ".";
|
|
246
|
+
if (lastSeparatorIndex === 0) return separator;
|
|
247
|
+
return normalized.slice(0, lastSeparatorIndex);
|
|
259
248
|
}
|
|
260
249
|
function getBasename(path, ext, isWin) {
|
|
261
250
|
if (path.length === 0) return "";
|
|
262
|
-
const
|
|
263
|
-
let base =
|
|
251
|
+
const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
|
|
252
|
+
let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
|
|
264
253
|
if (ext && base.endsWith(ext)) {
|
|
265
254
|
base = base.slice(0, base.length - ext.length);
|
|
266
255
|
}
|
|
@@ -268,8 +257,8 @@ function getBasename(path, ext, isWin) {
|
|
|
268
257
|
}
|
|
269
258
|
function getExtname(path) {
|
|
270
259
|
const lastDotIndex = path.lastIndexOf(".");
|
|
271
|
-
const
|
|
272
|
-
if (lastDotIndex === -1 || lastDotIndex <
|
|
260
|
+
const lastSeparatorIndex = findLastSeparator(path);
|
|
261
|
+
if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
|
|
273
262
|
return "";
|
|
274
263
|
}
|
|
275
264
|
return path.slice(lastDotIndex);
|
|
@@ -285,10 +274,8 @@ function parsePath(path, isWin) {
|
|
|
285
274
|
} else if (path[0] === "\\" || path[0] === "/") {
|
|
286
275
|
root = "\\";
|
|
287
276
|
}
|
|
288
|
-
} else {
|
|
289
|
-
|
|
290
|
-
root = "/";
|
|
291
|
-
}
|
|
277
|
+
} else if (path[0] === "/") {
|
|
278
|
+
root = "/";
|
|
292
279
|
}
|
|
293
280
|
const dir = getDirname(path, isWin);
|
|
294
281
|
const base = getBasename(path, void 0, isWin);
|
|
@@ -304,11 +291,31 @@ function formatPath(pathObject, isWin) {
|
|
|
304
291
|
if (dir === pathObject.root) return dir + base;
|
|
305
292
|
return dir + separator + base;
|
|
306
293
|
}
|
|
294
|
+
function createPathOps(isWin) {
|
|
295
|
+
return {
|
|
296
|
+
sep: getSeparator(isWin),
|
|
297
|
+
delimiter: isWin ? ";" : ":",
|
|
298
|
+
normalize: (path) => normalizePath(path, isWin),
|
|
299
|
+
join: (...paths) => joinPaths(paths, isWin),
|
|
300
|
+
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
301
|
+
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
302
|
+
relative: (from, to) => relativePath(from, to, isWin),
|
|
303
|
+
dirname: (path) => getDirname(path, isWin),
|
|
304
|
+
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
305
|
+
extname: (path) => getExtname(path),
|
|
306
|
+
parse: (path) => parsePath(path, isWin),
|
|
307
|
+
format: (pathObject) => formatPath(pathObject, isWin)
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// src/server/path/index.ts
|
|
312
|
+
var posix = createPathOps(false);
|
|
313
|
+
var win32 = createPathOps(true);
|
|
307
314
|
function dirname(path) {
|
|
308
315
|
return getDirname(path, isWindows);
|
|
309
316
|
}
|
|
310
317
|
|
|
311
|
-
// src/chokidar.ts
|
|
318
|
+
// src/server/chokidar/utils.ts
|
|
312
319
|
function normalizePath2(path) {
|
|
313
320
|
return path.replace(/\\/g, "/");
|
|
314
321
|
}
|
|
@@ -316,9 +323,45 @@ function emitEvent(watcher, eventType, path) {
|
|
|
316
323
|
watcher.emit(eventType, path);
|
|
317
324
|
watcher.emit("all", eventType, path);
|
|
318
325
|
}
|
|
326
|
+
function matchesPattern(filePath, pattern) {
|
|
327
|
+
const regexPattern = normalizePath2(pattern).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\?/g, ".");
|
|
328
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
329
|
+
const normalizedPath = normalizePath2(filePath);
|
|
330
|
+
return regex.test(normalizedPath);
|
|
331
|
+
}
|
|
319
332
|
function matchesAnyPattern(path, patterns) {
|
|
320
333
|
return patterns.some((pattern) => matchesPattern(path, pattern));
|
|
321
334
|
}
|
|
335
|
+
function getBaseDirectory(pattern) {
|
|
336
|
+
const normalizedPattern = normalizePath2(pattern);
|
|
337
|
+
const parts = normalizedPattern.split(/[\\/]/);
|
|
338
|
+
let baseDir = "";
|
|
339
|
+
let sawGlob = false;
|
|
340
|
+
for (const part of parts) {
|
|
341
|
+
if (part.includes("*") || part.includes("?")) {
|
|
342
|
+
sawGlob = true;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
baseDir = baseDir ? `${baseDir}/${part}` : part;
|
|
346
|
+
}
|
|
347
|
+
if (sawGlob) {
|
|
348
|
+
return baseDir || ".";
|
|
349
|
+
}
|
|
350
|
+
if (normalizedPattern && existsSync(normalizedPattern)) {
|
|
351
|
+
try {
|
|
352
|
+
return statSync(normalizedPattern).isDirectory() ? normalizedPattern : normalizePath2(dirname(normalizedPattern)) || ".";
|
|
353
|
+
} catch {
|
|
354
|
+
return normalizePath2(dirname(normalizedPattern)) || ".";
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const lastSegment = parts[parts.length - 1] || "";
|
|
358
|
+
if (lastSegment.includes(".") && !lastSegment.startsWith(".")) {
|
|
359
|
+
return normalizePath2(dirname(normalizedPattern)) || ".";
|
|
360
|
+
}
|
|
361
|
+
return normalizedPattern || ".";
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/server/chokidar/native-watch.ts
|
|
322
365
|
function handleRenameEvent(watcher, fullPath, fs2) {
|
|
323
366
|
try {
|
|
324
367
|
fs2.statSync(fullPath);
|
|
@@ -340,12 +383,15 @@ function setupFsWatch(watcher, baseDir, patterns, fs2) {
|
|
|
340
383
|
}
|
|
341
384
|
});
|
|
342
385
|
watcher._setWatcher(nativeWatcher);
|
|
343
|
-
watcher
|
|
386
|
+
watcher._trackWatchedPath(baseDir);
|
|
344
387
|
queueMicrotask(() => watcher.emit("ready"));
|
|
345
388
|
} catch (error) {
|
|
346
389
|
watcher.emit("error", error);
|
|
347
390
|
}
|
|
348
391
|
}
|
|
392
|
+
|
|
393
|
+
// src/server/chokidar/watcher.ts
|
|
394
|
+
var import_events = require("events");
|
|
349
395
|
var FSWatcher = class extends import_events.EventEmitter {
|
|
350
396
|
constructor(options) {
|
|
351
397
|
super();
|
|
@@ -361,12 +407,11 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
361
407
|
throw new Error("Watcher has been closed");
|
|
362
408
|
}
|
|
363
409
|
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
pathArray.forEach((path) => this._watched.add(path));
|
|
410
|
+
if (this._watcher && typeof this._watcher.add === "function") {
|
|
411
|
+
this._watcher.add(pathArray);
|
|
412
|
+
}
|
|
413
|
+
if (runtime !== "node" || !this._watcher || typeof this._watcher.add !== "function") {
|
|
414
|
+
pathArray.forEach((path) => this._trackWatchedPath(path));
|
|
370
415
|
}
|
|
371
416
|
return this;
|
|
372
417
|
}
|
|
@@ -378,12 +423,11 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
378
423
|
return this;
|
|
379
424
|
}
|
|
380
425
|
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
pathArray.forEach((path) => this._watched.delete(path));
|
|
426
|
+
if (this._watcher && typeof this._watcher.unwatch === "function") {
|
|
427
|
+
this._watcher.unwatch(pathArray);
|
|
428
|
+
}
|
|
429
|
+
if (runtime !== "node" || !this._watcher || typeof this._watcher.unwatch !== "function") {
|
|
430
|
+
pathArray.forEach((path) => this._untrackWatchedPath(path));
|
|
387
431
|
}
|
|
388
432
|
return this;
|
|
389
433
|
}
|
|
@@ -395,10 +439,8 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
395
439
|
return;
|
|
396
440
|
}
|
|
397
441
|
this._closed = true;
|
|
398
|
-
if (
|
|
399
|
-
|
|
400
|
-
await this._watcher.close();
|
|
401
|
-
}
|
|
442
|
+
if (this._watcher && typeof this._watcher.close === "function") {
|
|
443
|
+
await this._watcher.close();
|
|
402
444
|
}
|
|
403
445
|
this.removeAllListeners();
|
|
404
446
|
}
|
|
@@ -406,7 +448,7 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
406
448
|
* Get watched paths
|
|
407
449
|
*/
|
|
408
450
|
getWatched() {
|
|
409
|
-
if (
|
|
451
|
+
if (this._watcher && typeof this._watcher.getWatched === "function") {
|
|
410
452
|
return this._watcher.getWatched();
|
|
411
453
|
}
|
|
412
454
|
const result = {};
|
|
@@ -427,100 +469,95 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
427
469
|
_setWatcher(watcher) {
|
|
428
470
|
this._watcher = watcher;
|
|
429
471
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
for (const part of parts) {
|
|
437
|
-
if (part.includes("*") || part.includes("?")) {
|
|
438
|
-
sawGlob = true;
|
|
439
|
-
break;
|
|
440
|
-
}
|
|
441
|
-
baseDir = baseDir ? `${baseDir}/${part}` : part;
|
|
442
|
-
}
|
|
443
|
-
if (sawGlob) {
|
|
444
|
-
return baseDir || ".";
|
|
472
|
+
/**
|
|
473
|
+
* Internal method to track watched paths
|
|
474
|
+
* @internal
|
|
475
|
+
*/
|
|
476
|
+
_trackWatchedPath(path) {
|
|
477
|
+
this._watched.add(path);
|
|
445
478
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
479
|
+
/**
|
|
480
|
+
* Internal method to untrack watched paths
|
|
481
|
+
* @internal
|
|
482
|
+
*/
|
|
483
|
+
_untrackWatchedPath(path) {
|
|
484
|
+
this._watched.delete(path);
|
|
452
485
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
486
|
+
/**
|
|
487
|
+
* Internal method to read closed state
|
|
488
|
+
* @internal
|
|
489
|
+
*/
|
|
490
|
+
_isClosed() {
|
|
491
|
+
return this._closed;
|
|
456
492
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const regex = new RegExp(`^${regexPattern}$`);
|
|
462
|
-
const normalizedPath = normalizePath2(filePath);
|
|
463
|
-
return regex.test(normalizedPath);
|
|
464
|
-
}
|
|
465
|
-
function watch(paths, options) {
|
|
466
|
-
const watcher = new FSWatcher(options);
|
|
467
|
-
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// src/server/chokidar/watch.ts
|
|
496
|
+
function createWatchMap(paths) {
|
|
468
497
|
const watchMap = /* @__PURE__ */ new Map();
|
|
469
|
-
|
|
498
|
+
paths.forEach((path) => {
|
|
470
499
|
const baseDir = getBaseDirectory(path);
|
|
471
500
|
if (!watchMap.has(baseDir)) {
|
|
472
501
|
watchMap.set(baseDir, []);
|
|
473
502
|
}
|
|
474
503
|
watchMap.get(baseDir).push(path);
|
|
475
504
|
});
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
break;
|
|
500
|
-
case "remove":
|
|
501
|
-
emitEvent(watcher, "unlink", path);
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
505
|
+
return watchMap;
|
|
506
|
+
}
|
|
507
|
+
function setupDenoWatch(watcher, watchMap, pathArray) {
|
|
508
|
+
const baseDirs = Array.from(watchMap.keys());
|
|
509
|
+
const allPatterns = Array.from(watchMap.values()).flat();
|
|
510
|
+
(async () => {
|
|
511
|
+
try {
|
|
512
|
+
const denoWatcher = Deno.watchFs(baseDirs);
|
|
513
|
+
for await (const event of denoWatcher) {
|
|
514
|
+
if (watcher._isClosed()) break;
|
|
515
|
+
for (const path of event.paths) {
|
|
516
|
+
const normalizedPath = normalizePath2(path);
|
|
517
|
+
if (!matchesAnyPattern(normalizedPath, allPatterns)) continue;
|
|
518
|
+
switch (event.kind) {
|
|
519
|
+
case "create":
|
|
520
|
+
emitEvent(watcher, "add", path);
|
|
521
|
+
break;
|
|
522
|
+
case "modify":
|
|
523
|
+
emitEvent(watcher, "change", path);
|
|
524
|
+
break;
|
|
525
|
+
case "remove":
|
|
526
|
+
emitEvent(watcher, "unlink", path);
|
|
527
|
+
break;
|
|
504
528
|
}
|
|
505
529
|
}
|
|
506
|
-
} catch (error) {
|
|
507
|
-
if (!watcher["_closed"]) {
|
|
508
|
-
watcher.emit("error", error);
|
|
509
|
-
}
|
|
510
530
|
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
531
|
+
} catch (error) {
|
|
532
|
+
if (!watcher._isClosed()) {
|
|
533
|
+
watcher.emit("error", error);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
})();
|
|
537
|
+
pathArray.forEach((path) => watcher.add(path));
|
|
538
|
+
queueMicrotask(() => watcher.emit("ready"));
|
|
539
|
+
}
|
|
540
|
+
function watch(paths, options) {
|
|
541
|
+
const watcher = new FSWatcher(options);
|
|
542
|
+
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
543
|
+
const watchMap = createWatchMap(pathArray);
|
|
544
|
+
if (runtime === "node" || runtime === "bun") {
|
|
545
|
+
const fs2 = require("fs");
|
|
546
|
+
watchMap.forEach((patterns, baseDir) => setupFsWatch(watcher, baseDir, patterns, fs2));
|
|
547
|
+
} else if (runtime === "deno") {
|
|
548
|
+
setupDenoWatch(watcher, watchMap, pathArray);
|
|
514
549
|
}
|
|
515
550
|
return watcher;
|
|
516
551
|
}
|
|
517
|
-
function
|
|
552
|
+
function getRuntime2() {
|
|
518
553
|
return runtime;
|
|
519
554
|
}
|
|
555
|
+
|
|
556
|
+
// src/server/chokidar/index.ts
|
|
520
557
|
var chokidar_default = {
|
|
521
558
|
watch,
|
|
522
559
|
FSWatcher,
|
|
523
|
-
getRuntime
|
|
560
|
+
getRuntime: getRuntime2
|
|
524
561
|
};
|
|
525
562
|
// Annotate the CommonJS export names for ESM import in node:
|
|
526
563
|
0 && (module.exports = {
|
package/dist/chokidar.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* File watcher module with unified API across runtimes
|
|
5
|
-
* Pure implementation without external dependencies
|
|
6
|
-
* Compatible with 'chokidar' package API
|
|
7
|
-
* - Node.js: uses native fs.watch
|
|
8
|
-
* - Bun: uses native fs.watch with enhancements
|
|
9
|
-
* - Deno: uses Deno.watchFs
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
3
|
/**
|
|
13
4
|
* Watch options
|
|
14
5
|
*/
|
|
@@ -81,6 +72,7 @@ interface WatchOptions {
|
|
|
81
72
|
*/
|
|
82
73
|
atomic?: boolean | number;
|
|
83
74
|
}
|
|
75
|
+
|
|
84
76
|
/**
|
|
85
77
|
* FSWatcher class - Compatible with chokidar
|
|
86
78
|
*/
|
|
@@ -113,7 +105,23 @@ declare class FSWatcher extends EventEmitter {
|
|
|
113
105
|
* @internal
|
|
114
106
|
*/
|
|
115
107
|
_setWatcher(watcher: any): void;
|
|
108
|
+
/**
|
|
109
|
+
* Internal method to track watched paths
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
_trackWatchedPath(path: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Internal method to untrack watched paths
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
_untrackWatchedPath(path: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Internal method to read closed state
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
_isClosed(): boolean;
|
|
116
123
|
}
|
|
124
|
+
|
|
117
125
|
/**
|
|
118
126
|
* Watch files and directories
|
|
119
127
|
*/
|
|
@@ -122,9 +130,16 @@ declare function watch(paths: string | string[], options?: WatchOptions): FSWatc
|
|
|
122
130
|
* Get current runtime
|
|
123
131
|
*/
|
|
124
132
|
declare function getRuntime(): 'node' | 'bun' | 'deno';
|
|
133
|
+
|
|
125
134
|
/**
|
|
126
|
-
*
|
|
135
|
+
* File watcher module with unified API across runtimes
|
|
136
|
+
* Pure implementation without external dependencies
|
|
137
|
+
* Compatible with 'chokidar' package API
|
|
138
|
+
* - Node.js: uses native fs.watch
|
|
139
|
+
* - Bun: uses native fs.watch with enhancements
|
|
140
|
+
* - Deno: uses Deno.watchFs
|
|
127
141
|
*/
|
|
142
|
+
|
|
128
143
|
declare const _default: {
|
|
129
144
|
watch: typeof watch;
|
|
130
145
|
FSWatcher: typeof FSWatcher;
|