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/chokidar.js
CHANGED
|
@@ -7,10 +7,7 @@
|
|
|
7
7
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
// src/
|
|
11
|
-
var import_events = __require("events");
|
|
12
|
-
|
|
13
|
-
// src/runtime.ts
|
|
10
|
+
// src/shares/runtime.ts
|
|
14
11
|
var runtime = (() => {
|
|
15
12
|
if (typeof Deno !== "undefined") return "deno";
|
|
16
13
|
if (typeof Bun !== "undefined") return "bun";
|
|
@@ -20,30 +17,15 @@
|
|
|
20
17
|
var isBun = runtime === "bun";
|
|
21
18
|
var isDeno = runtime === "deno";
|
|
22
19
|
|
|
23
|
-
// src/fs.ts
|
|
20
|
+
// src/server/fs/node-modules.ts
|
|
24
21
|
var fs;
|
|
25
22
|
var fsPromises;
|
|
26
23
|
if (isNode || isBun) {
|
|
27
24
|
fs = __require("fs");
|
|
28
25
|
fsPromises = __require("fs/promises");
|
|
29
26
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
statSync(path);
|
|
33
|
-
return true;
|
|
34
|
-
} catch {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function statSync(path) {
|
|
39
|
-
if (isNode || isBun) {
|
|
40
|
-
return fs.statSync(path);
|
|
41
|
-
} else if (isDeno) {
|
|
42
|
-
const info = Deno.statSync(path);
|
|
43
|
-
return createStatsFromDenoFileInfo(info);
|
|
44
|
-
}
|
|
45
|
-
throw new Error("Unsupported runtime");
|
|
46
|
-
}
|
|
27
|
+
|
|
28
|
+
// src/server/fs/utils.ts
|
|
47
29
|
function createStatsFromDenoFileInfo(info) {
|
|
48
30
|
return {
|
|
49
31
|
isFile: () => info.isFile,
|
|
@@ -74,37 +56,52 @@
|
|
|
74
56
|
};
|
|
75
57
|
}
|
|
76
58
|
|
|
77
|
-
// src/
|
|
59
|
+
// src/server/fs/file-ops.ts
|
|
60
|
+
function existsSync(path) {
|
|
61
|
+
try {
|
|
62
|
+
statSync(path);
|
|
63
|
+
return true;
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function statSync(path) {
|
|
69
|
+
if (isNode || isBun) {
|
|
70
|
+
return fs.statSync(path);
|
|
71
|
+
} else if (isDeno) {
|
|
72
|
+
const info = Deno.statSync(path);
|
|
73
|
+
return createStatsFromDenoFileInfo(info);
|
|
74
|
+
}
|
|
75
|
+
throw new Error("Unsupported runtime");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/server/path/platform.ts
|
|
78
79
|
function getSeparator(isWin) {
|
|
79
80
|
return isWin ? "\\" : "/";
|
|
80
81
|
}
|
|
81
82
|
function getCwd() {
|
|
82
83
|
if (isNode || isBun) {
|
|
83
84
|
return process.cwd();
|
|
84
|
-
}
|
|
85
|
+
}
|
|
86
|
+
if (isDeno) {
|
|
85
87
|
return Deno.cwd();
|
|
86
88
|
}
|
|
87
89
|
return "/";
|
|
88
90
|
}
|
|
91
|
+
var isWindows = (() => {
|
|
92
|
+
if (isNode) {
|
|
93
|
+
return process.platform === "win32";
|
|
94
|
+
}
|
|
95
|
+
if (isDeno) {
|
|
96
|
+
return Deno.build.os === "windows";
|
|
97
|
+
}
|
|
98
|
+
return typeof process !== "undefined" && process.platform === "win32";
|
|
99
|
+
})();
|
|
100
|
+
|
|
101
|
+
// src/server/path/operations.ts
|
|
89
102
|
function findLastSeparator(path) {
|
|
90
103
|
return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
91
104
|
}
|
|
92
|
-
function createPathOps(isWin) {
|
|
93
|
-
return {
|
|
94
|
-
sep: getSeparator(isWin),
|
|
95
|
-
delimiter: isWin ? ";" : ":",
|
|
96
|
-
normalize: (path) => normalizePath(path, isWin),
|
|
97
|
-
join: (...paths) => joinPaths(paths, isWin),
|
|
98
|
-
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
99
|
-
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
100
|
-
relative: (from, to) => relativePath(from, to, isWin),
|
|
101
|
-
dirname: (path) => getDirname(path, isWin),
|
|
102
|
-
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
103
|
-
extname: (path) => getExtname(path),
|
|
104
|
-
parse: (path) => parsePath(path, isWin),
|
|
105
|
-
format: (pathObject) => formatPath(pathObject, isWin)
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
105
|
function isAbsolutePosix(path) {
|
|
109
106
|
return path.length > 0 && path[0] === "/";
|
|
110
107
|
}
|
|
@@ -125,28 +122,18 @@
|
|
|
125
122
|
}
|
|
126
123
|
return false;
|
|
127
124
|
}
|
|
128
|
-
var isWindows = (() => {
|
|
129
|
-
if (isNode) {
|
|
130
|
-
return process.platform === "win32";
|
|
131
|
-
} else if (isDeno) {
|
|
132
|
-
return Deno.build.os === "windows";
|
|
133
|
-
}
|
|
134
|
-
return typeof process !== "undefined" && process.platform === "win32";
|
|
135
|
-
})();
|
|
136
|
-
var posix = createPathOps(false);
|
|
137
|
-
var win32 = createPathOps(true);
|
|
138
125
|
function normalizePath(path, isWin) {
|
|
139
126
|
if (path.length === 0) return ".";
|
|
140
127
|
const separator = getSeparator(isWin);
|
|
141
128
|
const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
142
129
|
const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
|
|
143
|
-
|
|
130
|
+
const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
|
|
144
131
|
const parts = normalized.split(separator);
|
|
145
132
|
const result = [];
|
|
146
|
-
for (let
|
|
147
|
-
const part = parts[
|
|
133
|
+
for (let index = 0; index < parts.length; index++) {
|
|
134
|
+
const part = parts[index];
|
|
148
135
|
if (part === "" || part === ".") {
|
|
149
|
-
if (
|
|
136
|
+
if (index === 0 && isAbsolute) result.push("");
|
|
150
137
|
continue;
|
|
151
138
|
}
|
|
152
139
|
if (part === "..") {
|
|
@@ -161,21 +148,21 @@
|
|
|
161
148
|
result.push(part);
|
|
162
149
|
}
|
|
163
150
|
}
|
|
164
|
-
let
|
|
165
|
-
if (
|
|
151
|
+
let finalPath = result.join(separator);
|
|
152
|
+
if (finalPath.length === 0) {
|
|
166
153
|
return isAbsolute ? separator : ".";
|
|
167
154
|
}
|
|
168
|
-
if (trailingSeparator &&
|
|
169
|
-
|
|
155
|
+
if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
|
|
156
|
+
finalPath += separator;
|
|
170
157
|
}
|
|
171
|
-
return
|
|
158
|
+
return finalPath;
|
|
172
159
|
}
|
|
173
160
|
function joinPaths(paths, isWin) {
|
|
174
161
|
if (paths.length === 0) return ".";
|
|
175
162
|
const separator = getSeparator(isWin);
|
|
176
163
|
let joined = "";
|
|
177
|
-
for (let
|
|
178
|
-
const path = paths[
|
|
164
|
+
for (let index = 0; index < paths.length; index++) {
|
|
165
|
+
const path = paths[index];
|
|
179
166
|
if (path && path.length > 0) {
|
|
180
167
|
if (joined.length === 0) {
|
|
181
168
|
joined = path;
|
|
@@ -190,43 +177,43 @@
|
|
|
190
177
|
function resolvePaths(paths, isWin) {
|
|
191
178
|
const separator = getSeparator(isWin);
|
|
192
179
|
let resolved = "";
|
|
193
|
-
let
|
|
194
|
-
for (let
|
|
195
|
-
const path = paths[
|
|
180
|
+
let absolute = false;
|
|
181
|
+
for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
|
|
182
|
+
const path = paths[index];
|
|
196
183
|
if (path && path.length > 0) {
|
|
197
184
|
resolved = path + (resolved.length > 0 ? separator + resolved : "");
|
|
198
|
-
|
|
185
|
+
absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
|
|
199
186
|
}
|
|
200
187
|
}
|
|
201
|
-
if (!
|
|
188
|
+
if (!absolute) {
|
|
202
189
|
const cwd = getCwd();
|
|
203
190
|
resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
|
|
204
191
|
}
|
|
205
192
|
return normalizePath(resolved, isWin);
|
|
206
193
|
}
|
|
207
194
|
function relativePath(from, to, isWin) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (
|
|
195
|
+
const resolvedFrom = resolvePaths([from], isWin);
|
|
196
|
+
const resolvedTo = resolvePaths([to], isWin);
|
|
197
|
+
if (resolvedFrom === resolvedTo) return "";
|
|
211
198
|
const separator = getSeparator(isWin);
|
|
212
|
-
const fromParts =
|
|
213
|
-
const toParts =
|
|
214
|
-
let commonLength = 0;
|
|
199
|
+
const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
|
|
200
|
+
const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
|
|
215
201
|
const minLength = Math.min(fromParts.length, toParts.length);
|
|
216
|
-
|
|
217
|
-
|
|
202
|
+
let commonLength = 0;
|
|
203
|
+
for (let index = 0; index < minLength; index++) {
|
|
204
|
+
if (fromParts[index] === toParts[index]) {
|
|
218
205
|
commonLength++;
|
|
219
206
|
} else {
|
|
220
207
|
break;
|
|
221
208
|
}
|
|
222
209
|
}
|
|
223
|
-
const upCount = fromParts.length - commonLength;
|
|
224
210
|
const result = [];
|
|
225
|
-
|
|
211
|
+
const upCount = fromParts.length - commonLength;
|
|
212
|
+
for (let index = 0; index < upCount; index++) {
|
|
226
213
|
result.push("..");
|
|
227
214
|
}
|
|
228
|
-
for (let
|
|
229
|
-
result.push(toParts[
|
|
215
|
+
for (let index = commonLength; index < toParts.length; index++) {
|
|
216
|
+
result.push(toParts[index]);
|
|
230
217
|
}
|
|
231
218
|
return result.join(separator) || ".";
|
|
232
219
|
}
|
|
@@ -234,15 +221,15 @@
|
|
|
234
221
|
if (path.length === 0) return ".";
|
|
235
222
|
const separator = getSeparator(isWin);
|
|
236
223
|
const normalized = normalizePath(path, isWin);
|
|
237
|
-
const
|
|
238
|
-
if (
|
|
239
|
-
if (
|
|
240
|
-
return normalized.slice(0,
|
|
224
|
+
const lastSeparatorIndex = normalized.lastIndexOf(separator);
|
|
225
|
+
if (lastSeparatorIndex === -1) return ".";
|
|
226
|
+
if (lastSeparatorIndex === 0) return separator;
|
|
227
|
+
return normalized.slice(0, lastSeparatorIndex);
|
|
241
228
|
}
|
|
242
229
|
function getBasename(path, ext, isWin) {
|
|
243
230
|
if (path.length === 0) return "";
|
|
244
|
-
const
|
|
245
|
-
let base =
|
|
231
|
+
const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
|
|
232
|
+
let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
|
|
246
233
|
if (ext && base.endsWith(ext)) {
|
|
247
234
|
base = base.slice(0, base.length - ext.length);
|
|
248
235
|
}
|
|
@@ -250,8 +237,8 @@
|
|
|
250
237
|
}
|
|
251
238
|
function getExtname(path) {
|
|
252
239
|
const lastDotIndex = path.lastIndexOf(".");
|
|
253
|
-
const
|
|
254
|
-
if (lastDotIndex === -1 || lastDotIndex <
|
|
240
|
+
const lastSeparatorIndex = findLastSeparator(path);
|
|
241
|
+
if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
|
|
255
242
|
return "";
|
|
256
243
|
}
|
|
257
244
|
return path.slice(lastDotIndex);
|
|
@@ -267,10 +254,8 @@
|
|
|
267
254
|
} else if (path[0] === "\\" || path[0] === "/") {
|
|
268
255
|
root = "\\";
|
|
269
256
|
}
|
|
270
|
-
} else {
|
|
271
|
-
|
|
272
|
-
root = "/";
|
|
273
|
-
}
|
|
257
|
+
} else if (path[0] === "/") {
|
|
258
|
+
root = "/";
|
|
274
259
|
}
|
|
275
260
|
const dir = getDirname(path, isWin);
|
|
276
261
|
const base = getBasename(path, void 0, isWin);
|
|
@@ -286,11 +271,31 @@
|
|
|
286
271
|
if (dir === pathObject.root) return dir + base;
|
|
287
272
|
return dir + separator + base;
|
|
288
273
|
}
|
|
274
|
+
function createPathOps(isWin) {
|
|
275
|
+
return {
|
|
276
|
+
sep: getSeparator(isWin),
|
|
277
|
+
delimiter: isWin ? ";" : ":",
|
|
278
|
+
normalize: (path) => normalizePath(path, isWin),
|
|
279
|
+
join: (...paths) => joinPaths(paths, isWin),
|
|
280
|
+
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
281
|
+
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
282
|
+
relative: (from, to) => relativePath(from, to, isWin),
|
|
283
|
+
dirname: (path) => getDirname(path, isWin),
|
|
284
|
+
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
285
|
+
extname: (path) => getExtname(path),
|
|
286
|
+
parse: (path) => parsePath(path, isWin),
|
|
287
|
+
format: (pathObject) => formatPath(pathObject, isWin)
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// src/server/path/index.ts
|
|
292
|
+
var posix = createPathOps(false);
|
|
293
|
+
var win32 = createPathOps(true);
|
|
289
294
|
function dirname(path) {
|
|
290
295
|
return getDirname(path, isWindows);
|
|
291
296
|
}
|
|
292
297
|
|
|
293
|
-
// src/chokidar.ts
|
|
298
|
+
// src/server/chokidar/utils.ts
|
|
294
299
|
function normalizePath2(path) {
|
|
295
300
|
return path.replace(/\\/g, "/");
|
|
296
301
|
}
|
|
@@ -298,9 +303,45 @@
|
|
|
298
303
|
watcher.emit(eventType, path);
|
|
299
304
|
watcher.emit("all", eventType, path);
|
|
300
305
|
}
|
|
306
|
+
function matchesPattern(filePath, pattern) {
|
|
307
|
+
const regexPattern = normalizePath2(pattern).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\?/g, ".");
|
|
308
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
309
|
+
const normalizedPath = normalizePath2(filePath);
|
|
310
|
+
return regex.test(normalizedPath);
|
|
311
|
+
}
|
|
301
312
|
function matchesAnyPattern(path, patterns) {
|
|
302
313
|
return patterns.some((pattern) => matchesPattern(path, pattern));
|
|
303
314
|
}
|
|
315
|
+
function getBaseDirectory(pattern) {
|
|
316
|
+
const normalizedPattern = normalizePath2(pattern);
|
|
317
|
+
const parts = normalizedPattern.split(/[\\/]/);
|
|
318
|
+
let baseDir = "";
|
|
319
|
+
let sawGlob = false;
|
|
320
|
+
for (const part of parts) {
|
|
321
|
+
if (part.includes("*") || part.includes("?")) {
|
|
322
|
+
sawGlob = true;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
baseDir = baseDir ? `${baseDir}/${part}` : part;
|
|
326
|
+
}
|
|
327
|
+
if (sawGlob) {
|
|
328
|
+
return baseDir || ".";
|
|
329
|
+
}
|
|
330
|
+
if (normalizedPattern && existsSync(normalizedPattern)) {
|
|
331
|
+
try {
|
|
332
|
+
return statSync(normalizedPattern).isDirectory() ? normalizedPattern : normalizePath2(dirname(normalizedPattern)) || ".";
|
|
333
|
+
} catch {
|
|
334
|
+
return normalizePath2(dirname(normalizedPattern)) || ".";
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const lastSegment = parts[parts.length - 1] || "";
|
|
338
|
+
if (lastSegment.includes(".") && !lastSegment.startsWith(".")) {
|
|
339
|
+
return normalizePath2(dirname(normalizedPattern)) || ".";
|
|
340
|
+
}
|
|
341
|
+
return normalizedPattern || ".";
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// src/server/chokidar/native-watch.ts
|
|
304
345
|
function handleRenameEvent(watcher, fullPath, fs2) {
|
|
305
346
|
try {
|
|
306
347
|
fs2.statSync(fullPath);
|
|
@@ -322,12 +363,15 @@
|
|
|
322
363
|
}
|
|
323
364
|
});
|
|
324
365
|
watcher._setWatcher(nativeWatcher);
|
|
325
|
-
watcher
|
|
366
|
+
watcher._trackWatchedPath(baseDir);
|
|
326
367
|
queueMicrotask(() => watcher.emit("ready"));
|
|
327
368
|
} catch (error) {
|
|
328
369
|
watcher.emit("error", error);
|
|
329
370
|
}
|
|
330
371
|
}
|
|
372
|
+
|
|
373
|
+
// src/server/chokidar/watcher.ts
|
|
374
|
+
var import_events = __require("events");
|
|
331
375
|
var FSWatcher = class extends import_events.EventEmitter {
|
|
332
376
|
constructor(options) {
|
|
333
377
|
super();
|
|
@@ -343,12 +387,11 @@
|
|
|
343
387
|
throw new Error("Watcher has been closed");
|
|
344
388
|
}
|
|
345
389
|
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
346
|
-
if (
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
pathArray.forEach((path) => this._watched.add(path));
|
|
390
|
+
if (this._watcher && typeof this._watcher.add === "function") {
|
|
391
|
+
this._watcher.add(pathArray);
|
|
392
|
+
}
|
|
393
|
+
if (runtime !== "node" || !this._watcher || typeof this._watcher.add !== "function") {
|
|
394
|
+
pathArray.forEach((path) => this._trackWatchedPath(path));
|
|
352
395
|
}
|
|
353
396
|
return this;
|
|
354
397
|
}
|
|
@@ -360,12 +403,11 @@
|
|
|
360
403
|
return this;
|
|
361
404
|
}
|
|
362
405
|
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
363
|
-
if (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
pathArray.forEach((path) => this._watched.delete(path));
|
|
406
|
+
if (this._watcher && typeof this._watcher.unwatch === "function") {
|
|
407
|
+
this._watcher.unwatch(pathArray);
|
|
408
|
+
}
|
|
409
|
+
if (runtime !== "node" || !this._watcher || typeof this._watcher.unwatch !== "function") {
|
|
410
|
+
pathArray.forEach((path) => this._untrackWatchedPath(path));
|
|
369
411
|
}
|
|
370
412
|
return this;
|
|
371
413
|
}
|
|
@@ -377,10 +419,8 @@
|
|
|
377
419
|
return;
|
|
378
420
|
}
|
|
379
421
|
this._closed = true;
|
|
380
|
-
if (
|
|
381
|
-
|
|
382
|
-
await this._watcher.close();
|
|
383
|
-
}
|
|
422
|
+
if (this._watcher && typeof this._watcher.close === "function") {
|
|
423
|
+
await this._watcher.close();
|
|
384
424
|
}
|
|
385
425
|
this.removeAllListeners();
|
|
386
426
|
}
|
|
@@ -388,7 +428,7 @@
|
|
|
388
428
|
* Get watched paths
|
|
389
429
|
*/
|
|
390
430
|
getWatched() {
|
|
391
|
-
if (
|
|
431
|
+
if (this._watcher && typeof this._watcher.getWatched === "function") {
|
|
392
432
|
return this._watcher.getWatched();
|
|
393
433
|
}
|
|
394
434
|
const result = {};
|
|
@@ -409,99 +449,94 @@
|
|
|
409
449
|
_setWatcher(watcher) {
|
|
410
450
|
this._watcher = watcher;
|
|
411
451
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
for (const part of parts) {
|
|
419
|
-
if (part.includes("*") || part.includes("?")) {
|
|
420
|
-
sawGlob = true;
|
|
421
|
-
break;
|
|
422
|
-
}
|
|
423
|
-
baseDir = baseDir ? `${baseDir}/${part}` : part;
|
|
424
|
-
}
|
|
425
|
-
if (sawGlob) {
|
|
426
|
-
return baseDir || ".";
|
|
452
|
+
/**
|
|
453
|
+
* Internal method to track watched paths
|
|
454
|
+
* @internal
|
|
455
|
+
*/
|
|
456
|
+
_trackWatchedPath(path) {
|
|
457
|
+
this._watched.add(path);
|
|
427
458
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
459
|
+
/**
|
|
460
|
+
* Internal method to untrack watched paths
|
|
461
|
+
* @internal
|
|
462
|
+
*/
|
|
463
|
+
_untrackWatchedPath(path) {
|
|
464
|
+
this._watched.delete(path);
|
|
434
465
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
466
|
+
/**
|
|
467
|
+
* Internal method to read closed state
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
_isClosed() {
|
|
471
|
+
return this._closed;
|
|
438
472
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
const regex = new RegExp(`^${regexPattern}$`);
|
|
444
|
-
const normalizedPath = normalizePath2(filePath);
|
|
445
|
-
return regex.test(normalizedPath);
|
|
446
|
-
}
|
|
447
|
-
function watch(paths, options) {
|
|
448
|
-
const watcher = new FSWatcher(options);
|
|
449
|
-
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
// src/server/chokidar/watch.ts
|
|
476
|
+
function createWatchMap(paths) {
|
|
450
477
|
const watchMap = /* @__PURE__ */ new Map();
|
|
451
|
-
|
|
478
|
+
paths.forEach((path) => {
|
|
452
479
|
const baseDir = getBaseDirectory(path);
|
|
453
480
|
if (!watchMap.has(baseDir)) {
|
|
454
481
|
watchMap.set(baseDir, []);
|
|
455
482
|
}
|
|
456
483
|
watchMap.get(baseDir).push(path);
|
|
457
484
|
});
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
break;
|
|
482
|
-
case "remove":
|
|
483
|
-
emitEvent(watcher, "unlink", path);
|
|
484
|
-
break;
|
|
485
|
-
}
|
|
485
|
+
return watchMap;
|
|
486
|
+
}
|
|
487
|
+
function setupDenoWatch(watcher, watchMap, pathArray) {
|
|
488
|
+
const baseDirs = Array.from(watchMap.keys());
|
|
489
|
+
const allPatterns = Array.from(watchMap.values()).flat();
|
|
490
|
+
(async () => {
|
|
491
|
+
try {
|
|
492
|
+
const denoWatcher = Deno.watchFs(baseDirs);
|
|
493
|
+
for await (const event of denoWatcher) {
|
|
494
|
+
if (watcher._isClosed()) break;
|
|
495
|
+
for (const path of event.paths) {
|
|
496
|
+
const normalizedPath = normalizePath2(path);
|
|
497
|
+
if (!matchesAnyPattern(normalizedPath, allPatterns)) continue;
|
|
498
|
+
switch (event.kind) {
|
|
499
|
+
case "create":
|
|
500
|
+
emitEvent(watcher, "add", path);
|
|
501
|
+
break;
|
|
502
|
+
case "modify":
|
|
503
|
+
emitEvent(watcher, "change", path);
|
|
504
|
+
break;
|
|
505
|
+
case "remove":
|
|
506
|
+
emitEvent(watcher, "unlink", path);
|
|
507
|
+
break;
|
|
486
508
|
}
|
|
487
509
|
}
|
|
488
|
-
} catch (error) {
|
|
489
|
-
if (!watcher["_closed"]) {
|
|
490
|
-
watcher.emit("error", error);
|
|
491
|
-
}
|
|
492
510
|
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
|
|
511
|
+
} catch (error) {
|
|
512
|
+
if (!watcher._isClosed()) {
|
|
513
|
+
watcher.emit("error", error);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
})();
|
|
517
|
+
pathArray.forEach((path) => watcher.add(path));
|
|
518
|
+
queueMicrotask(() => watcher.emit("ready"));
|
|
519
|
+
}
|
|
520
|
+
function watch(paths, options) {
|
|
521
|
+
const watcher = new FSWatcher(options);
|
|
522
|
+
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
523
|
+
const watchMap = createWatchMap(pathArray);
|
|
524
|
+
if (runtime === "node" || runtime === "bun") {
|
|
525
|
+
const fs2 = __require("fs");
|
|
526
|
+
watchMap.forEach((patterns, baseDir) => setupFsWatch(watcher, baseDir, patterns, fs2));
|
|
527
|
+
} else if (runtime === "deno") {
|
|
528
|
+
setupDenoWatch(watcher, watchMap, pathArray);
|
|
496
529
|
}
|
|
497
530
|
return watcher;
|
|
498
531
|
}
|
|
499
|
-
function
|
|
532
|
+
function getRuntime2() {
|
|
500
533
|
return runtime;
|
|
501
534
|
}
|
|
535
|
+
|
|
536
|
+
// src/server/chokidar/index.ts
|
|
502
537
|
var chokidar_default = {
|
|
503
538
|
watch,
|
|
504
539
|
FSWatcher,
|
|
505
|
-
getRuntime
|
|
540
|
+
getRuntime: getRuntime2
|
|
506
541
|
};
|
|
507
542
|
})();
|