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.js CHANGED
@@ -7,10 +7,7 @@
7
7
  throw Error('Dynamic require of "' + x + '" is not supported');
8
8
  });
9
9
 
10
- // src/chokidar.ts
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
- function existsSync(path) {
31
- try {
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/path.ts
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
- } else if (isDeno) {
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
- let normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
130
+ const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
144
131
  const parts = normalized.split(separator);
145
132
  const result = [];
146
- for (let i = 0; i < parts.length; i++) {
147
- const part = parts[i];
133
+ for (let index = 0; index < parts.length; index++) {
134
+ const part = parts[index];
148
135
  if (part === "" || part === ".") {
149
- if (i === 0 && isAbsolute) result.push("");
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 final = result.join(separator);
165
- if (final.length === 0) {
151
+ let finalPath = result.join(separator);
152
+ if (finalPath.length === 0) {
166
153
  return isAbsolute ? separator : ".";
167
154
  }
168
- if (trailingSeparator && final[final.length - 1] !== separator) {
169
- final += separator;
155
+ if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
156
+ finalPath += separator;
170
157
  }
171
- return final;
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 i = 0; i < paths.length; i++) {
178
- const path = paths[i];
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 isAbsolute = false;
194
- for (let i = paths.length - 1; i >= 0 && !isAbsolute; i--) {
195
- const path = paths[i];
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
- isAbsolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
185
+ absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
199
186
  }
200
187
  }
201
- if (!isAbsolute) {
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
- from = resolvePaths([from], isWin);
209
- to = resolvePaths([to], isWin);
210
- if (from === to) return "";
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 = from.split(separator).filter((p) => p.length > 0);
213
- const toParts = to.split(separator).filter((p) => p.length > 0);
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
- for (let i = 0; i < minLength; i++) {
217
- if (fromParts[i] === toParts[i]) {
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
- for (let i = 0; i < upCount; i++) {
211
+ const upCount = fromParts.length - commonLength;
212
+ for (let index = 0; index < upCount; index++) {
226
213
  result.push("..");
227
214
  }
228
- for (let i = commonLength; i < toParts.length; i++) {
229
- result.push(toParts[i]);
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 lastSepIndex = normalized.lastIndexOf(separator);
238
- if (lastSepIndex === -1) return ".";
239
- if (lastSepIndex === 0) return separator;
240
- return normalized.slice(0, lastSepIndex);
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 lastSepIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
245
- let base = lastSepIndex === -1 ? path : path.slice(lastSepIndex + 1);
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 lastSepIndex = findLastSeparator(path);
254
- if (lastDotIndex === -1 || lastDotIndex < lastSepIndex || lastDotIndex === path.length - 1) {
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
- if (path[0] === "/") {
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["_watched"].add(baseDir);
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 (runtime === "node") {
347
- if (this._watcher) {
348
- this._watcher.add(pathArray);
349
- }
350
- } else {
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 (runtime === "node") {
364
- if (this._watcher) {
365
- this._watcher.unwatch(pathArray);
366
- }
367
- } else {
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 (runtime === "node") {
381
- if (this._watcher) {
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 (runtime === "node" && this._watcher) {
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
- function getBaseDirectory(pattern) {
414
- const normalizedPattern = normalizePath2(pattern);
415
- const parts = normalizedPattern.split(/[\\\/]/);
416
- let baseDir = "";
417
- let sawGlob = false;
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
- if (normalizedPattern && existsSync(normalizedPattern)) {
429
- try {
430
- return statSync(normalizedPattern).isDirectory() ? normalizedPattern : normalizePath2(dirname(normalizedPattern)) || ".";
431
- } catch {
432
- return normalizePath2(dirname(normalizedPattern)) || ".";
433
- }
459
+ /**
460
+ * Internal method to untrack watched paths
461
+ * @internal
462
+ */
463
+ _untrackWatchedPath(path) {
464
+ this._watched.delete(path);
434
465
  }
435
- const lastSegment = parts[parts.length - 1] || "";
436
- if (lastSegment.includes(".") && !lastSegment.startsWith(".")) {
437
- return normalizePath2(dirname(normalizedPattern)) || ".";
466
+ /**
467
+ * Internal method to read closed state
468
+ * @internal
469
+ */
470
+ _isClosed() {
471
+ return this._closed;
438
472
  }
439
- return normalizedPattern || ".";
440
- }
441
- function matchesPattern(filePath, pattern) {
442
- const regexPattern = normalizePath2(pattern).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\?/g, ".");
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
- pathArray.forEach((path) => {
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
- if (runtime === "node") {
459
- const fs2 = __require("fs");
460
- watchMap.forEach((patterns, baseDir) => setupFsWatch(watcher, baseDir, patterns, fs2));
461
- } else if (runtime === "bun") {
462
- const fs2 = __require("fs");
463
- watchMap.forEach((patterns, baseDir) => setupFsWatch(watcher, baseDir, patterns, fs2));
464
- } else if (runtime === "deno") {
465
- const baseDirs = Array.from(watchMap.keys());
466
- const allPatterns = Array.from(watchMap.values()).flat();
467
- (async () => {
468
- try {
469
- const denoWatcher = Deno.watchFs(baseDirs);
470
- for await (const event of denoWatcher) {
471
- if (watcher["_closed"]) break;
472
- for (const path of event.paths) {
473
- const normalizedPath = normalizePath2(path);
474
- if (!matchesAnyPattern(normalizedPath, allPatterns)) continue;
475
- switch (event.kind) {
476
- case "create":
477
- emitEvent(watcher, "add", path);
478
- break;
479
- case "modify":
480
- emitEvent(watcher, "change", path);
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
- pathArray.forEach((path) => watcher.add(path));
495
- queueMicrotask(() => watcher.emit("ready"));
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 getRuntime() {
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
  })();