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