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