elit 3.6.5 → 3.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/README.md +6 -0
  4. package/dist/build.cjs +421 -331
  5. package/dist/build.d.ts +1 -16
  6. package/dist/build.js +420 -330
  7. package/dist/build.mjs +420 -330
  8. package/dist/chokidar.cjs +219 -182
  9. package/dist/chokidar.d.ts +25 -10
  10. package/dist/chokidar.js +217 -182
  11. package/dist/chokidar.mjs +218 -183
  12. package/dist/cli.cjs +21608 -20241
  13. package/dist/cli.d.ts +19 -37
  14. package/dist/cli.mjs +21262 -19910
  15. package/dist/config.cjs +357 -350
  16. package/dist/config.d.ts +19 -240
  17. package/dist/config.js +520 -515
  18. package/dist/config.mjs +346 -341
  19. package/dist/contracts-BeW9k0yZ.d.ts +54 -0
  20. package/dist/contracts-D7KIS-TK.d.ts +36 -0
  21. package/dist/coverage.cjs +448 -485
  22. package/dist/coverage.d.ts +13 -59
  23. package/dist/coverage.js +447 -484
  24. package/dist/coverage.mjs +447 -484
  25. package/dist/database.cjs +819 -828
  26. package/dist/database.d.ts +8 -24
  27. package/dist/database.js +818 -829
  28. package/dist/database.mjs +818 -829
  29. package/dist/desktop-auto-render.cjs +1700 -1522
  30. package/dist/desktop-auto-render.d.ts +4 -9
  31. package/dist/desktop-auto-render.js +1695 -1517
  32. package/dist/desktop-auto-render.mjs +1696 -1518
  33. package/dist/desktop.cjs +3 -1
  34. package/dist/desktop.d.ts +4 -1
  35. package/dist/desktop.js +1 -1
  36. package/dist/desktop.mjs +1 -1
  37. package/dist/dev-build.cjs +830 -0
  38. package/dist/dev-build.d.ts +53 -0
  39. package/dist/dev-build.js +3318 -0
  40. package/dist/dev-build.mjs +797 -0
  41. package/dist/dom.cjs +717 -590
  42. package/dist/dom.d.ts +2 -15
  43. package/dist/dom.js +714 -587
  44. package/dist/dom.mjs +716 -589
  45. package/dist/el.cjs +62 -52
  46. package/dist/el.d.ts +5 -10
  47. package/dist/el.js +60 -52
  48. package/dist/el.mjs +60 -52
  49. package/dist/fs.cjs +72 -63
  50. package/dist/fs.d.ts +22 -19
  51. package/dist/fs.js +71 -62
  52. package/dist/fs.mjs +71 -62
  53. package/dist/hmr.cjs +40 -14
  54. package/dist/hmr.d.ts +11 -23
  55. package/dist/hmr.js +38 -14
  56. package/dist/hmr.mjs +38 -14
  57. package/dist/http.cjs +251 -99
  58. package/dist/http.d.ts +38 -104
  59. package/dist/http.js +249 -99
  60. package/dist/http.mjs +249 -99
  61. package/dist/https.cjs +524 -228
  62. package/dist/https.d.ts +44 -36
  63. package/dist/https.js +520 -226
  64. package/dist/https.mjs +522 -228
  65. package/dist/index.cjs +7502 -7690
  66. package/dist/index.d.ts +8 -3
  67. package/dist/index.js +7486 -7676
  68. package/dist/index.mjs +7497 -7686
  69. package/dist/mime-types.cjs +10 -4
  70. package/dist/mime-types.d.ts +8 -11
  71. package/dist/mime-types.js +9 -3
  72. package/dist/mime-types.mjs +9 -3
  73. package/dist/native.cjs +8616 -8869
  74. package/dist/native.d.ts +7 -8
  75. package/dist/native.js +8682 -8935
  76. package/dist/native.mjs +8615 -8868
  77. package/dist/path.cjs +83 -77
  78. package/dist/path.d.ts +29 -29
  79. package/dist/path.js +82 -76
  80. package/dist/path.mjs +82 -76
  81. package/dist/pm.cjs +3300 -0
  82. package/dist/pm.d.ts +256 -0
  83. package/dist/pm.js +5638 -0
  84. package/dist/pm.mjs +3196 -0
  85. package/dist/preview-build.cjs +712 -0
  86. package/dist/preview-build.d.ts +59 -0
  87. package/dist/preview-build.js +3194 -0
  88. package/dist/preview-build.mjs +676 -0
  89. package/dist/render-context.cjs +13 -2
  90. package/dist/render-context.d.ts +9 -31
  91. package/dist/render-context.js +11 -2
  92. package/dist/render-context.mjs +11 -2
  93. package/dist/router.cjs +787 -645
  94. package/dist/router.d.ts +8 -12
  95. package/dist/router.js +786 -644
  96. package/dist/router.mjs +786 -644
  97. package/dist/runtime.cjs +1 -1
  98. package/dist/runtime.js +1 -1
  99. package/dist/runtime.mjs +1 -1
  100. package/dist/server.cjs +3315 -2603
  101. package/dist/server.d.ts +49 -4
  102. package/dist/server.js +7611 -2834
  103. package/dist/server.mjs +3317 -2607
  104. package/dist/smtp-server.cjs +128 -0
  105. package/dist/smtp-server.d.ts +27 -0
  106. package/dist/smtp-server.js +4199 -0
  107. package/dist/smtp-server.mjs +100 -0
  108. package/dist/state-DvEkDehk.d.ts +195 -0
  109. package/dist/state.cjs +768 -658
  110. package/dist/state.d.ts +11 -69
  111. package/dist/state.js +760 -650
  112. package/dist/state.mjs +767 -657
  113. package/dist/style.cjs +1011 -968
  114. package/dist/style.d.ts +13 -127
  115. package/dist/style.js +1009 -970
  116. package/dist/style.mjs +1011 -971
  117. package/dist/test-reporter.cjs +332 -316
  118. package/dist/test-reporter.d.ts +28 -33
  119. package/dist/test-reporter.js +328 -312
  120. package/dist/test-reporter.mjs +328 -312
  121. package/dist/test-runtime.cjs +927 -968
  122. package/dist/test-runtime.d.ts +24 -99
  123. package/dist/test-runtime.js +922 -965
  124. package/dist/test-runtime.mjs +922 -965
  125. package/dist/test.cjs +4428 -4273
  126. package/dist/test.d.ts +2 -8
  127. package/dist/test.js +4307 -4154
  128. package/dist/test.mjs +4419 -4267
  129. package/dist/types-BONVzPtp.d.ts +59 -0
  130. package/dist/types-BR4wMiVx.d.ts +32 -0
  131. package/dist/types-C4gKykuG.d.ts +23 -0
  132. package/dist/types-CIhpN1-K.d.ts +64 -0
  133. package/dist/types-Ckj8md_j.d.ts +84 -0
  134. package/dist/types-CpjQTAkX.d.ts +24 -0
  135. package/dist/types-D0LjrYjS.d.ts +14 -0
  136. package/dist/types-DAisuVr5.d.ts +75 -0
  137. package/dist/types-tJn88E1N.d.ts +242 -0
  138. package/dist/types.d.ts +71 -226
  139. package/dist/universal.cjs +1 -1
  140. package/dist/universal.d.ts +1 -5
  141. package/dist/universal.js +1 -1
  142. package/dist/universal.mjs +1 -1
  143. package/dist/websocket-XfyK23zD.d.ts +119 -0
  144. package/dist/ws.cjs +129 -108
  145. package/dist/ws.d.ts +21 -131
  146. package/dist/ws.js +128 -109
  147. package/dist/ws.mjs +128 -109
  148. package/dist/wss.cjs +757 -479
  149. package/dist/wss.d.ts +31 -28
  150. package/dist/wss.js +755 -479
  151. package/dist/wss.mjs +758 -482
  152. package/package.json +16 -1
  153. package/vendor/epaint-0.31.1/src/image.rs +418 -0
  154. package/dist/server-CcBFc2F5.d.ts +0 -449
package/dist/build.js CHANGED
@@ -2533,7 +2533,19 @@ error: ${text}`);
2533
2533
  }
2534
2534
  });
2535
2535
 
2536
- // src/runtime.ts
2536
+ // src/build/constants.ts
2537
+ var defaultOptions = {
2538
+ outDir: "dist",
2539
+ minify: true,
2540
+ sourcemap: false,
2541
+ target: "es2020",
2542
+ format: "esm",
2543
+ treeshake: true,
2544
+ logging: true,
2545
+ external: []
2546
+ };
2547
+
2548
+ // src/shares/runtime.ts
2537
2549
  var runtime = (() => {
2538
2550
  if (typeof Deno !== "undefined") return "deno";
2539
2551
  if (typeof Bun !== "undefined") return "bun";
@@ -2543,7 +2555,15 @@ error: ${text}`);
2543
2555
  var isBun = runtime === "bun";
2544
2556
  var isDeno = runtime === "deno";
2545
2557
 
2546
- // src/fs.ts
2558
+ // src/server/fs/node-modules.ts
2559
+ var fs;
2560
+ var fsPromises;
2561
+ if (isNode || isBun) {
2562
+ fs = __require("fs");
2563
+ fsPromises = __require("fs/promises");
2564
+ }
2565
+
2566
+ // src/server/fs/utils.ts
2547
2567
  function parseOptions(options, defaultValue) {
2548
2568
  return typeof options === "string" ? { encoding: options } : options || defaultValue;
2549
2569
  }
@@ -2562,12 +2582,37 @@ error: ${text}`);
2562
2582
  }
2563
2583
  return data;
2564
2584
  }
2565
- var fs;
2566
- var fsPromises;
2567
- if (isNode || isBun) {
2568
- fs = __require("fs");
2569
- fsPromises = __require("fs/promises");
2585
+ function createStatsFromDenoFileInfo(info) {
2586
+ return {
2587
+ isFile: () => info.isFile,
2588
+ isDirectory: () => info.isDirectory,
2589
+ isBlockDevice: () => false,
2590
+ isCharacterDevice: () => false,
2591
+ isSymbolicLink: () => info.isSymlink || false,
2592
+ isFIFO: () => false,
2593
+ isSocket: () => false,
2594
+ dev: info.dev || 0,
2595
+ ino: info.ino || 0,
2596
+ mode: info.mode || 0,
2597
+ nlink: info.nlink || 1,
2598
+ uid: info.uid || 0,
2599
+ gid: info.gid || 0,
2600
+ rdev: 0,
2601
+ size: info.size,
2602
+ blksize: info.blksize || 4096,
2603
+ blocks: info.blocks || Math.ceil(info.size / 512),
2604
+ atimeMs: info.atime?.getTime() || Date.now(),
2605
+ mtimeMs: info.mtime?.getTime() || Date.now(),
2606
+ ctimeMs: info.birthtime?.getTime() || Date.now(),
2607
+ birthtimeMs: info.birthtime?.getTime() || Date.now(),
2608
+ atime: info.atime || /* @__PURE__ */ new Date(),
2609
+ mtime: info.mtime || /* @__PURE__ */ new Date(),
2610
+ ctime: info.birthtime || /* @__PURE__ */ new Date(),
2611
+ birthtime: info.birthtime || /* @__PURE__ */ new Date()
2612
+ };
2570
2613
  }
2614
+
2615
+ // src/server/fs/file-ops.ts
2571
2616
  function readFileSync(path, options) {
2572
2617
  const opts = parseOptions(options, {});
2573
2618
  if (isNode || isBun) {
@@ -2603,6 +2648,8 @@ error: ${text}`);
2603
2648
  }
2604
2649
  throw new Error("Unsupported runtime");
2605
2650
  }
2651
+
2652
+ // src/server/fs/directory-ops.ts
2606
2653
  function mkdirSync(path, options) {
2607
2654
  const opts = typeof options === "number" ? { mode: options } : options || {};
2608
2655
  if (isNode || isBun) {
@@ -2611,6 +2658,8 @@ error: ${text}`);
2611
2658
  Deno.mkdirSync(path, { recursive: opts.recursive });
2612
2659
  }
2613
2660
  }
2661
+
2662
+ // src/server/fs/path-ops.ts
2614
2663
  function copyFileSync(src, dest, flags) {
2615
2664
  if (isNode || isBun) {
2616
2665
  fs.copyFileSync(src, dest, flags);
@@ -2618,67 +2667,34 @@ error: ${text}`);
2618
2667
  Deno.copyFileSync(src, dest);
2619
2668
  }
2620
2669
  }
2621
- function createStatsFromDenoFileInfo(info) {
2622
- return {
2623
- isFile: () => info.isFile,
2624
- isDirectory: () => info.isDirectory,
2625
- isBlockDevice: () => false,
2626
- isCharacterDevice: () => false,
2627
- isSymbolicLink: () => info.isSymlink || false,
2628
- isFIFO: () => false,
2629
- isSocket: () => false,
2630
- dev: info.dev || 0,
2631
- ino: info.ino || 0,
2632
- mode: info.mode || 0,
2633
- nlink: info.nlink || 1,
2634
- uid: info.uid || 0,
2635
- gid: info.gid || 0,
2636
- rdev: 0,
2637
- size: info.size,
2638
- blksize: info.blksize || 4096,
2639
- blocks: info.blocks || Math.ceil(info.size / 512),
2640
- atimeMs: info.atime?.getTime() || Date.now(),
2641
- mtimeMs: info.mtime?.getTime() || Date.now(),
2642
- ctimeMs: info.birthtime?.getTime() || Date.now(),
2643
- birthtimeMs: info.birthtime?.getTime() || Date.now(),
2644
- atime: info.atime || /* @__PURE__ */ new Date(),
2645
- mtime: info.mtime || /* @__PURE__ */ new Date(),
2646
- ctime: info.birthtime || /* @__PURE__ */ new Date(),
2647
- birthtime: info.birthtime || /* @__PURE__ */ new Date()
2648
- };
2649
- }
2650
2670
 
2651
- // src/path.ts
2671
+ // src/server/path/platform.ts
2652
2672
  function getSeparator(isWin) {
2653
2673
  return isWin ? "\\" : "/";
2654
2674
  }
2655
2675
  function getCwd() {
2656
2676
  if (isNode || isBun) {
2657
2677
  return process.cwd();
2658
- } else if (isDeno) {
2678
+ }
2679
+ if (isDeno) {
2659
2680
  return Deno.cwd();
2660
2681
  }
2661
2682
  return "/";
2662
2683
  }
2684
+ var isWindows = (() => {
2685
+ if (isNode) {
2686
+ return process.platform === "win32";
2687
+ }
2688
+ if (isDeno) {
2689
+ return Deno.build.os === "windows";
2690
+ }
2691
+ return typeof process !== "undefined" && process.platform === "win32";
2692
+ })();
2693
+
2694
+ // src/server/path/operations.ts
2663
2695
  function findLastSeparator(path) {
2664
2696
  return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
2665
2697
  }
2666
- function createPathOps(isWin) {
2667
- return {
2668
- sep: getSeparator(isWin),
2669
- delimiter: isWin ? ";" : ":",
2670
- normalize: (path) => normalizePath(path, isWin),
2671
- join: (...paths) => joinPaths(paths, isWin),
2672
- resolve: (...paths) => resolvePaths(paths, isWin),
2673
- isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
2674
- relative: (from, to) => relativePath(from, to, isWin),
2675
- dirname: (path) => getDirname(path, isWin),
2676
- basename: (path, ext) => getBasename(path, ext, isWin),
2677
- extname: (path) => getExtname(path),
2678
- parse: (path) => parsePath(path, isWin),
2679
- format: (pathObject) => formatPath(pathObject, isWin)
2680
- };
2681
- }
2682
2698
  function isAbsolutePosix(path) {
2683
2699
  return path.length > 0 && path[0] === "/";
2684
2700
  }
@@ -2699,28 +2715,18 @@ error: ${text}`);
2699
2715
  }
2700
2716
  return false;
2701
2717
  }
2702
- var isWindows = (() => {
2703
- if (isNode) {
2704
- return process.platform === "win32";
2705
- } else if (isDeno) {
2706
- return Deno.build.os === "windows";
2707
- }
2708
- return typeof process !== "undefined" && process.platform === "win32";
2709
- })();
2710
- var posix = createPathOps(false);
2711
- var win32 = createPathOps(true);
2712
2718
  function normalizePath(path, isWin) {
2713
2719
  if (path.length === 0) return ".";
2714
2720
  const separator = getSeparator(isWin);
2715
2721
  const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
2716
2722
  const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
2717
- let normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
2723
+ const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
2718
2724
  const parts = normalized.split(separator);
2719
2725
  const result = [];
2720
- for (let i = 0; i < parts.length; i++) {
2721
- const part = parts[i];
2726
+ for (let index = 0; index < parts.length; index++) {
2727
+ const part = parts[index];
2722
2728
  if (part === "" || part === ".") {
2723
- if (i === 0 && isAbsolute) result.push("");
2729
+ if (index === 0 && isAbsolute) result.push("");
2724
2730
  continue;
2725
2731
  }
2726
2732
  if (part === "..") {
@@ -2735,21 +2741,21 @@ error: ${text}`);
2735
2741
  result.push(part);
2736
2742
  }
2737
2743
  }
2738
- let final = result.join(separator);
2739
- if (final.length === 0) {
2744
+ let finalPath = result.join(separator);
2745
+ if (finalPath.length === 0) {
2740
2746
  return isAbsolute ? separator : ".";
2741
2747
  }
2742
- if (trailingSeparator && final[final.length - 1] !== separator) {
2743
- final += separator;
2748
+ if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
2749
+ finalPath += separator;
2744
2750
  }
2745
- return final;
2751
+ return finalPath;
2746
2752
  }
2747
2753
  function joinPaths(paths, isWin) {
2748
2754
  if (paths.length === 0) return ".";
2749
2755
  const separator = getSeparator(isWin);
2750
2756
  let joined = "";
2751
- for (let i = 0; i < paths.length; i++) {
2752
- const path = paths[i];
2757
+ for (let index = 0; index < paths.length; index++) {
2758
+ const path = paths[index];
2753
2759
  if (path && path.length > 0) {
2754
2760
  if (joined.length === 0) {
2755
2761
  joined = path;
@@ -2764,43 +2770,43 @@ error: ${text}`);
2764
2770
  function resolvePaths(paths, isWin) {
2765
2771
  const separator = getSeparator(isWin);
2766
2772
  let resolved = "";
2767
- let isAbsolute = false;
2768
- for (let i = paths.length - 1; i >= 0 && !isAbsolute; i--) {
2769
- const path = paths[i];
2773
+ let absolute = false;
2774
+ for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
2775
+ const path = paths[index];
2770
2776
  if (path && path.length > 0) {
2771
2777
  resolved = path + (resolved.length > 0 ? separator + resolved : "");
2772
- isAbsolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
2778
+ absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
2773
2779
  }
2774
2780
  }
2775
- if (!isAbsolute) {
2781
+ if (!absolute) {
2776
2782
  const cwd = getCwd();
2777
2783
  resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
2778
2784
  }
2779
2785
  return normalizePath(resolved, isWin);
2780
2786
  }
2781
2787
  function relativePath(from, to, isWin) {
2782
- from = resolvePaths([from], isWin);
2783
- to = resolvePaths([to], isWin);
2784
- if (from === to) return "";
2788
+ const resolvedFrom = resolvePaths([from], isWin);
2789
+ const resolvedTo = resolvePaths([to], isWin);
2790
+ if (resolvedFrom === resolvedTo) return "";
2785
2791
  const separator = getSeparator(isWin);
2786
- const fromParts = from.split(separator).filter((p) => p.length > 0);
2787
- const toParts = to.split(separator).filter((p) => p.length > 0);
2788
- let commonLength = 0;
2792
+ const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
2793
+ const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
2789
2794
  const minLength = Math.min(fromParts.length, toParts.length);
2790
- for (let i = 0; i < minLength; i++) {
2791
- if (fromParts[i] === toParts[i]) {
2795
+ let commonLength = 0;
2796
+ for (let index = 0; index < minLength; index++) {
2797
+ if (fromParts[index] === toParts[index]) {
2792
2798
  commonLength++;
2793
2799
  } else {
2794
2800
  break;
2795
2801
  }
2796
2802
  }
2797
- const upCount = fromParts.length - commonLength;
2798
2803
  const result = [];
2799
- for (let i = 0; i < upCount; i++) {
2804
+ const upCount = fromParts.length - commonLength;
2805
+ for (let index = 0; index < upCount; index++) {
2800
2806
  result.push("..");
2801
2807
  }
2802
- for (let i = commonLength; i < toParts.length; i++) {
2803
- result.push(toParts[i]);
2808
+ for (let index = commonLength; index < toParts.length; index++) {
2809
+ result.push(toParts[index]);
2804
2810
  }
2805
2811
  return result.join(separator) || ".";
2806
2812
  }
@@ -2808,15 +2814,15 @@ error: ${text}`);
2808
2814
  if (path.length === 0) return ".";
2809
2815
  const separator = getSeparator(isWin);
2810
2816
  const normalized = normalizePath(path, isWin);
2811
- const lastSepIndex = normalized.lastIndexOf(separator);
2812
- if (lastSepIndex === -1) return ".";
2813
- if (lastSepIndex === 0) return separator;
2814
- return normalized.slice(0, lastSepIndex);
2817
+ const lastSeparatorIndex = normalized.lastIndexOf(separator);
2818
+ if (lastSeparatorIndex === -1) return ".";
2819
+ if (lastSeparatorIndex === 0) return separator;
2820
+ return normalized.slice(0, lastSeparatorIndex);
2815
2821
  }
2816
2822
  function getBasename(path, ext, isWin) {
2817
2823
  if (path.length === 0) return "";
2818
- const lastSepIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
2819
- let base = lastSepIndex === -1 ? path : path.slice(lastSepIndex + 1);
2824
+ const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
2825
+ let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
2820
2826
  if (ext && base.endsWith(ext)) {
2821
2827
  base = base.slice(0, base.length - ext.length);
2822
2828
  }
@@ -2824,8 +2830,8 @@ error: ${text}`);
2824
2830
  }
2825
2831
  function getExtname(path) {
2826
2832
  const lastDotIndex = path.lastIndexOf(".");
2827
- const lastSepIndex = findLastSeparator(path);
2828
- if (lastDotIndex === -1 || lastDotIndex < lastSepIndex || lastDotIndex === path.length - 1) {
2833
+ const lastSeparatorIndex = findLastSeparator(path);
2834
+ if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
2829
2835
  return "";
2830
2836
  }
2831
2837
  return path.slice(lastDotIndex);
@@ -2841,10 +2847,8 @@ error: ${text}`);
2841
2847
  } else if (path[0] === "\\" || path[0] === "/") {
2842
2848
  root = "\\";
2843
2849
  }
2844
- } else {
2845
- if (path[0] === "/") {
2846
- root = "/";
2847
- }
2850
+ } else if (path[0] === "/") {
2851
+ root = "/";
2848
2852
  }
2849
2853
  const dir = getDirname(path, isWin);
2850
2854
  const base = getBasename(path, void 0, isWin);
@@ -2860,6 +2864,26 @@ error: ${text}`);
2860
2864
  if (dir === pathObject.root) return dir + base;
2861
2865
  return dir + separator + base;
2862
2866
  }
2867
+ function createPathOps(isWin) {
2868
+ return {
2869
+ sep: getSeparator(isWin),
2870
+ delimiter: isWin ? ";" : ":",
2871
+ normalize: (path) => normalizePath(path, isWin),
2872
+ join: (...paths) => joinPaths(paths, isWin),
2873
+ resolve: (...paths) => resolvePaths(paths, isWin),
2874
+ isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
2875
+ relative: (from, to) => relativePath(from, to, isWin),
2876
+ dirname: (path) => getDirname(path, isWin),
2877
+ basename: (path, ext) => getBasename(path, ext, isWin),
2878
+ extname: (path) => getExtname(path),
2879
+ parse: (path) => parsePath(path, isWin),
2880
+ format: (pathObject) => formatPath(pathObject, isWin)
2881
+ };
2882
+ }
2883
+
2884
+ // src/server/path/index.ts
2885
+ var posix = createPathOps(false);
2886
+ var win32 = createPathOps(true);
2863
2887
  function join(...paths) {
2864
2888
  return joinPaths(paths, isWindows);
2865
2889
  }
@@ -2876,7 +2900,141 @@ error: ${text}`);
2876
2900
  return getExtname(path);
2877
2901
  }
2878
2902
 
2879
- // src/workspace-package.ts
2903
+ // src/build/helpers.ts
2904
+ function ensureDir(dirPath) {
2905
+ try {
2906
+ mkdirSync(dirPath, { recursive: true });
2907
+ } catch {
2908
+ }
2909
+ }
2910
+ function calculateBuildMetrics(startTime, outputPath) {
2911
+ const buildTime = Date.now() - startTime;
2912
+ const stats = statSync(outputPath);
2913
+ return { buildTime, size: stats.size };
2914
+ }
2915
+ function readFileAsString(filePath) {
2916
+ const contentBuffer = readFileSync(filePath, "utf-8");
2917
+ return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
2918
+ }
2919
+ function resolveBuildPaths(config) {
2920
+ const entryPath = resolve(config.entry);
2921
+ const outDir = resolve(config.outDir);
2922
+ let outFile = config.outFile;
2923
+ if (!outFile) {
2924
+ const baseName = basename(config.entry, extname(config.entry));
2925
+ const ext = config.format === "cjs" ? ".cjs" : ".js";
2926
+ outFile = baseName + ext;
2927
+ }
2928
+ return {
2929
+ entryPath,
2930
+ outDir,
2931
+ outFile,
2932
+ outputPath: join(outDir, outFile)
2933
+ };
2934
+ }
2935
+ function createDefine(config) {
2936
+ const define = {};
2937
+ if (!config.env) {
2938
+ return define;
2939
+ }
2940
+ Object.entries(config.env).forEach(([key, value]) => {
2941
+ if (key.startsWith("VITE_")) {
2942
+ define[`import.meta.env.${key}`] = JSON.stringify(value);
2943
+ }
2944
+ });
2945
+ if (config.env.MODE) {
2946
+ define["import.meta.env.MODE"] = JSON.stringify(config.env.MODE);
2947
+ }
2948
+ define["import.meta.env.DEV"] = JSON.stringify(config.env.MODE !== "production");
2949
+ define["import.meta.env.PROD"] = JSON.stringify(config.env.MODE === "production");
2950
+ return define;
2951
+ }
2952
+ function copyBuildFiles(config, outDir) {
2953
+ if (!config.copy || config.copy.length === 0) {
2954
+ return;
2955
+ }
2956
+ if (config.logging) {
2957
+ console.log("\n\u{1F4E6} Copying files...");
2958
+ }
2959
+ for (const copyItem of config.copy) {
2960
+ const fromPath = resolve(copyItem.from);
2961
+ const toPath = resolve(outDir, copyItem.to);
2962
+ const targetDir = dirname(toPath);
2963
+ if (!existsSync(targetDir)) {
2964
+ ensureDir(targetDir);
2965
+ }
2966
+ if (!existsSync(fromPath)) {
2967
+ if (config.logging) {
2968
+ console.warn(` \u26A0 File not found: ${copyItem.from}`);
2969
+ }
2970
+ continue;
2971
+ }
2972
+ if (copyItem.transform) {
2973
+ const content = readFileAsString(fromPath);
2974
+ const transformed = copyItem.transform(content, config);
2975
+ writeFileSync(toPath, transformed);
2976
+ } else {
2977
+ copyFileSync(fromPath, toPath);
2978
+ }
2979
+ if (config.logging) {
2980
+ console.log(` \u2713 ${copyItem.from} \u2192 ${copyItem.to}`);
2981
+ }
2982
+ }
2983
+ }
2984
+ function formatBytes(bytes) {
2985
+ if (bytes === 0) {
2986
+ return "0 B";
2987
+ }
2988
+ const k = 1024;
2989
+ const sizes = ["B", "KB", "MB", "GB"];
2990
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
2991
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
2992
+ }
2993
+
2994
+ // src/build/logging.ts
2995
+ function logBuildInfo(config, outputPath) {
2996
+ console.log("\n\u{1F528} Building...");
2997
+ console.log(` Entry: ${config.entry}`);
2998
+ console.log(` Output: ${outputPath}`);
2999
+ console.log(` Format: ${config.format}`);
3000
+ console.log(` Target: ${config.target}`);
3001
+ }
3002
+ function logBuildSuccess(buildTime, size) {
3003
+ console.log("\n\u2705 Build successful!");
3004
+ console.log(` Time: ${buildTime}ms`);
3005
+ console.log(` Size: ${formatBytes(size)}`);
3006
+ }
3007
+ function logMetafileSummary(result) {
3008
+ if (!result?.metafile) {
3009
+ return;
3010
+ }
3011
+ const inputs = Object.keys(result.metafile.inputs).length;
3012
+ console.log(` Files: ${inputs} input(s)`);
3013
+ const outputKeys = Object.keys(result.metafile.outputs);
3014
+ if (outputKeys.length === 0) {
3015
+ return;
3016
+ }
3017
+ const mainOutput = result.metafile.outputs[outputKeys[0]];
3018
+ if (!mainOutput?.inputs) {
3019
+ return;
3020
+ }
3021
+ const sortedInputs = Object.entries(mainOutput.inputs).sort(([, a], [, b]) => {
3022
+ const aBytes = a.bytesInOutput || 0;
3023
+ const bBytes = b.bytesInOutput || 0;
3024
+ return bBytes - aBytes;
3025
+ }).slice(0, 5);
3026
+ if (sortedInputs.length === 0) {
3027
+ return;
3028
+ }
3029
+ console.log("\n \u{1F4CA} Top 5 largest modules:");
3030
+ sortedInputs.forEach(([file, info]) => {
3031
+ const fileName = file.split(/[/\\]/).pop() || file;
3032
+ const infoBytes = info.bytesInOutput || 0;
3033
+ console.log(` ${fileName.padEnd(30)} ${formatBytes(infoBytes)}`);
3034
+ });
3035
+ }
3036
+
3037
+ // src/shares/workspace-package/package-json.ts
2880
3038
  function readPackageJson(filePath) {
2881
3039
  try {
2882
3040
  const packageJsonBuffer = readFileSync(filePath, "utf-8");
@@ -2886,13 +3044,14 @@ error: ${text}`);
2886
3044
  return void 0;
2887
3045
  }
2888
3046
  }
2889
- function findWorkspacePackageRoot(startDir, packageName) {
3047
+
3048
+ // src/shares/workspace-package/roots.ts
3049
+ function findPackageDirectory(startDir, resolveMatch) {
2890
3050
  let currentDir = resolve(startDir);
2891
3051
  while (true) {
2892
- const packageJsonPath = join(currentDir, "package.json");
2893
- const packageJson = existsSync(packageJsonPath) ? readPackageJson(packageJsonPath) : void 0;
2894
- if (packageJson?.name === packageName) {
2895
- return currentDir;
3052
+ const match = resolveMatch(currentDir);
3053
+ if (match) {
3054
+ return match;
2896
3055
  }
2897
3056
  const parentDir = dirname(currentDir);
2898
3057
  if (parentDir === currentDir) {
@@ -2901,20 +3060,21 @@ error: ${text}`);
2901
3060
  currentDir = parentDir;
2902
3061
  }
2903
3062
  }
3063
+ function findWorkspacePackageRoot(startDir, packageName) {
3064
+ return findPackageDirectory(startDir, (currentDir) => {
3065
+ const packageJsonPath = join(currentDir, "package.json");
3066
+ const packageJson = existsSync(packageJsonPath) ? readPackageJson(packageJsonPath) : void 0;
3067
+ return packageJson?.name === packageName ? currentDir : void 0;
3068
+ });
3069
+ }
2904
3070
  function findInstalledPackageRoot(startDir, packageName) {
2905
- let currentDir = resolve(startDir);
2906
- while (true) {
3071
+ return findPackageDirectory(startDir, (currentDir) => {
2907
3072
  const candidate = join(currentDir, "node_modules", ...packageName.split("/"));
2908
- if (existsSync(candidate)) {
2909
- return candidate;
2910
- }
2911
- const parentDir = dirname(currentDir);
2912
- if (parentDir === currentDir) {
2913
- return void 0;
2914
- }
2915
- currentDir = parentDir;
2916
- }
3073
+ return existsSync(candidate) ? candidate : void 0;
3074
+ });
2917
3075
  }
3076
+
3077
+ // src/shares/workspace-package/candidates.ts
2918
3078
  function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
2919
3079
  const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
2920
3080
  const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
@@ -2932,14 +3092,24 @@ error: ${text}`);
2932
3092
  ];
2933
3093
  return options.preferBuilt ? [...builtCandidates, ...sourceCandidates] : [...sourceCandidates, ...builtCandidates];
2934
3094
  }
3095
+
3096
+ // src/shares/workspace-package/resolve.ts
3097
+ function isWorkspacePackageSpecifier(specifier) {
3098
+ return specifier === "elit" || specifier.startsWith("elit/");
3099
+ }
2935
3100
  function resolveWorkspacePackageImport(specifier, startDir, options = {}) {
2936
- if (specifier !== "elit" && !specifier.startsWith("elit/")) {
3101
+ if (!isWorkspacePackageSpecifier(specifier)) {
2937
3102
  return void 0;
2938
3103
  }
2939
- const packageRoots = [
2940
- findWorkspacePackageRoot(startDir, "elit"),
2941
- findInstalledPackageRoot(startDir, "elit")
2942
- ].filter((value, index, values) => typeof value === "string" && values.indexOf(value) === index);
3104
+ const packageRoots = /* @__PURE__ */ new Set();
3105
+ const workspacePackageRoot = findWorkspacePackageRoot(startDir, "elit");
3106
+ const installedPackageRoot = findInstalledPackageRoot(startDir, "elit");
3107
+ if (workspacePackageRoot) {
3108
+ packageRoots.add(workspacePackageRoot);
3109
+ }
3110
+ if (installedPackageRoot) {
3111
+ packageRoots.add(installedPackageRoot);
3112
+ }
2943
3113
  for (const packageRoot of packageRoots) {
2944
3114
  for (const candidate of getWorkspacePackageImportCandidates(packageRoot, specifier, options)) {
2945
3115
  if (existsSync(candidate)) {
@@ -2950,22 +3120,7 @@ error: ${text}`);
2950
3120
  return void 0;
2951
3121
  }
2952
3122
 
2953
- // src/build.ts
2954
- function ensureDir(dirPath) {
2955
- try {
2956
- mkdirSync(dirPath, { recursive: true });
2957
- } catch (error) {
2958
- }
2959
- }
2960
- function calculateBuildMetrics(startTime, outputPath) {
2961
- const buildTime = Date.now() - startTime;
2962
- const stats = statSync(outputPath);
2963
- return { buildTime, size: stats.size };
2964
- }
2965
- function readFileAsString(filePath) {
2966
- const contentBuffer = readFileSync(filePath, "utf-8");
2967
- return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
2968
- }
3123
+ // src/build/plugins.ts
2969
3124
  function createWorkspacePackagePlugin(entryDir, options = {}) {
2970
3125
  return {
2971
3126
  name: "workspace-package-self-reference",
@@ -2977,6 +3132,31 @@ error: ${text}`);
2977
3132
  }
2978
3133
  };
2979
3134
  }
3135
+ function createBrowserOnlyPlugin() {
3136
+ return {
3137
+ name: "browser-only",
3138
+ setup(build2) {
3139
+ build2.onResolve({ filter: /^(node:.*|fs|path|http|https|url|os|child_process|net|tls|crypto|stream|util|events|buffer|zlib|readline|process|assert|constants|dns|domain|punycode|querystring|repl|string_decoder|sys|timers|tty|v8|vm)$/ }, () => {
3140
+ return { path: "node-builtin", external: true, sideEffects: false };
3141
+ });
3142
+ build2.onResolve({ filter: /^(chokidar|esbuild|mime-types|open|ws|fs\/promises)$/ }, () => {
3143
+ return { path: "server-dep", external: true, sideEffects: false };
3144
+ });
3145
+ build2.onLoad({ filter: /server|config|cli/ }, () => ({
3146
+ contents: "export default {};"
3147
+ }));
3148
+ }
3149
+ };
3150
+ }
3151
+ function createBuildPlugins(entryPath, platform) {
3152
+ const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath), {
3153
+ preferBuilt: platform === "browser",
3154
+ preferredBuiltFormat: platform === "browser" ? "esm" : void 0
3155
+ });
3156
+ return platform === "browser" ? [workspacePackagePlugin, createBrowserOnlyPlugin()] : [workspacePackagePlugin];
3157
+ }
3158
+
3159
+ // src/build/runtime-builders.ts
2980
3160
  function getMinifyOptions(minify) {
2981
3161
  return minify ? {
2982
3162
  minifyWhitespace: true,
@@ -2987,206 +3167,123 @@ error: ${text}`);
2987
3167
  keepNames: false
2988
3168
  } : {};
2989
3169
  }
2990
- function logBuildInfo(config, outputPath) {
2991
- console.log("\n\u{1F528} Building...");
2992
- console.log(` Entry: ${config.entry}`);
2993
- console.log(` Output: ${outputPath}`);
2994
- console.log(` Format: ${config.format}`);
2995
- console.log(` Target: ${config.target}`);
3170
+ async function buildWithNode(context) {
3171
+ const { build: esbuild } = await Promise.resolve().then(() => __toESM(require_main()));
3172
+ const { config, paths, platform, plugins, define, startTime } = context;
3173
+ const baseOptions = {
3174
+ entryPoints: [paths.entryPath],
3175
+ bundle: true,
3176
+ outfile: paths.outputPath,
3177
+ format: config.format,
3178
+ target: config.target,
3179
+ minify: config.minify,
3180
+ sourcemap: config.sourcemap,
3181
+ external: config.external,
3182
+ treeShaking: config.treeshake,
3183
+ globalName: config.globalName,
3184
+ platform,
3185
+ plugins,
3186
+ define,
3187
+ logLevel: config.logging ? "info" : "silent",
3188
+ metafile: true,
3189
+ mainFields: platform === "browser" ? ["browser", "module", "main"] : ["module", "main"]
3190
+ };
3191
+ const esbuildOptions = {
3192
+ ...baseOptions,
3193
+ ...getMinifyOptions(config.minify)
3194
+ };
3195
+ if (config.resolve?.alias) {
3196
+ esbuildOptions.resolve = { alias: config.resolve.alias };
3197
+ }
3198
+ const result = await esbuild(esbuildOptions);
3199
+ const { buildTime, size } = calculateBuildMetrics(startTime, paths.outputPath);
3200
+ return { result, buildTime, size };
2996
3201
  }
2997
- function logBuildSuccess(buildTime, size) {
2998
- console.log(`
2999
- \u2705 Build successful!`);
3000
- console.log(` Time: ${buildTime}ms`);
3001
- console.log(` Size: ${formatBytes(size)}`);
3202
+ async function buildWithBun(context) {
3203
+ const { config, paths, plugins, define, startTime } = context;
3204
+ const result = await Bun.build({
3205
+ entrypoints: [paths.entryPath],
3206
+ outdir: paths.outDir,
3207
+ target: "bun",
3208
+ format: config.format === "cjs" ? "cjs" : "esm",
3209
+ minify: config.minify,
3210
+ sourcemap: config.sourcemap ? "external" : "none",
3211
+ external: config.external,
3212
+ naming: paths.outFile,
3213
+ define,
3214
+ plugins
3215
+ });
3216
+ if (!result.success) {
3217
+ throw new Error("Bun build failed: " + JSON.stringify(result.logs));
3218
+ }
3219
+ const { buildTime, size } = calculateBuildMetrics(startTime, paths.outputPath);
3220
+ return { result, buildTime, size };
3221
+ }
3222
+ async function buildWithDeno(context) {
3223
+ const { config, paths, startTime } = context;
3224
+ const result = await Deno.emit(paths.entryPath, {
3225
+ bundle: "module",
3226
+ check: false,
3227
+ compilerOptions: {
3228
+ target: config.target,
3229
+ module: config.format === "cjs" ? "commonjs" : "esnext",
3230
+ sourceMap: config.sourcemap
3231
+ }
3232
+ });
3233
+ const bundledCode = result.files["deno:///bundle.js"];
3234
+ if (bundledCode) {
3235
+ await Deno.writeTextFile(paths.outputPath, bundledCode);
3236
+ }
3237
+ const { buildTime, size } = calculateBuildMetrics(startTime, paths.outputPath);
3238
+ return { result, buildTime, size };
3239
+ }
3240
+ async function runRuntimeBuild(context) {
3241
+ if (runtime === "node") {
3242
+ return buildWithNode(context);
3243
+ }
3244
+ if (runtime === "bun") {
3245
+ return buildWithBun(context);
3246
+ }
3247
+ return buildWithDeno(context);
3248
+ }
3249
+
3250
+ // src/build/build.ts
3251
+ function resolveBuildPlatform(config) {
3252
+ return config.platform || (config.format === "cjs" ? "node" : "browser");
3002
3253
  }
3003
- var defaultOptions = {
3004
- outDir: "dist",
3005
- minify: true,
3006
- sourcemap: false,
3007
- target: "es2020",
3008
- format: "esm",
3009
- treeshake: true,
3010
- logging: true,
3011
- external: []
3012
- };
3013
3254
  async function build(options) {
3014
3255
  const config = { ...defaultOptions, ...options };
3015
3256
  const startTime = Date.now();
3016
3257
  if (!config.entry) {
3017
3258
  throw new Error("Entry file is required");
3018
3259
  }
3019
- const entryPath = resolve(config.entry);
3020
- const outDir = resolve(config.outDir);
3021
- let outFile = config.outFile;
3022
- if (!outFile) {
3023
- const baseName = basename(config.entry, extname(config.entry));
3024
- const ext = config.format === "cjs" ? ".cjs" : ".js";
3025
- outFile = baseName + ext;
3026
- }
3027
- const outputPath = join(outDir, outFile);
3028
- ensureDir(outDir);
3260
+ const paths = resolveBuildPaths(config);
3261
+ ensureDir(paths.outDir);
3029
3262
  if (config.logging) {
3030
- logBuildInfo(config, outputPath);
3263
+ logBuildInfo(config, paths.outputPath);
3031
3264
  }
3032
- const browserOnlyPlugin = {
3033
- name: "browser-only",
3034
- setup(build2) {
3035
- build2.onResolve({ filter: /^(node:.*|fs|path|http|https|url|os|child_process|net|tls|crypto|stream|util|events|buffer|zlib|readline|process|assert|constants|dns|domain|punycode|querystring|repl|string_decoder|sys|timers|tty|v8|vm)$/ }, () => {
3036
- return { path: "node-builtin", external: true, sideEffects: false };
3037
- });
3038
- build2.onResolve({ filter: /^(chokidar|esbuild|mime-types|open|ws|fs\/promises)$/ }, () => {
3039
- return { path: "server-dep", external: true, sideEffects: false };
3040
- });
3041
- build2.onLoad({ filter: /server|config|cli/ }, () => ({
3042
- contents: "export default {};"
3043
- }));
3044
- }
3045
- };
3046
3265
  try {
3047
- const platform = config.platform || (config.format === "cjs" ? "node" : "browser");
3048
- const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath), {
3049
- preferBuilt: platform === "browser",
3050
- preferredBuiltFormat: platform === "browser" ? "esm" : void 0
3266
+ const platform = resolveBuildPlatform(config);
3267
+ const plugins = createBuildPlugins(paths.entryPath, platform);
3268
+ const define = createDefine(config);
3269
+ const { result, buildTime, size } = await runRuntimeBuild({
3270
+ config,
3271
+ paths,
3272
+ platform,
3273
+ plugins,
3274
+ define,
3275
+ startTime
3051
3276
  });
3052
- const plugins = platform === "browser" ? [workspacePackagePlugin, browserOnlyPlugin] : [workspacePackagePlugin];
3053
- const define = {};
3054
- if (config.env) {
3055
- Object.entries(config.env).forEach(([key, value]) => {
3056
- if (key.startsWith("VITE_")) {
3057
- define[`import.meta.env.${key}`] = JSON.stringify(value);
3058
- }
3059
- });
3060
- if (config.env.MODE) {
3061
- define["import.meta.env.MODE"] = JSON.stringify(config.env.MODE);
3062
- }
3063
- define["import.meta.env.DEV"] = JSON.stringify(config.env.MODE !== "production");
3064
- define["import.meta.env.PROD"] = JSON.stringify(config.env.MODE === "production");
3065
- }
3066
- let result;
3067
- let buildTime;
3068
- let size;
3069
- if (runtime === "node") {
3070
- const { build: esbuild } = await Promise.resolve().then(() => __toESM(require_main()));
3071
- const baseOptions = {
3072
- entryPoints: [entryPath],
3073
- bundle: true,
3074
- outfile: outputPath,
3075
- format: config.format,
3076
- target: config.target,
3077
- minify: config.minify,
3078
- sourcemap: config.sourcemap,
3079
- external: config.external,
3080
- treeShaking: config.treeshake,
3081
- globalName: config.globalName,
3082
- platform,
3083
- plugins,
3084
- define,
3085
- logLevel: config.logging ? "info" : "silent",
3086
- metafile: true,
3087
- // Prioritize browser field for browser builds
3088
- mainFields: platform === "browser" ? ["browser", "module", "main"] : ["module", "main"]
3089
- };
3090
- const esbuildOptions = {
3091
- ...baseOptions,
3092
- ...getMinifyOptions(config.minify)
3093
- };
3094
- if (config.resolve?.alias) {
3095
- esbuildOptions.resolve = { alias: config.resolve.alias };
3096
- }
3097
- result = await esbuild(esbuildOptions);
3098
- ({ buildTime, size } = calculateBuildMetrics(startTime, outputPath));
3099
- } else if (runtime === "bun") {
3100
- result = await Bun.build({
3101
- entrypoints: [entryPath],
3102
- outdir: outDir,
3103
- target: "bun",
3104
- format: config.format === "cjs" ? "cjs" : "esm",
3105
- minify: config.minify,
3106
- sourcemap: config.sourcemap ? "external" : "none",
3107
- external: config.external,
3108
- naming: outFile,
3109
- define,
3110
- plugins
3111
- });
3112
- if (!result.success) {
3113
- throw new Error("Bun build failed: " + JSON.stringify(result.logs));
3114
- }
3115
- ({ buildTime, size } = calculateBuildMetrics(startTime, outputPath));
3116
- } else {
3117
- result = await Deno.emit(entryPath, {
3118
- bundle: "module",
3119
- check: false,
3120
- compilerOptions: {
3121
- target: config.target,
3122
- module: config.format === "cjs" ? "commonjs" : "esnext",
3123
- sourceMap: config.sourcemap
3124
- }
3125
- });
3126
- const bundledCode = result.files["deno:///bundle.js"];
3127
- if (bundledCode) {
3128
- await Deno.writeTextFile(outputPath, bundledCode);
3129
- }
3130
- ({ buildTime, size } = calculateBuildMetrics(startTime, outputPath));
3131
- }
3132
3277
  if (config.logging) {
3133
3278
  logBuildSuccess(buildTime, size);
3134
- if (runtime === "node" && result.metafile) {
3135
- const inputs = Object.keys(result.metafile.inputs).length;
3136
- console.log(` Files: ${inputs} input(s)`);
3137
- const outputKeys = Object.keys(result.metafile.outputs);
3138
- if (outputKeys.length > 0) {
3139
- const mainOutput = result.metafile.outputs[outputKeys[0]];
3140
- if (mainOutput && mainOutput.inputs) {
3141
- const sortedInputs = Object.entries(mainOutput.inputs).sort(([, a], [, b]) => {
3142
- const aBytes = a.bytesInOutput || 0;
3143
- const bBytes = b.bytesInOutput || 0;
3144
- return bBytes - aBytes;
3145
- }).slice(0, 5);
3146
- if (sortedInputs.length > 0) {
3147
- console.log("\n \u{1F4CA} Top 5 largest modules:");
3148
- sortedInputs.forEach(([file, info]) => {
3149
- const fileName = file.split(/[/\\]/).pop() || file;
3150
- const infoBytes = info.bytesInOutput || 0;
3151
- console.log(` ${fileName.padEnd(30)} ${formatBytes(infoBytes)}`);
3152
- });
3153
- }
3154
- }
3155
- }
3156
- }
3279
+ logMetafileSummary(result);
3157
3280
  }
3158
3281
  const buildResult = {
3159
- outputPath,
3282
+ outputPath: paths.outputPath,
3160
3283
  buildTime,
3161
3284
  size
3162
3285
  };
3163
- if (config.copy && config.copy.length > 0) {
3164
- if (config.logging) {
3165
- console.log("\n\u{1F4E6} Copying files...");
3166
- }
3167
- for (const copyItem of config.copy) {
3168
- const fromPath = resolve(copyItem.from);
3169
- const toPath = resolve(outDir, copyItem.to);
3170
- const targetDir = dirname(toPath);
3171
- if (!existsSync(targetDir)) {
3172
- ensureDir(targetDir);
3173
- }
3174
- if (existsSync(fromPath)) {
3175
- if (copyItem.transform) {
3176
- const content = readFileAsString(fromPath);
3177
- const transformed = copyItem.transform(content, config);
3178
- writeFileSync(toPath, transformed);
3179
- } else {
3180
- copyFileSync(fromPath, toPath);
3181
- }
3182
- if (config.logging) {
3183
- console.log(` \u2713 ${copyItem.from} \u2192 ${copyItem.to}`);
3184
- }
3185
- } else if (config.logging) {
3186
- console.warn(` \u26A0 File not found: ${copyItem.from}`);
3187
- }
3188
- }
3189
- }
3286
+ copyBuildFiles(config, paths.outDir);
3190
3287
  if (config.onBuildEnd) {
3191
3288
  await config.onBuildEnd(buildResult);
3192
3289
  }
@@ -3202,11 +3299,4 @@ error: ${text}`);
3202
3299
  throw error;
3203
3300
  }
3204
3301
  }
3205
- function formatBytes(bytes) {
3206
- if (bytes === 0) return "0 B";
3207
- const k = 1024;
3208
- const sizes = ["B", "KB", "MB", "GB"];
3209
- const i = Math.floor(Math.log(bytes) / Math.log(k));
3210
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
3211
- }
3212
3302
  })();