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
@@ -0,0 +1,797 @@
1
+ import {createRequire as __createRequire} from 'module';const require = __createRequire(import.meta.url);
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // src/shares/runtime.ts
10
+ var runtime = (() => {
11
+ if (typeof Deno !== "undefined") return "deno";
12
+ if (typeof Bun !== "undefined") return "bun";
13
+ return "node";
14
+ })();
15
+ var isNode = runtime === "node";
16
+ var isBun = runtime === "bun";
17
+ var isDeno = runtime === "deno";
18
+
19
+ // src/server/fs/node-modules.ts
20
+ var fs;
21
+ var fsPromises;
22
+ if (isNode || isBun) {
23
+ fs = __require("fs");
24
+ fsPromises = __require("fs/promises");
25
+ }
26
+
27
+ // src/server/fs/utils.ts
28
+ function parseOptions(options, defaultValue) {
29
+ return typeof options === "string" ? { encoding: options } : options || defaultValue;
30
+ }
31
+ function decodeContent(content, encoding) {
32
+ if (encoding) {
33
+ return new TextDecoder(encoding).decode(content);
34
+ }
35
+ return Buffer.from(content instanceof ArrayBuffer ? new Uint8Array(content) : content);
36
+ }
37
+ function dataToUint8Array(data) {
38
+ if (typeof data === "string") {
39
+ return new TextEncoder().encode(data);
40
+ }
41
+ if (data instanceof Buffer) {
42
+ return new Uint8Array(data);
43
+ }
44
+ return data;
45
+ }
46
+ function createDirentFromDenoEntry(entry) {
47
+ return {
48
+ name: entry.name,
49
+ isFile: () => entry.isFile,
50
+ isDirectory: () => entry.isDirectory,
51
+ isBlockDevice: () => false,
52
+ isCharacterDevice: () => false,
53
+ isSymbolicLink: () => entry.isSymlink || false,
54
+ isFIFO: () => false,
55
+ isSocket: () => false
56
+ };
57
+ }
58
+ function processDenoEntries(iterator, withFileTypes) {
59
+ const entries = [];
60
+ for (const entry of iterator) {
61
+ if (withFileTypes) {
62
+ entries.push(createDirentFromDenoEntry(entry));
63
+ } else {
64
+ entries.push(entry.name);
65
+ }
66
+ }
67
+ return entries;
68
+ }
69
+ function createStatsFromDenoFileInfo(info) {
70
+ return {
71
+ isFile: () => info.isFile,
72
+ isDirectory: () => info.isDirectory,
73
+ isBlockDevice: () => false,
74
+ isCharacterDevice: () => false,
75
+ isSymbolicLink: () => info.isSymlink || false,
76
+ isFIFO: () => false,
77
+ isSocket: () => false,
78
+ dev: info.dev || 0,
79
+ ino: info.ino || 0,
80
+ mode: info.mode || 0,
81
+ nlink: info.nlink || 1,
82
+ uid: info.uid || 0,
83
+ gid: info.gid || 0,
84
+ rdev: 0,
85
+ size: info.size,
86
+ blksize: info.blksize || 4096,
87
+ blocks: info.blocks || Math.ceil(info.size / 512),
88
+ atimeMs: info.atime?.getTime() || Date.now(),
89
+ mtimeMs: info.mtime?.getTime() || Date.now(),
90
+ ctimeMs: info.birthtime?.getTime() || Date.now(),
91
+ birthtimeMs: info.birthtime?.getTime() || Date.now(),
92
+ atime: info.atime || /* @__PURE__ */ new Date(),
93
+ mtime: info.mtime || /* @__PURE__ */ new Date(),
94
+ ctime: info.birthtime || /* @__PURE__ */ new Date(),
95
+ birthtime: info.birthtime || /* @__PURE__ */ new Date()
96
+ };
97
+ }
98
+
99
+ // src/server/fs/file-ops.ts
100
+ function readFileSync(path, options) {
101
+ const opts = parseOptions(options, {});
102
+ if (isNode || isBun) {
103
+ return fs.readFileSync(path, opts);
104
+ } else if (isDeno) {
105
+ const content = Deno.readFileSync(path);
106
+ return decodeContent(content, opts.encoding);
107
+ }
108
+ throw new Error("Unsupported runtime");
109
+ }
110
+ function writeFileSync(path, data, options) {
111
+ const opts = parseOptions(options, {});
112
+ if (isNode || isBun) {
113
+ fs.writeFileSync(path, data, opts);
114
+ } else if (isDeno) {
115
+ Deno.writeFileSync(path, dataToUint8Array(data));
116
+ }
117
+ }
118
+ function existsSync(path) {
119
+ try {
120
+ statSync(path);
121
+ return true;
122
+ } catch {
123
+ return false;
124
+ }
125
+ }
126
+ function statSync(path) {
127
+ if (isNode || isBun) {
128
+ return fs.statSync(path);
129
+ } else if (isDeno) {
130
+ const info = Deno.statSync(path);
131
+ return createStatsFromDenoFileInfo(info);
132
+ }
133
+ throw new Error("Unsupported runtime");
134
+ }
135
+
136
+ // src/server/fs/directory-ops.ts
137
+ function mkdirSync(path, options) {
138
+ const opts = typeof options === "number" ? { mode: options } : options || {};
139
+ if (isNode || isBun) {
140
+ fs.mkdirSync(path, opts);
141
+ } else if (isDeno) {
142
+ Deno.mkdirSync(path, { recursive: opts.recursive });
143
+ }
144
+ }
145
+ function readdirSync(path, options) {
146
+ const opts = parseOptions(options, {});
147
+ if (isNode || isBun) {
148
+ return fs.readdirSync(path, opts);
149
+ } else if (isDeno) {
150
+ return processDenoEntries(Deno.readDirSync(path), opts.withFileTypes);
151
+ }
152
+ throw new Error("Unsupported runtime");
153
+ }
154
+
155
+ // src/server/path/platform.ts
156
+ function getSeparator(isWin) {
157
+ return isWin ? "\\" : "/";
158
+ }
159
+ function getCwd() {
160
+ if (isNode || isBun) {
161
+ return process.cwd();
162
+ }
163
+ if (isDeno) {
164
+ return Deno.cwd();
165
+ }
166
+ return "/";
167
+ }
168
+ var isWindows = (() => {
169
+ if (isNode) {
170
+ return process.platform === "win32";
171
+ }
172
+ if (isDeno) {
173
+ return Deno.build.os === "windows";
174
+ }
175
+ return typeof process !== "undefined" && process.platform === "win32";
176
+ })();
177
+
178
+ // src/server/path/operations.ts
179
+ function findLastSeparator(path) {
180
+ return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
181
+ }
182
+ function isAbsolutePosix(path) {
183
+ return path.length > 0 && path[0] === "/";
184
+ }
185
+ function isAbsoluteWin(path) {
186
+ const len = path.length;
187
+ if (len === 0) return false;
188
+ const code = path.charCodeAt(0);
189
+ if (code === 47 || code === 92) {
190
+ return true;
191
+ }
192
+ if (code >= 65 && code <= 90 || code >= 97 && code <= 122) {
193
+ if (len > 2 && path.charCodeAt(1) === 58) {
194
+ const code2 = path.charCodeAt(2);
195
+ if (code2 === 47 || code2 === 92) {
196
+ return true;
197
+ }
198
+ }
199
+ }
200
+ return false;
201
+ }
202
+ function normalizePath(path, isWin) {
203
+ if (path.length === 0) return ".";
204
+ const separator = getSeparator(isWin);
205
+ const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
206
+ const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
207
+ const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
208
+ const parts = normalized.split(separator);
209
+ const result = [];
210
+ for (let index = 0; index < parts.length; index++) {
211
+ const part = parts[index];
212
+ if (part === "" || part === ".") {
213
+ if (index === 0 && isAbsolute) result.push("");
214
+ continue;
215
+ }
216
+ if (part === "..") {
217
+ if (result.length > 0 && result[result.length - 1] !== "..") {
218
+ if (!(result.length === 1 && result[0] === "")) {
219
+ result.pop();
220
+ }
221
+ } else if (!isAbsolute) {
222
+ result.push("..");
223
+ }
224
+ } else {
225
+ result.push(part);
226
+ }
227
+ }
228
+ let finalPath = result.join(separator);
229
+ if (finalPath.length === 0) {
230
+ return isAbsolute ? separator : ".";
231
+ }
232
+ if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
233
+ finalPath += separator;
234
+ }
235
+ return finalPath;
236
+ }
237
+ function joinPaths(paths, isWin) {
238
+ if (paths.length === 0) return ".";
239
+ const separator = getSeparator(isWin);
240
+ let joined = "";
241
+ for (let index = 0; index < paths.length; index++) {
242
+ const path = paths[index];
243
+ if (path && path.length > 0) {
244
+ if (joined.length === 0) {
245
+ joined = path;
246
+ } else {
247
+ joined += separator + path;
248
+ }
249
+ }
250
+ }
251
+ if (joined.length === 0) return ".";
252
+ return normalizePath(joined, isWin);
253
+ }
254
+ function resolvePaths(paths, isWin) {
255
+ const separator = getSeparator(isWin);
256
+ let resolved = "";
257
+ let absolute = false;
258
+ for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
259
+ const path = paths[index];
260
+ if (path && path.length > 0) {
261
+ resolved = path + (resolved.length > 0 ? separator + resolved : "");
262
+ absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
263
+ }
264
+ }
265
+ if (!absolute) {
266
+ const cwd = getCwd();
267
+ resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
268
+ }
269
+ return normalizePath(resolved, isWin);
270
+ }
271
+ function relativePath(from, to, isWin) {
272
+ const resolvedFrom = resolvePaths([from], isWin);
273
+ const resolvedTo = resolvePaths([to], isWin);
274
+ if (resolvedFrom === resolvedTo) return "";
275
+ const separator = getSeparator(isWin);
276
+ const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
277
+ const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
278
+ const minLength = Math.min(fromParts.length, toParts.length);
279
+ let commonLength = 0;
280
+ for (let index = 0; index < minLength; index++) {
281
+ if (fromParts[index] === toParts[index]) {
282
+ commonLength++;
283
+ } else {
284
+ break;
285
+ }
286
+ }
287
+ const result = [];
288
+ const upCount = fromParts.length - commonLength;
289
+ for (let index = 0; index < upCount; index++) {
290
+ result.push("..");
291
+ }
292
+ for (let index = commonLength; index < toParts.length; index++) {
293
+ result.push(toParts[index]);
294
+ }
295
+ return result.join(separator) || ".";
296
+ }
297
+ function getDirname(path, isWin) {
298
+ if (path.length === 0) return ".";
299
+ const separator = getSeparator(isWin);
300
+ const normalized = normalizePath(path, isWin);
301
+ const lastSeparatorIndex = normalized.lastIndexOf(separator);
302
+ if (lastSeparatorIndex === -1) return ".";
303
+ if (lastSeparatorIndex === 0) return separator;
304
+ return normalized.slice(0, lastSeparatorIndex);
305
+ }
306
+ function getBasename(path, ext, isWin) {
307
+ if (path.length === 0) return "";
308
+ const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
309
+ let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
310
+ if (ext && base.endsWith(ext)) {
311
+ base = base.slice(0, base.length - ext.length);
312
+ }
313
+ return base;
314
+ }
315
+ function getExtname(path) {
316
+ const lastDotIndex = path.lastIndexOf(".");
317
+ const lastSeparatorIndex = findLastSeparator(path);
318
+ if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
319
+ return "";
320
+ }
321
+ return path.slice(lastDotIndex);
322
+ }
323
+ function parsePath(path, isWin) {
324
+ let root = "";
325
+ if (isWin) {
326
+ if (path.length >= 2 && path[1] === ":") {
327
+ root = path.slice(0, 2);
328
+ if (path.length > 2 && (path[2] === "\\" || path[2] === "/")) {
329
+ root += "\\";
330
+ }
331
+ } else if (path[0] === "\\" || path[0] === "/") {
332
+ root = "\\";
333
+ }
334
+ } else if (path[0] === "/") {
335
+ root = "/";
336
+ }
337
+ const dir = getDirname(path, isWin);
338
+ const base = getBasename(path, void 0, isWin);
339
+ const ext = getExtname(path);
340
+ const name = ext ? base.slice(0, base.length - ext.length) : base;
341
+ return { root, dir, base, ext, name };
342
+ }
343
+ function formatPath(pathObject, isWin) {
344
+ const separator = getSeparator(isWin);
345
+ const dir = pathObject.dir || pathObject.root || "";
346
+ const base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
347
+ if (!dir) return base;
348
+ if (dir === pathObject.root) return dir + base;
349
+ return dir + separator + base;
350
+ }
351
+ function createPathOps(isWin) {
352
+ return {
353
+ sep: getSeparator(isWin),
354
+ delimiter: isWin ? ";" : ":",
355
+ normalize: (path) => normalizePath(path, isWin),
356
+ join: (...paths) => joinPaths(paths, isWin),
357
+ resolve: (...paths) => resolvePaths(paths, isWin),
358
+ isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
359
+ relative: (from, to) => relativePath(from, to, isWin),
360
+ dirname: (path) => getDirname(path, isWin),
361
+ basename: (path, ext) => getBasename(path, ext, isWin),
362
+ extname: (path) => getExtname(path),
363
+ parse: (path) => parsePath(path, isWin),
364
+ format: (pathObject) => formatPath(pathObject, isWin)
365
+ };
366
+ }
367
+
368
+ // src/server/path/index.ts
369
+ var posix = createPathOps(false);
370
+ var win32 = createPathOps(true);
371
+ function join(...paths) {
372
+ return joinPaths(paths, isWindows);
373
+ }
374
+ function resolve(...paths) {
375
+ return resolvePaths(paths, isWindows);
376
+ }
377
+ function relative(from, to) {
378
+ return relativePath(from, to, isWindows);
379
+ }
380
+ function dirname(path) {
381
+ return getDirname(path, isWindows);
382
+ }
383
+ function basename(path, ext) {
384
+ return getBasename(path, ext, isWindows);
385
+ }
386
+ function extname(path) {
387
+ return getExtname(path);
388
+ }
389
+
390
+ // src/shares/workspace-package/package-json.ts
391
+ function readPackageJson(filePath) {
392
+ try {
393
+ const packageJsonBuffer = readFileSync(filePath, "utf-8");
394
+ const packageJsonText = typeof packageJsonBuffer === "string" ? packageJsonBuffer : packageJsonBuffer.toString("utf-8");
395
+ return JSON.parse(packageJsonText);
396
+ } catch {
397
+ return void 0;
398
+ }
399
+ }
400
+
401
+ // src/shares/workspace-package/roots.ts
402
+ function findPackageDirectory(startDir, resolveMatch) {
403
+ let currentDir = resolve(startDir);
404
+ while (true) {
405
+ const match = resolveMatch(currentDir);
406
+ if (match) {
407
+ return match;
408
+ }
409
+ const parentDir = dirname(currentDir);
410
+ if (parentDir === currentDir) {
411
+ return void 0;
412
+ }
413
+ currentDir = parentDir;
414
+ }
415
+ }
416
+ function findWorkspacePackageRoot(startDir, packageName) {
417
+ return findPackageDirectory(startDir, (currentDir) => {
418
+ const packageJsonPath = join(currentDir, "package.json");
419
+ const packageJson = existsSync(packageJsonPath) ? readPackageJson(packageJsonPath) : void 0;
420
+ return packageJson?.name === packageName ? currentDir : void 0;
421
+ });
422
+ }
423
+ function findInstalledPackageRoot(startDir, packageName) {
424
+ return findPackageDirectory(startDir, (currentDir) => {
425
+ const candidate = join(currentDir, "node_modules", ...packageName.split("/"));
426
+ return existsSync(candidate) ? candidate : void 0;
427
+ });
428
+ }
429
+
430
+ // src/shares/workspace-package/candidates.ts
431
+ function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
432
+ const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
433
+ const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
434
+ resolve(packageRoot, "dist", `${subpath}.cjs`),
435
+ resolve(packageRoot, "dist", `${subpath}.js`),
436
+ resolve(packageRoot, "dist", `${subpath}.mjs`)
437
+ ] : [
438
+ resolve(packageRoot, "dist", `${subpath}.mjs`),
439
+ resolve(packageRoot, "dist", `${subpath}.js`),
440
+ resolve(packageRoot, "dist", `${subpath}.cjs`)
441
+ ];
442
+ const sourceCandidates = [
443
+ resolve(packageRoot, "src", `${subpath}.ts`),
444
+ resolve(packageRoot, "src", `${subpath}.tsx`)
445
+ ];
446
+ return options.preferBuilt ? [...builtCandidates, ...sourceCandidates] : [...sourceCandidates, ...builtCandidates];
447
+ }
448
+
449
+ // src/shares/workspace-package/resolve.ts
450
+ function isWorkspacePackageSpecifier(specifier) {
451
+ return specifier === "elit" || specifier.startsWith("elit/");
452
+ }
453
+ function resolveWorkspacePackageImport(specifier, startDir, options = {}) {
454
+ if (!isWorkspacePackageSpecifier(specifier)) {
455
+ return void 0;
456
+ }
457
+ const packageRoots = /* @__PURE__ */ new Set();
458
+ const workspacePackageRoot = findWorkspacePackageRoot(startDir, "elit");
459
+ const installedPackageRoot = findInstalledPackageRoot(startDir, "elit");
460
+ if (workspacePackageRoot) {
461
+ packageRoots.add(workspacePackageRoot);
462
+ }
463
+ if (installedPackageRoot) {
464
+ packageRoots.add(installedPackageRoot);
465
+ }
466
+ for (const packageRoot of packageRoots) {
467
+ for (const candidate of getWorkspacePackageImportCandidates(packageRoot, specifier, options)) {
468
+ if (existsSync(candidate)) {
469
+ return candidate;
470
+ }
471
+ }
472
+ }
473
+ return void 0;
474
+ }
475
+
476
+ // src/preview-build/helpers.ts
477
+ function normalizePackageDependencies(value) {
478
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
479
+ return {};
480
+ }
481
+ const dependencies = {};
482
+ for (const [key, entryValue] of Object.entries(value)) {
483
+ if (typeof entryValue === "string") {
484
+ dependencies[key] = entryValue;
485
+ }
486
+ }
487
+ return dependencies;
488
+ }
489
+ function readJsonFile(filePath) {
490
+ try {
491
+ const rawContent = readFileSync(filePath, "utf-8");
492
+ const content = typeof rawContent === "string" ? rawContent : rawContent.toString("utf-8");
493
+ return JSON.parse(content);
494
+ } catch {
495
+ return void 0;
496
+ }
497
+ }
498
+ function createWorkspacePackagePlugin(resolveDir, options = {}) {
499
+ return {
500
+ name: "workspace-package-self-reference",
501
+ setup(build) {
502
+ build.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
503
+ const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || resolveDir, options);
504
+ return resolved ? { path: resolved } : void 0;
505
+ });
506
+ }
507
+ };
508
+ }
509
+ function normalizeRelativePath(filePath) {
510
+ const normalized = filePath.replace(/\\/g, "/");
511
+ return normalized === "" ? "." : normalized;
512
+ }
513
+ function normalizeImportPath(filePath) {
514
+ return filePath.replace(/\\/g, "/");
515
+ }
516
+ function createInlineConfigSource(config) {
517
+ const entries = Object.entries(config).filter(([, value]) => value !== void 0);
518
+ if (entries.length === 0) {
519
+ return "{}";
520
+ }
521
+ return `{ ${entries.map(([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`).join(", ")} }`;
522
+ }
523
+ function writeStandalonePackageJson(packageJsonPath, outputFile, options = {}) {
524
+ const currentPackageJson = existsSync(packageJsonPath) ? readJsonFile(packageJsonPath) : void 0;
525
+ const basePackageJson = options.replaceDependencies && currentPackageJson ? Object.fromEntries(Object.entries(currentPackageJson).filter(([key]) => key !== "dependencies")) : currentPackageJson ?? {};
526
+ const dependencies = options.replaceDependencies ? { ...options.dependencies ?? {} } : {
527
+ ...normalizePackageDependencies(currentPackageJson?.dependencies),
528
+ ...options.dependencies ?? {}
529
+ };
530
+ const nextPackageJson = {
531
+ ...basePackageJson,
532
+ ...Object.keys(dependencies).length > 0 ? { dependencies } : {},
533
+ private: true,
534
+ type: "commonjs",
535
+ main: outputFile
536
+ };
537
+ writeFileSync(packageJsonPath, `${JSON.stringify(nextPackageJson, null, 2)}
538
+ `);
539
+ }
540
+
541
+ // src/dev-build/plan.ts
542
+ function resolveStandaloneDevBuildPlan(options) {
543
+ const cwd = resolve(options.cwd || process.cwd());
544
+ const devConfig = options.devConfig || void 0;
545
+ const allBuilds = options.allBuilds && options.allBuilds.length > 0 ? options.allBuilds : [options.buildConfig || {}];
546
+ const primaryBuild = options.buildConfig || allBuilds[0] || {};
547
+ const outputRoot = resolve(cwd, options.outDir || devConfig?.outDir || "dev-dist");
548
+ const outputFile = options.outFile || devConfig?.outFile || "index.js";
549
+ const outputPath = resolve(join(outputRoot, outputFile));
550
+ const bundleDir = dirname(outputPath);
551
+ if (devConfig?.clients && devConfig.clients.length > 0) {
552
+ const clients = devConfig.clients.map((client, index) => {
553
+ const buildForClient = allBuilds[index] || primaryBuild;
554
+ return {
555
+ basePath: client.basePath || "",
556
+ fallbackRootRelativePath: normalizeRelativePath(relative(bundleDir, resolve(cwd, buildForClient.outDir || "dist"))),
557
+ index: client.index,
558
+ rootRelativePath: normalizeRelativePath(relative(bundleDir, resolve(cwd, client.root || ".")))
559
+ };
560
+ });
561
+ return {
562
+ clients,
563
+ outputPath,
564
+ outputRoot,
565
+ packageJsonPath: join(outputRoot, "package.json"),
566
+ usesClientArray: true
567
+ };
568
+ }
569
+ const rootRelativePath = normalizeRelativePath(relative(bundleDir, resolve(cwd, devConfig?.root || ".")));
570
+ const fallbackRootRelativePath = normalizeRelativePath(relative(bundleDir, resolve(cwd, primaryBuild.outDir || "dist")));
571
+ return {
572
+ fallbackRootRelativePath,
573
+ index: devConfig?.index,
574
+ outputPath,
575
+ outputRoot,
576
+ packageJsonPath: join(outputRoot, "package.json"),
577
+ clients: void 0,
578
+ rootRelativePath,
579
+ usesClientArray: false
580
+ };
581
+ }
582
+ function resolveStandaloneDevFallbackRootRelativePath(plan, options) {
583
+ if (plan.fallbackRootRelativePath) {
584
+ return plan.fallbackRootRelativePath;
585
+ }
586
+ const cwd = resolve(options.cwd || process.cwd());
587
+ const primaryBuild = options.buildConfig || options.allBuilds?.[0] || {};
588
+ return normalizeRelativePath(relative(dirname(plan.outputPath), resolve(cwd, primaryBuild.outDir || "dist")));
589
+ }
590
+ function createStandaloneDevFallbackRootRelativePath(options) {
591
+ const plan = resolveStandaloneDevBuildPlan(options);
592
+ return resolveStandaloneDevFallbackRootRelativePath(plan, options);
593
+ }
594
+
595
+ // src/dev-build/entry-source.ts
596
+ function createStandaloneDevEntrySource(configPath, plan, devConfig, buildOptions) {
597
+ const fallbackRootRelativePath = resolveStandaloneDevFallbackRootRelativePath(plan, {
598
+ cwd: buildOptions?.cwd,
599
+ buildConfig: buildOptions?.buildConfig,
600
+ allBuilds: buildOptions?.allBuilds
601
+ });
602
+ const configImportBlock = configPath ? `import userConfigModule from ${JSON.stringify(normalizeImportPath(configPath))};
603
+ const resolvedConfig = userConfigModule ?? {};` : "const resolvedConfig = {} as Record<string, any>;";
604
+ const inlineConfigSource = createInlineConfigSource({
605
+ port: devConfig?.port,
606
+ host: devConfig?.host,
607
+ open: devConfig?.open,
608
+ logging: devConfig?.logging,
609
+ domain: devConfig?.domain,
610
+ env: devConfig?.env,
611
+ basePath: devConfig?.basePath,
612
+ index: devConfig?.index,
613
+ watch: devConfig?.watch,
614
+ ignore: devConfig?.ignore
615
+ });
616
+ const clientArraySource = plan.clients ? `const runtimeClients = [
617
+ ${plan.clients.map((client, index) => ` {
618
+ ...(mergedConfig.clients?.[${index}] ?? {}),
619
+ basePath: mergedConfig.clients?.[${index}]?.basePath ?? ${JSON.stringify(client.basePath)},
620
+ fallbackRoot: resolve(__dirname, ${JSON.stringify(client.fallbackRootRelativePath)}),
621
+ index: mergedConfig.clients?.[${index}]?.index ?? ${client.index ? JSON.stringify(client.index) : "undefined"},
622
+ root: resolve(__dirname, ${JSON.stringify(client.rootRelativePath)}),
623
+ mode: 'dev',
624
+ }`).join(",\n")}
625
+ ];` : "";
626
+ const rootSource = plan.usesClientArray ? " clients: runtimeClients,\n" : ` root: resolve(__dirname, ${JSON.stringify(plan.rootRelativePath || ".")}),
627
+ fallbackRoot: resolve(__dirname, ${JSON.stringify(fallbackRootRelativePath)}),
628
+ basePath: mergedConfig.basePath ?? '',
629
+ index: mergedConfig.index ?? ${plan.index ? JSON.stringify(plan.index) : "undefined"},
630
+ `;
631
+ return `import { createDevServer } from 'elit/server';
632
+ import { resolve } from 'node:path';
633
+
634
+ ${configImportBlock}
635
+
636
+ const inlineDevConfig = ${inlineConfigSource};
637
+ const runtimeConfig = (resolvedConfig as any).dev ?? {};
638
+ const mergedConfig = { ...runtimeConfig, ...inlineDevConfig };
639
+ ${clientArraySource}
640
+ const options = {
641
+ port: mergedConfig.port || 3000,
642
+ host: mergedConfig.host || 'localhost',
643
+ open: mergedConfig.open ?? false,
644
+ logging: mergedConfig.logging ?? true,
645
+ domain: mergedConfig.domain,
646
+ api: mergedConfig.api,
647
+ ws: mergedConfig.ws,
648
+ https: mergedConfig.https,
649
+ ssr: mergedConfig.ssr,
650
+ proxy: mergedConfig.proxy,
651
+ worker: mergedConfig.worker ?? [],
652
+ watch: mergedConfig.watch ?? ['**/*.ts', '**/*.js', '**/*.html', '**/*.css'],
653
+ ignore: mergedConfig.ignore ?? ['node_modules/**', 'dist/**', '.git/**', '**/*.d.ts'],
654
+ env: mergedConfig.env,
655
+ ${rootSource} mode: 'dev',
656
+ };
657
+
658
+ const devServer = createDevServer(options);
659
+
660
+ const shutdown = async () => {
661
+ await devServer.close();
662
+ process.exit(0);
663
+ };
664
+
665
+ process.on('SIGINT', shutdown);
666
+ process.on('SIGTERM', shutdown);
667
+ `;
668
+ }
669
+
670
+ // src/dev-build/runtime.ts
671
+ var defaultStandaloneDevRuntimeIgnorePatterns = ["node_modules/**", "dist/**", "dev-dist/**", ".git/**", "coverage/**", "**/*.d.ts"];
672
+ function normalizeStandaloneDevRuntimeIgnorePatterns(devConfig) {
673
+ const merged = new Set(defaultStandaloneDevRuntimeIgnorePatterns);
674
+ if (devConfig?.outDir) {
675
+ merged.add(`${normalizeRelativePath(devConfig.outDir).replace(/^\.\//, "")}/**`);
676
+ }
677
+ for (const pattern of devConfig?.ignore || []) {
678
+ merged.add(pattern);
679
+ }
680
+ return [...merged];
681
+ }
682
+ function shouldIgnoreStandaloneDevRuntimePath(relativePath2, isDirectory, ignorePatterns) {
683
+ const normalizedPath = relativePath2.replace(/\\/g, "/").replace(/^\.\//, "");
684
+ if (!normalizedPath) {
685
+ return false;
686
+ }
687
+ for (const pattern of ignorePatterns) {
688
+ const normalizedPattern = pattern.replace(/\\/g, "/").replace(/^\.\//, "");
689
+ if (normalizedPattern === "**/*.d.ts") {
690
+ if (!isDirectory && normalizedPath.endsWith(".d.ts")) {
691
+ return true;
692
+ }
693
+ continue;
694
+ }
695
+ const directoryToken = normalizedPattern.replace(/^\*\*\//, "").replace(/\/\*\*$/, "").replace(/\*.*$/, "").replace(/\/+$/, "");
696
+ if (!directoryToken) {
697
+ continue;
698
+ }
699
+ if (normalizedPath === directoryToken || normalizedPath.startsWith(`${directoryToken}/`) || normalizedPath.includes(`/${directoryToken}/`)) {
700
+ return true;
701
+ }
702
+ }
703
+ return false;
704
+ }
705
+ function rootContainsEsbuildDependentSources(rootDir, ignorePatterns) {
706
+ if (!existsSync(rootDir)) {
707
+ return false;
708
+ }
709
+ const pendingDirectories = [rootDir];
710
+ while (pendingDirectories.length > 0) {
711
+ const currentDirectory = pendingDirectories.pop();
712
+ const entries = readdirSync(currentDirectory, { withFileTypes: true });
713
+ for (const entry of entries) {
714
+ const absolutePath = join(currentDirectory, entry.name);
715
+ const relativePath2 = normalizeRelativePath(relative(rootDir, absolutePath));
716
+ const isDirectory = entry.isDirectory();
717
+ if (shouldIgnoreStandaloneDevRuntimePath(relativePath2, isDirectory, ignorePatterns)) {
718
+ continue;
719
+ }
720
+ if (isDirectory) {
721
+ pendingDirectories.push(absolutePath);
722
+ continue;
723
+ }
724
+ if (!entry.isFile()) {
725
+ continue;
726
+ }
727
+ const extension = extname(entry.name).toLowerCase();
728
+ if (extension === ".tsx" || extension === ".jsx") {
729
+ return true;
730
+ }
731
+ }
732
+ }
733
+ return false;
734
+ }
735
+ function standaloneDevNeedsEsbuildRuntime(cwd, devConfig) {
736
+ const resolvedCwd = resolve(cwd || process.cwd());
737
+ const clientRoots = devConfig?.clients && devConfig.clients.length > 0 ? devConfig.clients.map((client) => resolve(resolvedCwd, client.root || ".")) : [resolve(resolvedCwd, devConfig?.root || ".")];
738
+ const ignorePatterns = normalizeStandaloneDevRuntimeIgnorePatterns(devConfig);
739
+ return clientRoots.some((clientRoot) => rootContainsEsbuildDependentSources(clientRoot, ignorePatterns));
740
+ }
741
+
742
+ // src/dev-build/build.ts
743
+ async function buildStandaloneDevServer(options) {
744
+ const cwd = resolve(options.cwd || process.cwd());
745
+ const plan = resolveStandaloneDevBuildPlan({
746
+ ...options,
747
+ cwd
748
+ });
749
+ const outputDir = dirname(plan.outputPath);
750
+ mkdirSync(outputDir, { recursive: true });
751
+ const { build, version } = await import("esbuild");
752
+ const workspacePackagePlugin = createWorkspacePackagePlugin(cwd, {
753
+ preferBuilt: true,
754
+ preferredBuiltFormat: "cjs"
755
+ });
756
+ const entrySource = createStandaloneDevEntrySource(options.configPath, plan, options.devConfig, {
757
+ cwd,
758
+ buildConfig: options.buildConfig,
759
+ allBuilds: options.allBuilds
760
+ });
761
+ const needsEsbuildRuntime = standaloneDevNeedsEsbuildRuntime(cwd, options.devConfig);
762
+ await build({
763
+ stdin: {
764
+ contents: entrySource,
765
+ loader: "ts",
766
+ resolveDir: cwd,
767
+ sourcefile: "elit-standalone-dev-entry.ts"
768
+ },
769
+ bundle: true,
770
+ outfile: plan.outputPath,
771
+ format: "cjs",
772
+ mainFields: ["module", "main"],
773
+ platform: "node",
774
+ plugins: [workspacePackagePlugin],
775
+ external: ["esbuild", "javascript-obfuscator", "open"],
776
+ sourcemap: false,
777
+ target: "es2020",
778
+ logLevel: options.logging === false ? "silent" : "info"
779
+ });
780
+ writeStandalonePackageJson(plan.packageJsonPath, basename(plan.outputPath), {
781
+ dependencies: needsEsbuildRuntime ? {
782
+ esbuild: typeof version === "string" && version.length > 0 ? `^${version}` : "*"
783
+ } : {},
784
+ replaceDependencies: true
785
+ });
786
+ if (options.logging !== false) {
787
+ console.log(` \u2713 Standalone dev server \u2192 ${plan.outputPath}`);
788
+ }
789
+ return plan.outputPath;
790
+ }
791
+ export {
792
+ buildStandaloneDevServer,
793
+ createStandaloneDevEntrySource,
794
+ createStandaloneDevFallbackRootRelativePath,
795
+ resolveStandaloneDevBuildPlan,
796
+ standaloneDevNeedsEsbuildRuntime
797
+ };