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.
Files changed (154) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/README.md +6 -0
  4. package/dist/build.cjs +421 -331
  5. package/dist/build.d.ts +1 -16
  6. package/dist/build.js +420 -330
  7. package/dist/build.mjs +420 -330
  8. package/dist/chokidar.cjs +219 -182
  9. package/dist/chokidar.d.ts +25 -10
  10. package/dist/chokidar.js +217 -182
  11. package/dist/chokidar.mjs +218 -183
  12. package/dist/cli.cjs +21608 -20241
  13. package/dist/cli.d.ts +19 -37
  14. package/dist/cli.mjs +21262 -19910
  15. package/dist/config.cjs +357 -350
  16. package/dist/config.d.ts +19 -240
  17. package/dist/config.js +520 -515
  18. package/dist/config.mjs +346 -341
  19. package/dist/contracts-BeW9k0yZ.d.ts +54 -0
  20. package/dist/contracts-D7KIS-TK.d.ts +36 -0
  21. package/dist/coverage.cjs +448 -485
  22. package/dist/coverage.d.ts +13 -59
  23. package/dist/coverage.js +447 -484
  24. package/dist/coverage.mjs +447 -484
  25. package/dist/database.cjs +819 -828
  26. package/dist/database.d.ts +8 -24
  27. package/dist/database.js +818 -829
  28. package/dist/database.mjs +818 -829
  29. package/dist/desktop-auto-render.cjs +1700 -1522
  30. package/dist/desktop-auto-render.d.ts +4 -9
  31. package/dist/desktop-auto-render.js +1695 -1517
  32. package/dist/desktop-auto-render.mjs +1696 -1518
  33. package/dist/desktop.cjs +3 -1
  34. package/dist/desktop.d.ts +4 -1
  35. package/dist/desktop.js +1 -1
  36. package/dist/desktop.mjs +1 -1
  37. package/dist/dev-build.cjs +830 -0
  38. package/dist/dev-build.d.ts +53 -0
  39. package/dist/dev-build.js +3318 -0
  40. package/dist/dev-build.mjs +797 -0
  41. package/dist/dom.cjs +717 -590
  42. package/dist/dom.d.ts +2 -15
  43. package/dist/dom.js +714 -587
  44. package/dist/dom.mjs +716 -589
  45. package/dist/el.cjs +62 -52
  46. package/dist/el.d.ts +5 -10
  47. package/dist/el.js +60 -52
  48. package/dist/el.mjs +60 -52
  49. package/dist/fs.cjs +72 -63
  50. package/dist/fs.d.ts +22 -19
  51. package/dist/fs.js +71 -62
  52. package/dist/fs.mjs +71 -62
  53. package/dist/hmr.cjs +40 -14
  54. package/dist/hmr.d.ts +11 -23
  55. package/dist/hmr.js +38 -14
  56. package/dist/hmr.mjs +38 -14
  57. package/dist/http.cjs +251 -99
  58. package/dist/http.d.ts +38 -104
  59. package/dist/http.js +249 -99
  60. package/dist/http.mjs +249 -99
  61. package/dist/https.cjs +524 -228
  62. package/dist/https.d.ts +44 -36
  63. package/dist/https.js +520 -226
  64. package/dist/https.mjs +522 -228
  65. package/dist/index.cjs +7502 -7690
  66. package/dist/index.d.ts +8 -3
  67. package/dist/index.js +7486 -7676
  68. package/dist/index.mjs +7497 -7686
  69. package/dist/mime-types.cjs +10 -4
  70. package/dist/mime-types.d.ts +8 -11
  71. package/dist/mime-types.js +9 -3
  72. package/dist/mime-types.mjs +9 -3
  73. package/dist/native.cjs +8616 -8869
  74. package/dist/native.d.ts +7 -8
  75. package/dist/native.js +8682 -8935
  76. package/dist/native.mjs +8615 -8868
  77. package/dist/path.cjs +83 -77
  78. package/dist/path.d.ts +29 -29
  79. package/dist/path.js +82 -76
  80. package/dist/path.mjs +82 -76
  81. package/dist/pm.cjs +3300 -0
  82. package/dist/pm.d.ts +256 -0
  83. package/dist/pm.js +5638 -0
  84. package/dist/pm.mjs +3196 -0
  85. package/dist/preview-build.cjs +712 -0
  86. package/dist/preview-build.d.ts +59 -0
  87. package/dist/preview-build.js +3194 -0
  88. package/dist/preview-build.mjs +676 -0
  89. package/dist/render-context.cjs +13 -2
  90. package/dist/render-context.d.ts +9 -31
  91. package/dist/render-context.js +11 -2
  92. package/dist/render-context.mjs +11 -2
  93. package/dist/router.cjs +787 -645
  94. package/dist/router.d.ts +8 -12
  95. package/dist/router.js +786 -644
  96. package/dist/router.mjs +786 -644
  97. package/dist/runtime.cjs +1 -1
  98. package/dist/runtime.js +1 -1
  99. package/dist/runtime.mjs +1 -1
  100. package/dist/server.cjs +3315 -2603
  101. package/dist/server.d.ts +49 -4
  102. package/dist/server.js +7611 -2834
  103. package/dist/server.mjs +3317 -2607
  104. package/dist/smtp-server.cjs +128 -0
  105. package/dist/smtp-server.d.ts +27 -0
  106. package/dist/smtp-server.js +4199 -0
  107. package/dist/smtp-server.mjs +100 -0
  108. package/dist/state-DvEkDehk.d.ts +195 -0
  109. package/dist/state.cjs +768 -658
  110. package/dist/state.d.ts +11 -69
  111. package/dist/state.js +760 -650
  112. package/dist/state.mjs +767 -657
  113. package/dist/style.cjs +1011 -968
  114. package/dist/style.d.ts +13 -127
  115. package/dist/style.js +1009 -970
  116. package/dist/style.mjs +1011 -971
  117. package/dist/test-reporter.cjs +332 -316
  118. package/dist/test-reporter.d.ts +28 -33
  119. package/dist/test-reporter.js +328 -312
  120. package/dist/test-reporter.mjs +328 -312
  121. package/dist/test-runtime.cjs +927 -968
  122. package/dist/test-runtime.d.ts +24 -99
  123. package/dist/test-runtime.js +922 -965
  124. package/dist/test-runtime.mjs +922 -965
  125. package/dist/test.cjs +4428 -4273
  126. package/dist/test.d.ts +2 -8
  127. package/dist/test.js +4307 -4154
  128. package/dist/test.mjs +4419 -4267
  129. package/dist/types-BONVzPtp.d.ts +59 -0
  130. package/dist/types-BR4wMiVx.d.ts +32 -0
  131. package/dist/types-C4gKykuG.d.ts +23 -0
  132. package/dist/types-CIhpN1-K.d.ts +64 -0
  133. package/dist/types-Ckj8md_j.d.ts +84 -0
  134. package/dist/types-CpjQTAkX.d.ts +24 -0
  135. package/dist/types-D0LjrYjS.d.ts +14 -0
  136. package/dist/types-DAisuVr5.d.ts +75 -0
  137. package/dist/types-tJn88E1N.d.ts +242 -0
  138. package/dist/types.d.ts +71 -226
  139. package/dist/universal.cjs +1 -1
  140. package/dist/universal.d.ts +1 -5
  141. package/dist/universal.js +1 -1
  142. package/dist/universal.mjs +1 -1
  143. package/dist/websocket-XfyK23zD.d.ts +119 -0
  144. package/dist/ws.cjs +129 -108
  145. package/dist/ws.d.ts +21 -131
  146. package/dist/ws.js +128 -109
  147. package/dist/ws.mjs +128 -109
  148. package/dist/wss.cjs +757 -479
  149. package/dist/wss.d.ts +31 -28
  150. package/dist/wss.js +755 -479
  151. package/dist/wss.mjs +758 -482
  152. package/package.json +16 -1
  153. package/vendor/epaint-0.31.1/src/image.rs +418 -0
  154. 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: () => 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
- function existsSync(path) {
49
- try {
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/path.ts
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
- } else if (isDeno) {
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
- let normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
150
+ const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
162
151
  const parts = normalized.split(separator);
163
152
  const result = [];
164
- for (let i = 0; i < parts.length; i++) {
165
- const part = parts[i];
153
+ for (let index = 0; index < parts.length; index++) {
154
+ const part = parts[index];
166
155
  if (part === "" || part === ".") {
167
- if (i === 0 && isAbsolute) result.push("");
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 final = result.join(separator);
183
- if (final.length === 0) {
171
+ let finalPath = result.join(separator);
172
+ if (finalPath.length === 0) {
184
173
  return isAbsolute ? separator : ".";
185
174
  }
186
- if (trailingSeparator && final[final.length - 1] !== separator) {
187
- final += separator;
175
+ if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
176
+ finalPath += separator;
188
177
  }
189
- return final;
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 i = 0; i < paths.length; i++) {
196
- const path = paths[i];
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 isAbsolute = false;
212
- for (let i = paths.length - 1; i >= 0 && !isAbsolute; i--) {
213
- const path = paths[i];
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
- isAbsolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
205
+ absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
217
206
  }
218
207
  }
219
- if (!isAbsolute) {
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
- from = resolvePaths([from], isWin);
227
- to = resolvePaths([to], isWin);
228
- if (from === to) return "";
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 = from.split(separator).filter((p) => p.length > 0);
231
- const toParts = to.split(separator).filter((p) => p.length > 0);
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
- for (let i = 0; i < minLength; i++) {
235
- if (fromParts[i] === toParts[i]) {
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
- for (let i = 0; i < upCount; i++) {
231
+ const upCount = fromParts.length - commonLength;
232
+ for (let index = 0; index < upCount; index++) {
244
233
  result.push("..");
245
234
  }
246
- for (let i = commonLength; i < toParts.length; i++) {
247
- result.push(toParts[i]);
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 lastSepIndex = normalized.lastIndexOf(separator);
256
- if (lastSepIndex === -1) return ".";
257
- if (lastSepIndex === 0) return separator;
258
- return normalized.slice(0, lastSepIndex);
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 lastSepIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
263
- let base = lastSepIndex === -1 ? path : path.slice(lastSepIndex + 1);
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 lastSepIndex = findLastSeparator(path);
272
- if (lastDotIndex === -1 || lastDotIndex < lastSepIndex || lastDotIndex === path.length - 1) {
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
- if (path[0] === "/") {
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["_watched"].add(baseDir);
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 (runtime === "node") {
365
- if (this._watcher) {
366
- this._watcher.add(pathArray);
367
- }
368
- } else {
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 (runtime === "node") {
382
- if (this._watcher) {
383
- this._watcher.unwatch(pathArray);
384
- }
385
- } else {
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 (runtime === "node") {
399
- if (this._watcher) {
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 (runtime === "node" && this._watcher) {
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
- function getBaseDirectory(pattern) {
432
- const normalizedPattern = normalizePath2(pattern);
433
- const parts = normalizedPattern.split(/[\\\/]/);
434
- let baseDir = "";
435
- let sawGlob = false;
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
- if (normalizedPattern && existsSync(normalizedPattern)) {
447
- try {
448
- return statSync(normalizedPattern).isDirectory() ? normalizedPattern : normalizePath2(dirname(normalizedPattern)) || ".";
449
- } catch {
450
- return normalizePath2(dirname(normalizedPattern)) || ".";
451
- }
479
+ /**
480
+ * Internal method to untrack watched paths
481
+ * @internal
482
+ */
483
+ _untrackWatchedPath(path) {
484
+ this._watched.delete(path);
452
485
  }
453
- const lastSegment = parts[parts.length - 1] || "";
454
- if (lastSegment.includes(".") && !lastSegment.startsWith(".")) {
455
- return normalizePath2(dirname(normalizedPattern)) || ".";
486
+ /**
487
+ * Internal method to read closed state
488
+ * @internal
489
+ */
490
+ _isClosed() {
491
+ return this._closed;
456
492
  }
457
- return normalizedPattern || ".";
458
- }
459
- function matchesPattern(filePath, pattern) {
460
- const regexPattern = normalizePath2(pattern).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\?/g, ".");
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
- pathArray.forEach((path) => {
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
- if (runtime === "node") {
477
- const fs2 = require("fs");
478
- watchMap.forEach((patterns, baseDir) => setupFsWatch(watcher, baseDir, patterns, fs2));
479
- } else if (runtime === "bun") {
480
- const fs2 = require("fs");
481
- watchMap.forEach((patterns, baseDir) => setupFsWatch(watcher, baseDir, patterns, fs2));
482
- } else if (runtime === "deno") {
483
- const baseDirs = Array.from(watchMap.keys());
484
- const allPatterns = Array.from(watchMap.values()).flat();
485
- (async () => {
486
- try {
487
- const denoWatcher = Deno.watchFs(baseDirs);
488
- for await (const event of denoWatcher) {
489
- if (watcher["_closed"]) break;
490
- for (const path of event.paths) {
491
- const normalizedPath = normalizePath2(path);
492
- if (!matchesAnyPattern(normalizedPath, allPatterns)) continue;
493
- switch (event.kind) {
494
- case "create":
495
- emitEvent(watcher, "add", path);
496
- break;
497
- case "modify":
498
- emitEvent(watcher, "change", path);
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
- pathArray.forEach((path) => watcher.add(path));
513
- queueMicrotask(() => watcher.emit("ready"));
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 getRuntime() {
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 = {
@@ -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
- * Default export
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;