@evitcastudio/kit 3.2.2 → 3.3.1

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.
@@ -2,8 +2,8 @@
2
2
  // @bun
3
3
 
4
4
  /*!
5
- * @evitcastudio/kit@3.2.2 git+https://github.com/EvitcaStudio/Kit.git
6
- * Compiled Wed, 09 Sep 2026 14:01:08 UTC
5
+ * @evitcastudio/kit@3.3.1 git+https://github.com/EvitcaStudio/Kit.git
6
+ * Compiled Wed, 09 Sep 2026 16:18:17 UTC
7
7
  * Copyright (c) 2026 Jared Bates, Evitca Studio, "doubleactii"
8
8
  *
9
9
  * @evitcastudio/kit is licensed under the MIT License.
@@ -1942,8 +1942,8 @@ var {
1942
1942
  } = import__.default;
1943
1943
 
1944
1944
  // src/cli/resource-builder.ts
1945
- import { promises as fs2, watch as fsWatch, existsSync as existsSync2 } from "fs";
1946
- import { join as join2, extname as extname2, basename, resolve } from "path";
1945
+ import { promises as fs2, existsSync as existsSync2 } from "fs";
1946
+ import { join as join4, extname as extname3, basename as basename3, resolve as resolve3, relative as relative3 } from "path";
1947
1947
 
1948
1948
  // node_modules/chalk/source/vendor/ansi-styles/index.js
1949
1949
  var ANSI_BACKGROUND_OFFSET = 10;
@@ -2213,6 +2213,12 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
2213
2213
  if (env.TERM === "xterm-kitty") {
2214
2214
  return 3;
2215
2215
  }
2216
+ if (env.TERM === "xterm-ghostty") {
2217
+ return 3;
2218
+ }
2219
+ if (env.TERM === "wezterm") {
2220
+ return 3;
2221
+ }
2216
2222
  if ("TERM_PROGRAM" in env) {
2217
2223
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
2218
2224
  switch (env.TERM_PROGRAM) {
@@ -2429,6 +2435,1639 @@ var chalk = createChalk();
2429
2435
  var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
2430
2436
  var source_default = chalk;
2431
2437
 
2438
+ // node_modules/chokidar/index.js
2439
+ import { EventEmitter } from "events";
2440
+ import { stat as statcb, Stats } from "fs";
2441
+ import { readdir as readdir2, stat as stat3 } from "fs/promises";
2442
+ import * as sp2 from "path";
2443
+
2444
+ // node_modules/chokidar/node_modules/readdirp/index.js
2445
+ import { lstat, readdir, realpath, stat } from "fs/promises";
2446
+ import { join as pjoin, resolve as presolve, sep as psep } from "path";
2447
+ import { Readable } from "stream";
2448
+ var EntryTypes = {
2449
+ FILE_TYPE: "files",
2450
+ DIR_TYPE: "directories",
2451
+ FILE_DIR_TYPE: "files_directories",
2452
+ EVERYTHING_TYPE: "all"
2453
+ };
2454
+ var defaultOptions = {
2455
+ root: ".",
2456
+ fileFilter: (_entryInfo) => true,
2457
+ directoryFilter: (_entryInfo) => true,
2458
+ type: EntryTypes.FILE_TYPE,
2459
+ lstat: false,
2460
+ depth: 2147483648,
2461
+ alwaysStat: false,
2462
+ highWaterMark: 256
2463
+ };
2464
+ Object.freeze(defaultOptions);
2465
+ var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
2466
+ var NORMAL_FLOW_ERRORS = new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
2467
+ var ALL_TYPES = [
2468
+ EntryTypes.DIR_TYPE,
2469
+ EntryTypes.EVERYTHING_TYPE,
2470
+ EntryTypes.FILE_DIR_TYPE,
2471
+ EntryTypes.FILE_TYPE
2472
+ ];
2473
+ var DIR_TYPES = new Set([
2474
+ EntryTypes.DIR_TYPE,
2475
+ EntryTypes.EVERYTHING_TYPE,
2476
+ EntryTypes.FILE_DIR_TYPE
2477
+ ]);
2478
+ var FILE_TYPES = new Set([
2479
+ EntryTypes.EVERYTHING_TYPE,
2480
+ EntryTypes.FILE_DIR_TYPE,
2481
+ EntryTypes.FILE_TYPE
2482
+ ]);
2483
+ var isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
2484
+ var wantBigintFsStats = process.platform === "win32";
2485
+ var emptyFn = (_entryInfo) => true;
2486
+ var normalizeFilter = (filter) => {
2487
+ if (filter === undefined)
2488
+ return emptyFn;
2489
+ if (typeof filter === "function")
2490
+ return filter;
2491
+ if (typeof filter === "string") {
2492
+ const fl = filter.trim();
2493
+ return (entry) => entry.basename === fl;
2494
+ }
2495
+ if (Array.isArray(filter)) {
2496
+ const trItems = filter.map((item) => item.trim());
2497
+ return (entry) => trItems.some((f) => entry.basename === f);
2498
+ }
2499
+ return emptyFn;
2500
+ };
2501
+
2502
+ class ReaddirpStream extends Readable {
2503
+ parents;
2504
+ reading;
2505
+ parent;
2506
+ _stat;
2507
+ _maxDepth;
2508
+ _wantsDir;
2509
+ _wantsFile;
2510
+ _wantsEverything;
2511
+ _root;
2512
+ _isDirent;
2513
+ _statsProp;
2514
+ _rdOptions;
2515
+ _fileFilter;
2516
+ _directoryFilter;
2517
+ _relStart;
2518
+ constructor(options = {}) {
2519
+ super({
2520
+ objectMode: true,
2521
+ autoDestroy: true,
2522
+ highWaterMark: options.highWaterMark ?? defaultOptions.highWaterMark
2523
+ });
2524
+ const opts = { ...defaultOptions, ...options };
2525
+ const root = opts.root ?? defaultOptions.root;
2526
+ const type = opts.type ?? defaultOptions.type;
2527
+ this._fileFilter = normalizeFilter(opts.fileFilter);
2528
+ this._directoryFilter = normalizeFilter(opts.directoryFilter);
2529
+ const statMethod = opts.lstat ? lstat : stat;
2530
+ if (wantBigintFsStats) {
2531
+ this._stat = (path) => statMethod(path, { bigint: true });
2532
+ } else {
2533
+ this._stat = statMethod;
2534
+ }
2535
+ this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
2536
+ this._wantsDir = DIR_TYPES.has(type);
2537
+ this._wantsFile = FILE_TYPES.has(type);
2538
+ this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
2539
+ this._root = presolve(root);
2540
+ this._relStart = this._root.endsWith(psep) ? this._root.length : this._root.length + 1;
2541
+ this._isDirent = !opts.alwaysStat;
2542
+ this._statsProp = this._isDirent ? "dirent" : "stats";
2543
+ this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
2544
+ const rootDir = { path: this._root, depth: 1 };
2545
+ rootDir.pending = this._exploreDir(this._root, 1);
2546
+ this.parents = [rootDir];
2547
+ this.reading = false;
2548
+ this.parent = undefined;
2549
+ }
2550
+ async _read(batch) {
2551
+ if (this.reading)
2552
+ return;
2553
+ this.reading = true;
2554
+ try {
2555
+ while (!this.destroyed && batch > 0) {
2556
+ const par = this.parent;
2557
+ const fil = par && par.files;
2558
+ if (fil && fil.length > 0) {
2559
+ const { path, depth } = par;
2560
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
2561
+ const awaited = this._isDirent ? slice : await Promise.all(slice);
2562
+ for (const entry of awaited) {
2563
+ if (!entry)
2564
+ continue;
2565
+ if (this.destroyed)
2566
+ return;
2567
+ let entryType = this._getEntryType(entry);
2568
+ if (typeof entryType !== "string")
2569
+ entryType = await entryType;
2570
+ if (entryType === "directory" && this._directoryFilter(entry)) {
2571
+ if (depth <= this._maxDepth) {
2572
+ this.parents.push({ path: entry.fullPath, depth: depth + 1 });
2573
+ }
2574
+ if (this._wantsDir) {
2575
+ this.push(entry);
2576
+ batch--;
2577
+ }
2578
+ } else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
2579
+ if (this._wantsFile) {
2580
+ this.push(entry);
2581
+ batch--;
2582
+ }
2583
+ }
2584
+ }
2585
+ } else {
2586
+ const parent = this.parents.pop();
2587
+ if (!parent) {
2588
+ this.push(null);
2589
+ break;
2590
+ }
2591
+ const dir = parent.pending ?? this._exploreDir(parent.path, parent.depth);
2592
+ const next = this.parents[this.parents.length - 1];
2593
+ if (next && !next.pending) {
2594
+ next.pending = this._exploreDir(next.path, next.depth);
2595
+ }
2596
+ this.parent = await dir;
2597
+ if (this.destroyed)
2598
+ return;
2599
+ }
2600
+ }
2601
+ } catch (error) {
2602
+ this.destroy(error);
2603
+ } finally {
2604
+ this.reading = false;
2605
+ }
2606
+ }
2607
+ async _exploreDir(path, depth) {
2608
+ let files;
2609
+ try {
2610
+ files = await readdir(path, this._rdOptions);
2611
+ } catch (error) {
2612
+ this._onError(error);
2613
+ }
2614
+ return { files, depth, path };
2615
+ }
2616
+ _formatEntry(dirent, path) {
2617
+ const basename = this._isDirent ? dirent.name : dirent;
2618
+ const fullPath = pjoin(path, basename);
2619
+ const entry = { path: fullPath.slice(this._relStart), fullPath, basename };
2620
+ if (this._isDirent) {
2621
+ entry.dirent = dirent;
2622
+ return entry;
2623
+ }
2624
+ return this._stat(fullPath).then((stats) => {
2625
+ entry.stats = stats;
2626
+ return entry;
2627
+ }, (err) => {
2628
+ this._onError(err);
2629
+ return;
2630
+ });
2631
+ }
2632
+ _onError(err) {
2633
+ if (isNormalFlowError(err) && !this.destroyed) {
2634
+ this.emit("warn", err);
2635
+ } else {
2636
+ this.destroy(err);
2637
+ }
2638
+ }
2639
+ _getEntryType(entry) {
2640
+ if (!entry || !(this._statsProp in entry)) {
2641
+ return "";
2642
+ }
2643
+ const stats = entry[this._statsProp];
2644
+ if (stats.isFile())
2645
+ return "file";
2646
+ if (stats.isDirectory())
2647
+ return "directory";
2648
+ if (stats.isSymbolicLink())
2649
+ return this._getSymlinkEntryType(entry);
2650
+ return "";
2651
+ }
2652
+ async _getSymlinkEntryType(entry) {
2653
+ const full = entry.fullPath;
2654
+ try {
2655
+ const entryRealPath = await realpath(full);
2656
+ const entryRealPathStats = await lstat(entryRealPath);
2657
+ if (entryRealPathStats.isFile()) {
2658
+ return "file";
2659
+ }
2660
+ if (entryRealPathStats.isDirectory()) {
2661
+ const len = entryRealPath.length;
2662
+ if (full.startsWith(entryRealPath) && full[len] === psep) {
2663
+ const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
2664
+ recursiveError.code = RECURSIVE_ERROR_CODE;
2665
+ this._onError(recursiveError);
2666
+ return "";
2667
+ }
2668
+ return "directory";
2669
+ }
2670
+ } catch (error) {
2671
+ this._onError(error);
2672
+ }
2673
+ return "";
2674
+ }
2675
+ _includeAsFile(entry) {
2676
+ const stats = entry && entry[this._statsProp];
2677
+ return stats && this._wantsEverything && !stats.isDirectory();
2678
+ }
2679
+ }
2680
+ function readdirp(root, options = {}) {
2681
+ let type = options.entryType || options.type;
2682
+ if (type === "both")
2683
+ type = EntryTypes.FILE_DIR_TYPE;
2684
+ if (!root) {
2685
+ throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
2686
+ } else if (typeof root !== "string") {
2687
+ throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
2688
+ } else if (type && !ALL_TYPES.includes(type)) {
2689
+ throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
2690
+ }
2691
+ const opts = { ...options, root };
2692
+ if (type)
2693
+ opts.type = type;
2694
+ return new ReaddirpStream(opts);
2695
+ }
2696
+
2697
+ // node_modules/chokidar/handler.js
2698
+ import { watch as fs_watch, unwatchFile, watchFile } from "fs";
2699
+ import { realpath as fsrealpath, lstat as lstat2, open, stat as stat2 } from "fs/promises";
2700
+ import { type as osType } from "os";
2701
+ import * as sp from "path";
2702
+ var STR_DATA = "data";
2703
+ var STR_END = "end";
2704
+ var STR_CLOSE = "close";
2705
+ var EMPTY_FN = () => {
2706
+ };
2707
+ var pl = process.platform;
2708
+ var isWindows = pl === "win32";
2709
+ var isMacos = pl === "darwin";
2710
+ var isLinux = pl === "linux";
2711
+ var isFreeBSD = pl === "freebsd";
2712
+ var isIBMi = osType() === "OS400";
2713
+ var EVENTS = {
2714
+ ALL: "all",
2715
+ READY: "ready",
2716
+ ADD: "add",
2717
+ CHANGE: "change",
2718
+ ADD_DIR: "addDir",
2719
+ UNLINK: "unlink",
2720
+ UNLINK_DIR: "unlinkDir",
2721
+ RAW: "raw",
2722
+ ERROR: "error"
2723
+ };
2724
+ var EV = EVENTS;
2725
+ var THROTTLE_MODE_WATCH = "watch";
2726
+ var statMethods = { lstat: lstat2, stat: stat2 };
2727
+ var KEY_LISTENERS = "listeners";
2728
+ var KEY_ERR = "errHandlers";
2729
+ var KEY_RAW = "rawEmitters";
2730
+ var HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
2731
+ var binaryExtensions = new Set([
2732
+ "3dm",
2733
+ "3ds",
2734
+ "3g2",
2735
+ "3gp",
2736
+ "7z",
2737
+ "a",
2738
+ "aac",
2739
+ "adp",
2740
+ "afdesign",
2741
+ "afphoto",
2742
+ "afpub",
2743
+ "ai",
2744
+ "aif",
2745
+ "aiff",
2746
+ "alz",
2747
+ "ape",
2748
+ "apk",
2749
+ "appimage",
2750
+ "ar",
2751
+ "arj",
2752
+ "asf",
2753
+ "au",
2754
+ "avi",
2755
+ "bak",
2756
+ "baml",
2757
+ "bh",
2758
+ "bin",
2759
+ "bk",
2760
+ "bmp",
2761
+ "btif",
2762
+ "bz2",
2763
+ "bzip2",
2764
+ "cab",
2765
+ "caf",
2766
+ "cgm",
2767
+ "class",
2768
+ "cmx",
2769
+ "cpio",
2770
+ "cr2",
2771
+ "cur",
2772
+ "dat",
2773
+ "dcm",
2774
+ "deb",
2775
+ "dex",
2776
+ "djvu",
2777
+ "dll",
2778
+ "dmg",
2779
+ "dng",
2780
+ "doc",
2781
+ "docm",
2782
+ "docx",
2783
+ "dot",
2784
+ "dotm",
2785
+ "dra",
2786
+ "DS_Store",
2787
+ "dsk",
2788
+ "dts",
2789
+ "dtshd",
2790
+ "dvb",
2791
+ "dwg",
2792
+ "dxf",
2793
+ "ecelp4800",
2794
+ "ecelp7470",
2795
+ "ecelp9600",
2796
+ "egg",
2797
+ "eol",
2798
+ "eot",
2799
+ "epub",
2800
+ "exe",
2801
+ "f4v",
2802
+ "fbs",
2803
+ "fh",
2804
+ "fla",
2805
+ "flac",
2806
+ "flatpak",
2807
+ "fli",
2808
+ "flv",
2809
+ "fpx",
2810
+ "fst",
2811
+ "fvt",
2812
+ "g3",
2813
+ "gh",
2814
+ "gif",
2815
+ "graffle",
2816
+ "gz",
2817
+ "gzip",
2818
+ "h261",
2819
+ "h263",
2820
+ "h264",
2821
+ "icns",
2822
+ "ico",
2823
+ "ief",
2824
+ "img",
2825
+ "ipa",
2826
+ "iso",
2827
+ "jar",
2828
+ "jpeg",
2829
+ "jpg",
2830
+ "jpgv",
2831
+ "jpm",
2832
+ "jxr",
2833
+ "key",
2834
+ "ktx",
2835
+ "lha",
2836
+ "lib",
2837
+ "lvp",
2838
+ "lz",
2839
+ "lzh",
2840
+ "lzma",
2841
+ "lzo",
2842
+ "m3u",
2843
+ "m4a",
2844
+ "m4v",
2845
+ "mar",
2846
+ "mdi",
2847
+ "mht",
2848
+ "mid",
2849
+ "midi",
2850
+ "mj2",
2851
+ "mka",
2852
+ "mkv",
2853
+ "mmr",
2854
+ "mng",
2855
+ "mobi",
2856
+ "mov",
2857
+ "movie",
2858
+ "mp3",
2859
+ "mp4",
2860
+ "mp4a",
2861
+ "mpeg",
2862
+ "mpg",
2863
+ "mpga",
2864
+ "mxu",
2865
+ "nef",
2866
+ "npx",
2867
+ "numbers",
2868
+ "nupkg",
2869
+ "o",
2870
+ "odp",
2871
+ "ods",
2872
+ "odt",
2873
+ "oga",
2874
+ "ogg",
2875
+ "ogv",
2876
+ "otf",
2877
+ "ott",
2878
+ "pages",
2879
+ "pbm",
2880
+ "pcx",
2881
+ "pdb",
2882
+ "pdf",
2883
+ "pea",
2884
+ "pgm",
2885
+ "pic",
2886
+ "png",
2887
+ "pnm",
2888
+ "pot",
2889
+ "potm",
2890
+ "potx",
2891
+ "ppa",
2892
+ "ppam",
2893
+ "ppm",
2894
+ "pps",
2895
+ "ppsm",
2896
+ "ppsx",
2897
+ "ppt",
2898
+ "pptm",
2899
+ "pptx",
2900
+ "psd",
2901
+ "pya",
2902
+ "pyc",
2903
+ "pyo",
2904
+ "pyv",
2905
+ "qt",
2906
+ "rar",
2907
+ "ras",
2908
+ "raw",
2909
+ "resources",
2910
+ "rgb",
2911
+ "rip",
2912
+ "rlc",
2913
+ "rmf",
2914
+ "rmvb",
2915
+ "rpm",
2916
+ "rtf",
2917
+ "rz",
2918
+ "s3m",
2919
+ "s7z",
2920
+ "scpt",
2921
+ "sgi",
2922
+ "shar",
2923
+ "snap",
2924
+ "sil",
2925
+ "sketch",
2926
+ "slk",
2927
+ "smv",
2928
+ "snk",
2929
+ "so",
2930
+ "stl",
2931
+ "suo",
2932
+ "sub",
2933
+ "swf",
2934
+ "tar",
2935
+ "tbz",
2936
+ "tbz2",
2937
+ "tga",
2938
+ "tgz",
2939
+ "thmx",
2940
+ "tif",
2941
+ "tiff",
2942
+ "tlz",
2943
+ "ttc",
2944
+ "ttf",
2945
+ "txz",
2946
+ "udf",
2947
+ "uvh",
2948
+ "uvi",
2949
+ "uvm",
2950
+ "uvp",
2951
+ "uvs",
2952
+ "uvu",
2953
+ "viv",
2954
+ "vob",
2955
+ "war",
2956
+ "wav",
2957
+ "wax",
2958
+ "wbmp",
2959
+ "wdp",
2960
+ "weba",
2961
+ "webm",
2962
+ "webp",
2963
+ "whl",
2964
+ "wim",
2965
+ "wm",
2966
+ "wma",
2967
+ "wmv",
2968
+ "wmx",
2969
+ "woff",
2970
+ "woff2",
2971
+ "wrm",
2972
+ "wvx",
2973
+ "xbm",
2974
+ "xif",
2975
+ "xla",
2976
+ "xlam",
2977
+ "xls",
2978
+ "xlsb",
2979
+ "xlsm",
2980
+ "xlsx",
2981
+ "xlt",
2982
+ "xltm",
2983
+ "xltx",
2984
+ "xm",
2985
+ "xmind",
2986
+ "xpi",
2987
+ "xpm",
2988
+ "xwd",
2989
+ "xz",
2990
+ "z",
2991
+ "zip",
2992
+ "zipx"
2993
+ ]);
2994
+ var isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
2995
+ var foreach = (val, fn) => {
2996
+ if (val instanceof Set) {
2997
+ val.forEach(fn);
2998
+ } else {
2999
+ fn(val);
3000
+ }
3001
+ };
3002
+ var addAndConvert = (main, prop, item) => {
3003
+ let container = main[prop];
3004
+ if (!(container instanceof Set)) {
3005
+ main[prop] = container = new Set([container]);
3006
+ }
3007
+ container.add(item);
3008
+ };
3009
+ var clearItem = (cont) => (key) => {
3010
+ const set = cont[key];
3011
+ if (set instanceof Set) {
3012
+ set.clear();
3013
+ } else {
3014
+ delete cont[key];
3015
+ }
3016
+ };
3017
+ var delFromSet = (main, prop, item) => {
3018
+ const container = main[prop];
3019
+ if (container instanceof Set) {
3020
+ container.delete(item);
3021
+ } else if (container === item) {
3022
+ delete main[prop];
3023
+ }
3024
+ };
3025
+ var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
3026
+ var FsWatchInstances = new Map;
3027
+ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
3028
+ const handleEvent = (rawEvent, evPath) => {
3029
+ listener(path);
3030
+ emitRaw(rawEvent, evPath, { watchedPath: path });
3031
+ if (evPath && path !== evPath) {
3032
+ fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
3033
+ }
3034
+ };
3035
+ try {
3036
+ return fs_watch(path, {
3037
+ persistent: options.persistent
3038
+ }, handleEvent);
3039
+ } catch (error) {
3040
+ errHandler(error);
3041
+ return;
3042
+ }
3043
+ }
3044
+ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
3045
+ const cont = FsWatchInstances.get(fullPath);
3046
+ if (!cont)
3047
+ return;
3048
+ foreach(cont[listenerType], (listener) => {
3049
+ listener(val1, val2, val3);
3050
+ });
3051
+ };
3052
+ var setFsWatchListener = (path, fullPath, options, handlers) => {
3053
+ const { listener, errHandler, rawEmitter } = handlers;
3054
+ let cont = FsWatchInstances.get(fullPath);
3055
+ let watcher;
3056
+ if (!options.persistent) {
3057
+ watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
3058
+ if (!watcher)
3059
+ return;
3060
+ return watcher.close.bind(watcher);
3061
+ }
3062
+ if (cont) {
3063
+ addAndConvert(cont, KEY_LISTENERS, listener);
3064
+ addAndConvert(cont, KEY_ERR, errHandler);
3065
+ addAndConvert(cont, KEY_RAW, rawEmitter);
3066
+ } else {
3067
+ watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
3068
+ if (!watcher)
3069
+ return;
3070
+ watcher.on(EV.ERROR, async (error) => {
3071
+ const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
3072
+ if (cont)
3073
+ cont.watcherUnusable = true;
3074
+ if (isWindows && error.code === "EPERM") {
3075
+ try {
3076
+ const fd = await open(path, "r");
3077
+ await fd.close();
3078
+ broadcastErr(error);
3079
+ } catch (err) {
3080
+ }
3081
+ } else {
3082
+ broadcastErr(error);
3083
+ }
3084
+ });
3085
+ cont = {
3086
+ listeners: listener,
3087
+ errHandlers: errHandler,
3088
+ rawEmitters: rawEmitter,
3089
+ watcher
3090
+ };
3091
+ FsWatchInstances.set(fullPath, cont);
3092
+ }
3093
+ return () => {
3094
+ delFromSet(cont, KEY_LISTENERS, listener);
3095
+ delFromSet(cont, KEY_ERR, errHandler);
3096
+ delFromSet(cont, KEY_RAW, rawEmitter);
3097
+ if (isEmptySet(cont.listeners)) {
3098
+ cont.watcher.close();
3099
+ FsWatchInstances.delete(fullPath);
3100
+ HANDLER_KEYS.forEach(clearItem(cont));
3101
+ cont.watcher = undefined;
3102
+ Object.freeze(cont);
3103
+ }
3104
+ };
3105
+ };
3106
+ var FsWatchFileInstances = new Map;
3107
+ var setFsWatchFileListener = (path, fullPath, options, handlers) => {
3108
+ const { listener, rawEmitter } = handlers;
3109
+ let cont = FsWatchFileInstances.get(fullPath);
3110
+ const copts = cont && cont.options;
3111
+ if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
3112
+ unwatchFile(fullPath);
3113
+ cont = undefined;
3114
+ }
3115
+ if (cont) {
3116
+ addAndConvert(cont, KEY_LISTENERS, listener);
3117
+ addAndConvert(cont, KEY_RAW, rawEmitter);
3118
+ } else {
3119
+ cont = {
3120
+ listeners: listener,
3121
+ rawEmitters: rawEmitter,
3122
+ options,
3123
+ watcher: watchFile(fullPath, options, (curr, prev) => {
3124
+ foreach(cont.rawEmitters, (rawEmitter2) => {
3125
+ rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
3126
+ });
3127
+ const currmtime = curr.mtimeMs;
3128
+ if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
3129
+ foreach(cont.listeners, (listener2) => listener2(path, curr));
3130
+ }
3131
+ })
3132
+ };
3133
+ FsWatchFileInstances.set(fullPath, cont);
3134
+ }
3135
+ return () => {
3136
+ delFromSet(cont, KEY_LISTENERS, listener);
3137
+ delFromSet(cont, KEY_RAW, rawEmitter);
3138
+ if (isEmptySet(cont.listeners)) {
3139
+ FsWatchFileInstances.delete(fullPath);
3140
+ unwatchFile(fullPath);
3141
+ cont.options = cont.watcher = undefined;
3142
+ Object.freeze(cont);
3143
+ }
3144
+ };
3145
+ };
3146
+
3147
+ class NodeFsHandler {
3148
+ fsw;
3149
+ _boundHandleError;
3150
+ constructor(fsW) {
3151
+ this.fsw = fsW;
3152
+ this._boundHandleError = (error) => fsW._handleError(error);
3153
+ }
3154
+ _watchWithNodeFs(path, listener) {
3155
+ const opts = this.fsw.options;
3156
+ const directory = sp.dirname(path);
3157
+ const basename2 = sp.basename(path);
3158
+ const parent = this.fsw._getWatchedDir(directory);
3159
+ parent.add(basename2);
3160
+ const absolutePath = sp.resolve(path);
3161
+ const options = {
3162
+ persistent: opts.persistent
3163
+ };
3164
+ if (!listener)
3165
+ listener = EMPTY_FN;
3166
+ let closer;
3167
+ if (opts.usePolling) {
3168
+ const enableBin = opts.interval !== opts.binaryInterval;
3169
+ options.interval = enableBin && isBinaryPath(basename2) ? opts.binaryInterval : opts.interval;
3170
+ closer = setFsWatchFileListener(path, absolutePath, options, {
3171
+ listener,
3172
+ rawEmitter: this.fsw._emitRaw
3173
+ });
3174
+ } else {
3175
+ closer = setFsWatchListener(path, absolutePath, options, {
3176
+ listener,
3177
+ errHandler: this._boundHandleError,
3178
+ rawEmitter: this.fsw._emitRaw
3179
+ });
3180
+ }
3181
+ return closer;
3182
+ }
3183
+ _handleFile(file, stats, initialAdd) {
3184
+ if (this.fsw.closed) {
3185
+ return;
3186
+ }
3187
+ const dirname2 = sp.dirname(file);
3188
+ const basename2 = sp.basename(file);
3189
+ const parent = this.fsw._getWatchedDir(dirname2);
3190
+ let prevStats = stats;
3191
+ if (parent.has(basename2))
3192
+ return;
3193
+ const listener = async (path, newStats) => {
3194
+ if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
3195
+ return;
3196
+ if (!newStats || newStats.mtimeMs === 0) {
3197
+ try {
3198
+ const newStats2 = await stat2(file);
3199
+ if (this.fsw.closed)
3200
+ return;
3201
+ const at = newStats2.atimeMs;
3202
+ const mt = newStats2.mtimeMs;
3203
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) {
3204
+ this.fsw._emit(EV.CHANGE, file, newStats2);
3205
+ }
3206
+ if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
3207
+ this.fsw._closeFile(path);
3208
+ prevStats = newStats2;
3209
+ const closer2 = this._watchWithNodeFs(file, listener);
3210
+ if (closer2)
3211
+ this.fsw._addPathCloser(path, closer2);
3212
+ } else {
3213
+ prevStats = newStats2;
3214
+ }
3215
+ } catch (error) {
3216
+ this.fsw._remove(dirname2, basename2);
3217
+ }
3218
+ } else if (parent.has(basename2)) {
3219
+ const at = newStats.atimeMs;
3220
+ const mt = newStats.mtimeMs;
3221
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) {
3222
+ this.fsw._emit(EV.CHANGE, file, newStats);
3223
+ }
3224
+ prevStats = newStats;
3225
+ }
3226
+ };
3227
+ const closer = this._watchWithNodeFs(file, listener);
3228
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
3229
+ if (!this.fsw._throttle(EV.ADD, file, 0))
3230
+ return;
3231
+ this.fsw._emit(EV.ADD, file, stats);
3232
+ }
3233
+ return closer;
3234
+ }
3235
+ async _handleSymlink(entry, directory, path, item) {
3236
+ if (this.fsw.closed) {
3237
+ return;
3238
+ }
3239
+ const full = entry.fullPath;
3240
+ const dir = this.fsw._getWatchedDir(directory);
3241
+ if (!this.fsw.options.followSymlinks) {
3242
+ this.fsw._incrReadyCount();
3243
+ let linkPath;
3244
+ try {
3245
+ linkPath = await fsrealpath(path);
3246
+ } catch (e) {
3247
+ this.fsw._emitReady();
3248
+ return true;
3249
+ }
3250
+ if (this.fsw.closed)
3251
+ return;
3252
+ if (dir.has(item)) {
3253
+ if (this.fsw._symlinkPaths.get(full) !== linkPath) {
3254
+ this.fsw._symlinkPaths.set(full, linkPath);
3255
+ this.fsw._emit(EV.CHANGE, path, entry.stats);
3256
+ }
3257
+ } else {
3258
+ dir.add(item);
3259
+ this.fsw._symlinkPaths.set(full, linkPath);
3260
+ this.fsw._emit(EV.ADD, path, entry.stats);
3261
+ }
3262
+ this.fsw._emitReady();
3263
+ return true;
3264
+ }
3265
+ if (this.fsw._symlinkPaths.has(full)) {
3266
+ return true;
3267
+ }
3268
+ this.fsw._symlinkPaths.set(full, true);
3269
+ }
3270
+ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
3271
+ directory = sp.join(directory, "");
3272
+ const throttleKey = target ? `${directory}:${target}` : directory;
3273
+ throttler = this.fsw._throttle("readdir", throttleKey, 1000);
3274
+ if (!throttler)
3275
+ return;
3276
+ const previous = this.fsw._getWatchedDir(wh.path);
3277
+ const current = new Set;
3278
+ let stream = this.fsw._readdirp(directory, {
3279
+ fileFilter: (entry) => wh.filterPath(entry),
3280
+ directoryFilter: (entry) => wh.filterDir(entry)
3281
+ });
3282
+ if (!stream)
3283
+ return;
3284
+ stream.on(STR_DATA, async (entry) => {
3285
+ if (this.fsw.closed) {
3286
+ stream = undefined;
3287
+ return;
3288
+ }
3289
+ const item = entry.path;
3290
+ let path = sp.join(directory, item);
3291
+ current.add(item);
3292
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
3293
+ return;
3294
+ }
3295
+ if (this.fsw.closed) {
3296
+ stream = undefined;
3297
+ return;
3298
+ }
3299
+ if (item === target || !target && !previous.has(item)) {
3300
+ this.fsw._incrReadyCount();
3301
+ path = sp.join(dir, sp.relative(dir, path));
3302
+ this._addToNodeFs(path, initialAdd, wh, depth + 1);
3303
+ }
3304
+ }).on(EV.ERROR, this._boundHandleError);
3305
+ return new Promise((resolve2, reject) => {
3306
+ if (!stream)
3307
+ return reject();
3308
+ stream.once(STR_END, () => {
3309
+ if (this.fsw.closed) {
3310
+ stream = undefined;
3311
+ return;
3312
+ }
3313
+ const wasThrottled = throttler ? throttler.clear() : false;
3314
+ resolve2(undefined);
3315
+ previous.getChildren().filter((item) => {
3316
+ return item !== directory && !current.has(item);
3317
+ }).forEach((item) => {
3318
+ this.fsw._remove(directory, item);
3319
+ });
3320
+ stream = undefined;
3321
+ if (wasThrottled)
3322
+ this._handleRead(directory, false, wh, target, dir, depth, throttler);
3323
+ });
3324
+ });
3325
+ }
3326
+ async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
3327
+ const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
3328
+ const tracked = parentDir.has(sp.basename(dir));
3329
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
3330
+ this.fsw._emit(EV.ADD_DIR, dir, stats);
3331
+ }
3332
+ parentDir.add(sp.basename(dir));
3333
+ this.fsw._getWatchedDir(dir);
3334
+ let throttler;
3335
+ let closer;
3336
+ const oDepth = this.fsw.options.depth;
3337
+ if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
3338
+ if (!target) {
3339
+ await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
3340
+ if (this.fsw.closed)
3341
+ return;
3342
+ }
3343
+ closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
3344
+ if (stats2 && stats2.mtimeMs === 0)
3345
+ return;
3346
+ this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
3347
+ });
3348
+ }
3349
+ return closer;
3350
+ }
3351
+ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
3352
+ const ready = this.fsw._emitReady;
3353
+ if (this.fsw._isIgnored(path) || this.fsw.closed) {
3354
+ ready();
3355
+ return false;
3356
+ }
3357
+ const wh = this.fsw._getWatchHelpers(path);
3358
+ if (priorWh) {
3359
+ wh.filterPath = (entry) => priorWh.filterPath(entry);
3360
+ wh.filterDir = (entry) => priorWh.filterDir(entry);
3361
+ }
3362
+ try {
3363
+ const stats = await statMethods[wh.statMethod](wh.watchPath);
3364
+ if (this.fsw.closed)
3365
+ return;
3366
+ if (this.fsw._isIgnored(wh.watchPath, stats)) {
3367
+ ready();
3368
+ return false;
3369
+ }
3370
+ const follow = this.fsw.options.followSymlinks;
3371
+ let closer;
3372
+ if (stats.isDirectory()) {
3373
+ const absPath = sp.resolve(path);
3374
+ const targetPath = follow ? await fsrealpath(path) : path;
3375
+ if (this.fsw.closed)
3376
+ return;
3377
+ closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
3378
+ if (this.fsw.closed)
3379
+ return;
3380
+ if (absPath !== targetPath && targetPath !== undefined) {
3381
+ this.fsw._symlinkPaths.set(absPath, targetPath);
3382
+ }
3383
+ } else if (stats.isSymbolicLink()) {
3384
+ const targetPath = follow ? await fsrealpath(path) : path;
3385
+ if (this.fsw.closed)
3386
+ return;
3387
+ const parent = sp.dirname(wh.watchPath);
3388
+ this.fsw._getWatchedDir(parent).add(wh.watchPath);
3389
+ this.fsw._emit(EV.ADD, wh.watchPath, stats);
3390
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
3391
+ if (this.fsw.closed)
3392
+ return;
3393
+ if (targetPath !== undefined) {
3394
+ this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
3395
+ }
3396
+ } else {
3397
+ closer = this._handleFile(wh.watchPath, stats, initialAdd);
3398
+ }
3399
+ ready();
3400
+ if (closer)
3401
+ this.fsw._addPathCloser(path, closer);
3402
+ return false;
3403
+ } catch (error) {
3404
+ if (this.fsw._handleError(error)) {
3405
+ ready();
3406
+ return path;
3407
+ }
3408
+ }
3409
+ }
3410
+ }
3411
+
3412
+ // node_modules/chokidar/index.js
3413
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
3414
+ var SLASH = "/";
3415
+ var SLASH_SLASH = "//";
3416
+ var ONE_DOT = ".";
3417
+ var TWO_DOTS = "..";
3418
+ var STRING_TYPE = "string";
3419
+ var BACK_SLASH_RE = /\\/g;
3420
+ var DOUBLE_SLASH_RE = /\/\//g;
3421
+ var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
3422
+ var REPLACER_RE = /^\.[/\\]/;
3423
+ function arrify(item) {
3424
+ return Array.isArray(item) ? item : [item];
3425
+ }
3426
+ var isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
3427
+ function createPattern(matcher) {
3428
+ if (typeof matcher === "function")
3429
+ return matcher;
3430
+ if (typeof matcher === "string")
3431
+ return (string) => matcher === string;
3432
+ if (matcher instanceof RegExp)
3433
+ return (string) => matcher.test(string);
3434
+ if (typeof matcher === "object" && matcher !== null) {
3435
+ return (string) => {
3436
+ if (matcher.path === string)
3437
+ return true;
3438
+ if (matcher.recursive) {
3439
+ const relative3 = sp2.relative(matcher.path, string);
3440
+ if (!relative3) {
3441
+ return false;
3442
+ }
3443
+ return !relative3.startsWith("..") && !sp2.isAbsolute(relative3);
3444
+ }
3445
+ return false;
3446
+ };
3447
+ }
3448
+ return () => false;
3449
+ }
3450
+ function normalizePath(path) {
3451
+ if (typeof path !== "string")
3452
+ throw new Error("string expected");
3453
+ path = sp2.normalize(path);
3454
+ path = path.replace(/\\/g, "/");
3455
+ let prepend = false;
3456
+ if (path.startsWith("//"))
3457
+ prepend = true;
3458
+ path = path.replace(DOUBLE_SLASH_RE, "/");
3459
+ if (prepend)
3460
+ path = "/" + path;
3461
+ return path;
3462
+ }
3463
+ function matchPatterns(patterns, testString, stats) {
3464
+ const path = normalizePath(testString);
3465
+ for (let index = 0;index < patterns.length; index++) {
3466
+ const pattern = patterns[index];
3467
+ if (pattern(path, stats)) {
3468
+ return true;
3469
+ }
3470
+ }
3471
+ return false;
3472
+ }
3473
+ function anymatch(matchers, testString) {
3474
+ if (matchers == null) {
3475
+ throw new TypeError("anymatch: specify first argument");
3476
+ }
3477
+ const matchersArray = arrify(matchers);
3478
+ const patterns = matchersArray.map((matcher) => createPattern(matcher));
3479
+ if (testString == null) {
3480
+ return (testString2, stats) => {
3481
+ return matchPatterns(patterns, testString2, stats);
3482
+ };
3483
+ }
3484
+ return matchPatterns(patterns, testString);
3485
+ }
3486
+ var unifyPaths = (paths_) => {
3487
+ const paths = arrify(paths_).flat();
3488
+ if (!paths.every((p) => typeof p === STRING_TYPE)) {
3489
+ throw new TypeError(`Non-string provided as watch path: ${paths}`);
3490
+ }
3491
+ return paths.map(normalizePathToUnix);
3492
+ };
3493
+ var toUnix = (string) => {
3494
+ let str = string.replace(BACK_SLASH_RE, SLASH);
3495
+ let prepend = false;
3496
+ if (str.startsWith(SLASH_SLASH)) {
3497
+ prepend = true;
3498
+ }
3499
+ str = str.replace(DOUBLE_SLASH_RE, SLASH);
3500
+ if (prepend) {
3501
+ str = SLASH + str;
3502
+ }
3503
+ return str;
3504
+ };
3505
+ var normalizePathToUnix = (path) => toUnix(sp2.normalize(toUnix(path)));
3506
+ var normalizeIgnored = (cwd = "") => (path) => {
3507
+ if (typeof path === "string") {
3508
+ return normalizePathToUnix(sp2.isAbsolute(path) ? path : sp2.join(cwd, path));
3509
+ } else {
3510
+ return path;
3511
+ }
3512
+ };
3513
+ var getAbsolutePath = (path, cwd) => {
3514
+ if (sp2.isAbsolute(path)) {
3515
+ return path;
3516
+ }
3517
+ return sp2.join(cwd, path);
3518
+ };
3519
+ var EMPTY_SET = Object.freeze(new Set);
3520
+
3521
+ class DirEntry {
3522
+ path;
3523
+ _removeWatcher;
3524
+ items;
3525
+ constructor(dir, removeWatcher) {
3526
+ this.path = dir;
3527
+ this._removeWatcher = removeWatcher;
3528
+ this.items = new Set;
3529
+ }
3530
+ add(item) {
3531
+ const { items } = this;
3532
+ if (!items)
3533
+ return;
3534
+ if (item !== ONE_DOT && item !== TWO_DOTS)
3535
+ items.add(item);
3536
+ }
3537
+ async remove(item) {
3538
+ const { items } = this;
3539
+ if (!items)
3540
+ return;
3541
+ items.delete(item);
3542
+ if (items.size > 0)
3543
+ return;
3544
+ const dir = this.path;
3545
+ try {
3546
+ await readdir2(dir);
3547
+ } catch (err) {
3548
+ if (this._removeWatcher) {
3549
+ this._removeWatcher(sp2.dirname(dir), sp2.basename(dir));
3550
+ }
3551
+ }
3552
+ }
3553
+ has(item) {
3554
+ const { items } = this;
3555
+ if (!items)
3556
+ return;
3557
+ return items.has(item);
3558
+ }
3559
+ getChildren() {
3560
+ const { items } = this;
3561
+ if (!items)
3562
+ return [];
3563
+ return [...items.values()];
3564
+ }
3565
+ dispose() {
3566
+ this.items.clear();
3567
+ this.path = "";
3568
+ this._removeWatcher = EMPTY_FN;
3569
+ this.items = EMPTY_SET;
3570
+ Object.freeze(this);
3571
+ }
3572
+ }
3573
+ var STAT_METHOD_F = "stat";
3574
+ var STAT_METHOD_L = "lstat";
3575
+
3576
+ class WatchHelper {
3577
+ fsw;
3578
+ path;
3579
+ watchPath;
3580
+ fullWatchPath;
3581
+ dirParts;
3582
+ followSymlinks;
3583
+ statMethod;
3584
+ constructor(path, follow, fsw) {
3585
+ this.fsw = fsw;
3586
+ const watchPath = path;
3587
+ this.path = path = path.replace(REPLACER_RE, "");
3588
+ this.watchPath = watchPath;
3589
+ this.fullWatchPath = sp2.resolve(watchPath);
3590
+ this.dirParts = [];
3591
+ this.dirParts.forEach((parts) => {
3592
+ if (parts.length > 1)
3593
+ parts.pop();
3594
+ });
3595
+ this.followSymlinks = follow;
3596
+ this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
3597
+ }
3598
+ entryPath(entry) {
3599
+ return sp2.join(this.watchPath, sp2.relative(this.watchPath, entry.fullPath));
3600
+ }
3601
+ filterPath(entry) {
3602
+ const { stats } = entry;
3603
+ if (stats && stats.isSymbolicLink())
3604
+ return this.filterDir(entry);
3605
+ const resolvedPath = this.entryPath(entry);
3606
+ return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
3607
+ }
3608
+ filterDir(entry) {
3609
+ return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
3610
+ }
3611
+ }
3612
+
3613
+ class FSWatcher extends EventEmitter {
3614
+ closed;
3615
+ options;
3616
+ _closers;
3617
+ _ignoredPaths;
3618
+ _throttled;
3619
+ _streams;
3620
+ _symlinkPaths;
3621
+ _watched;
3622
+ _pendingWrites;
3623
+ _pendingUnlinks;
3624
+ _readyCount;
3625
+ _emitReady;
3626
+ _closePromise;
3627
+ _userIgnored;
3628
+ _readyEmitted;
3629
+ _emitRaw;
3630
+ _boundRemove;
3631
+ _nodeFsHandler;
3632
+ constructor(_opts = {}) {
3633
+ super();
3634
+ this.closed = false;
3635
+ this._closers = new Map;
3636
+ this._ignoredPaths = new Set;
3637
+ this._throttled = new Map;
3638
+ this._streams = new Set;
3639
+ this._symlinkPaths = new Map;
3640
+ this._watched = new Map;
3641
+ this._pendingWrites = new Map;
3642
+ this._pendingUnlinks = new Map;
3643
+ this._readyCount = 0;
3644
+ this._readyEmitted = false;
3645
+ const awf = _opts.awaitWriteFinish;
3646
+ const DEF_AWF = { stabilityThreshold: 2000, pollInterval: 100 };
3647
+ const opts = {
3648
+ persistent: true,
3649
+ ignoreInitial: false,
3650
+ ignorePermissionErrors: false,
3651
+ interval: 100,
3652
+ binaryInterval: 300,
3653
+ followSymlinks: true,
3654
+ usePolling: false,
3655
+ atomic: true,
3656
+ ..._opts,
3657
+ ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
3658
+ awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? { ...DEF_AWF, ...awf } : false
3659
+ };
3660
+ if (isIBMi)
3661
+ opts.usePolling = true;
3662
+ if (opts.atomic === undefined)
3663
+ opts.atomic = !opts.usePolling;
3664
+ const envPoll = process.env.CHOKIDAR_USEPOLLING;
3665
+ if (envPoll !== undefined) {
3666
+ const envLower = envPoll.toLowerCase();
3667
+ if (envLower === "false" || envLower === "0")
3668
+ opts.usePolling = false;
3669
+ else if (envLower === "true" || envLower === "1")
3670
+ opts.usePolling = true;
3671
+ else
3672
+ opts.usePolling = !!envLower;
3673
+ }
3674
+ const envInterval = process.env.CHOKIDAR_INTERVAL;
3675
+ if (envInterval)
3676
+ opts.interval = Number.parseInt(envInterval, 10);
3677
+ let readyCalls = 0;
3678
+ this._emitReady = () => {
3679
+ readyCalls++;
3680
+ if (readyCalls >= this._readyCount) {
3681
+ this._emitReady = EMPTY_FN;
3682
+ this._readyEmitted = true;
3683
+ process.nextTick(() => this.emit(EVENTS.READY));
3684
+ }
3685
+ };
3686
+ this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
3687
+ this._boundRemove = this._remove.bind(this);
3688
+ this.options = opts;
3689
+ this._nodeFsHandler = new NodeFsHandler(this);
3690
+ Object.freeze(opts);
3691
+ }
3692
+ _addIgnoredPath(matcher) {
3693
+ if (isMatcherObject(matcher)) {
3694
+ for (const ignored of this._ignoredPaths) {
3695
+ if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) {
3696
+ return;
3697
+ }
3698
+ }
3699
+ }
3700
+ this._ignoredPaths.add(matcher);
3701
+ }
3702
+ _removeIgnoredPath(matcher) {
3703
+ this._ignoredPaths.delete(matcher);
3704
+ if (typeof matcher === "string") {
3705
+ for (const ignored of this._ignoredPaths) {
3706
+ if (isMatcherObject(ignored) && ignored.path === matcher) {
3707
+ this._ignoredPaths.delete(ignored);
3708
+ }
3709
+ }
3710
+ }
3711
+ }
3712
+ add(paths_, _origAdd, _internal) {
3713
+ const { cwd } = this.options;
3714
+ this.closed = false;
3715
+ this._closePromise = undefined;
3716
+ let paths = unifyPaths(paths_);
3717
+ if (cwd) {
3718
+ paths = paths.map((path) => {
3719
+ const absPath = getAbsolutePath(path, cwd);
3720
+ return absPath;
3721
+ });
3722
+ }
3723
+ paths.forEach((path) => {
3724
+ this._removeIgnoredPath(path);
3725
+ });
3726
+ this._userIgnored = undefined;
3727
+ if (!this._readyCount)
3728
+ this._readyCount = 0;
3729
+ this._readyCount += paths.length;
3730
+ Promise.all(paths.map(async (path) => {
3731
+ const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, undefined, 0, _origAdd);
3732
+ if (res)
3733
+ this._emitReady();
3734
+ return res;
3735
+ })).then((results) => {
3736
+ if (this.closed)
3737
+ return;
3738
+ results.forEach((item) => {
3739
+ if (item)
3740
+ this.add(sp2.dirname(item), sp2.basename(_origAdd || item));
3741
+ });
3742
+ });
3743
+ return this;
3744
+ }
3745
+ unwatch(paths_) {
3746
+ if (this.closed)
3747
+ return this;
3748
+ const paths = unifyPaths(paths_);
3749
+ const { cwd } = this.options;
3750
+ paths.forEach((path) => {
3751
+ if (!sp2.isAbsolute(path) && !this._closers.has(path)) {
3752
+ if (cwd)
3753
+ path = sp2.join(cwd, path);
3754
+ path = sp2.resolve(path);
3755
+ }
3756
+ this._closePath(path);
3757
+ this._addIgnoredPath(path);
3758
+ if (this._watched.has(path)) {
3759
+ this._addIgnoredPath({
3760
+ path,
3761
+ recursive: true
3762
+ });
3763
+ }
3764
+ this._userIgnored = undefined;
3765
+ });
3766
+ return this;
3767
+ }
3768
+ close() {
3769
+ if (this._closePromise) {
3770
+ return this._closePromise;
3771
+ }
3772
+ this.closed = true;
3773
+ this.removeAllListeners();
3774
+ const closers = [];
3775
+ this._closers.forEach((closerList) => closerList.forEach((closer) => {
3776
+ const promise = closer();
3777
+ if (promise instanceof Promise)
3778
+ closers.push(promise);
3779
+ }));
3780
+ this._streams.forEach((stream) => stream.destroy());
3781
+ this._userIgnored = undefined;
3782
+ this._readyCount = 0;
3783
+ this._readyEmitted = false;
3784
+ this._watched.forEach((dirent) => dirent.dispose());
3785
+ this._closers.clear();
3786
+ this._watched.clear();
3787
+ this._streams.clear();
3788
+ this._symlinkPaths.clear();
3789
+ this._throttled.clear();
3790
+ this._closePromise = closers.length ? Promise.all(closers).then(() => {
3791
+ return;
3792
+ }) : Promise.resolve();
3793
+ return this._closePromise;
3794
+ }
3795
+ getWatched() {
3796
+ const watchList = {};
3797
+ this._watched.forEach((entry, dir) => {
3798
+ const key = this.options.cwd ? sp2.relative(this.options.cwd, dir) : dir;
3799
+ const index = key || ONE_DOT;
3800
+ watchList[index] = entry.getChildren().sort();
3801
+ });
3802
+ return watchList;
3803
+ }
3804
+ emitWithAll(event, args) {
3805
+ this.emit(event, ...args);
3806
+ if (event !== EVENTS.ERROR)
3807
+ this.emit(EVENTS.ALL, event, ...args);
3808
+ }
3809
+ async _emit(event, path, stats) {
3810
+ if (this.closed)
3811
+ return;
3812
+ const opts = this.options;
3813
+ if (isWindows)
3814
+ path = sp2.normalize(path);
3815
+ if (opts.cwd)
3816
+ path = sp2.relative(opts.cwd, path);
3817
+ const args = [path];
3818
+ if (stats != null)
3819
+ args.push(stats);
3820
+ const awf = opts.awaitWriteFinish;
3821
+ let pw;
3822
+ if (awf && (pw = this._pendingWrites.get(path))) {
3823
+ pw.lastChange = new Date;
3824
+ return this;
3825
+ }
3826
+ if (opts.atomic) {
3827
+ if (event === EVENTS.UNLINK) {
3828
+ this._pendingUnlinks.set(path, [event, ...args]);
3829
+ setTimeout(() => {
3830
+ this._pendingUnlinks.forEach((entry, path2) => {
3831
+ this.emit(...entry);
3832
+ this.emit(EVENTS.ALL, ...entry);
3833
+ this._pendingUnlinks.delete(path2);
3834
+ });
3835
+ }, typeof opts.atomic === "number" ? opts.atomic : 100);
3836
+ return this;
3837
+ }
3838
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
3839
+ event = EVENTS.CHANGE;
3840
+ this._pendingUnlinks.delete(path);
3841
+ }
3842
+ }
3843
+ if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
3844
+ const awfEmit = (err, stats2) => {
3845
+ if (err) {
3846
+ event = EVENTS.ERROR;
3847
+ args[0] = err;
3848
+ this.emitWithAll(event, args);
3849
+ } else if (stats2) {
3850
+ if (args.length > 1) {
3851
+ args[1] = stats2;
3852
+ } else {
3853
+ args.push(stats2);
3854
+ }
3855
+ this.emitWithAll(event, args);
3856
+ }
3857
+ };
3858
+ this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
3859
+ return this;
3860
+ }
3861
+ if (event === EVENTS.CHANGE) {
3862
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path, 50);
3863
+ if (isThrottled)
3864
+ return this;
3865
+ }
3866
+ if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
3867
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path) : path;
3868
+ let stats2;
3869
+ try {
3870
+ stats2 = await stat3(fullPath);
3871
+ } catch (err) {
3872
+ }
3873
+ if (!stats2 || this.closed)
3874
+ return;
3875
+ args.push(stats2);
3876
+ }
3877
+ this.emitWithAll(event, args);
3878
+ return this;
3879
+ }
3880
+ _handleError(error) {
3881
+ const code = error && error.code;
3882
+ if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) {
3883
+ this.emit(EVENTS.ERROR, error);
3884
+ }
3885
+ return error || this.closed;
3886
+ }
3887
+ _throttle(actionType, path, timeout) {
3888
+ if (!this._throttled.has(actionType)) {
3889
+ this._throttled.set(actionType, new Map);
3890
+ }
3891
+ const action = this._throttled.get(actionType);
3892
+ if (!action)
3893
+ throw new Error("invalid throttle");
3894
+ const actionPath = action.get(path);
3895
+ if (actionPath) {
3896
+ actionPath.count++;
3897
+ return false;
3898
+ }
3899
+ let timeoutObject;
3900
+ const clear = () => {
3901
+ const item = action.get(path);
3902
+ const count = item ? item.count : 0;
3903
+ action.delete(path);
3904
+ clearTimeout(timeoutObject);
3905
+ if (item)
3906
+ clearTimeout(item.timeoutObject);
3907
+ return count;
3908
+ };
3909
+ timeoutObject = setTimeout(clear, timeout);
3910
+ const thr = { timeoutObject, clear, count: 0 };
3911
+ action.set(path, thr);
3912
+ return thr;
3913
+ }
3914
+ _incrReadyCount() {
3915
+ return this._readyCount++;
3916
+ }
3917
+ _awaitWriteFinish(path, threshold, event, awfEmit) {
3918
+ const awf = this.options.awaitWriteFinish;
3919
+ if (typeof awf !== "object")
3920
+ return;
3921
+ const pollInterval = awf.pollInterval;
3922
+ let timeoutHandler;
3923
+ let fullPath = path;
3924
+ if (this.options.cwd && !sp2.isAbsolute(path)) {
3925
+ fullPath = sp2.join(this.options.cwd, path);
3926
+ }
3927
+ const now = new Date;
3928
+ const writes = this._pendingWrites;
3929
+ function awaitWriteFinishFn(prevStat) {
3930
+ statcb(fullPath, (err, curStat) => {
3931
+ if (err || !writes.has(path)) {
3932
+ if (err && err.code !== "ENOENT")
3933
+ awfEmit(err);
3934
+ return;
3935
+ }
3936
+ const now2 = Number(new Date);
3937
+ if (prevStat && curStat.size !== prevStat.size) {
3938
+ writes.get(path).lastChange = now2;
3939
+ }
3940
+ const pw = writes.get(path);
3941
+ const df = now2 - pw.lastChange;
3942
+ if (df >= threshold) {
3943
+ writes.delete(path);
3944
+ awfEmit(undefined, curStat);
3945
+ } else {
3946
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
3947
+ }
3948
+ });
3949
+ }
3950
+ if (!writes.has(path)) {
3951
+ writes.set(path, {
3952
+ lastChange: now,
3953
+ cancelWait: () => {
3954
+ writes.delete(path);
3955
+ clearTimeout(timeoutHandler);
3956
+ return event;
3957
+ }
3958
+ });
3959
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
3960
+ }
3961
+ }
3962
+ _isIgnored(path, stats) {
3963
+ if (this.options.atomic && DOT_RE.test(path))
3964
+ return true;
3965
+ if (!this._userIgnored) {
3966
+ const { cwd } = this.options;
3967
+ const ign = this.options.ignored;
3968
+ const ignored = (ign || []).map(normalizeIgnored(cwd));
3969
+ const ignoredPaths = [...this._ignoredPaths];
3970
+ const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
3971
+ this._userIgnored = anymatch(list, undefined);
3972
+ }
3973
+ return this._userIgnored(path, stats);
3974
+ }
3975
+ _isntIgnored(path, stat4) {
3976
+ return !this._isIgnored(path, stat4);
3977
+ }
3978
+ _getWatchHelpers(path) {
3979
+ return new WatchHelper(path, this.options.followSymlinks, this);
3980
+ }
3981
+ _getWatchedDir(directory) {
3982
+ const dir = sp2.resolve(directory);
3983
+ if (!this._watched.has(dir))
3984
+ this._watched.set(dir, new DirEntry(dir, this._boundRemove));
3985
+ return this._watched.get(dir);
3986
+ }
3987
+ _hasReadPermissions(stats) {
3988
+ if (this.options.ignorePermissionErrors)
3989
+ return true;
3990
+ return Boolean(Number(stats.mode) & 256);
3991
+ }
3992
+ _remove(directory, item, isDirectory) {
3993
+ const path = sp2.join(directory, item);
3994
+ const fullPath = sp2.resolve(path);
3995
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
3996
+ if (!this._throttle("remove", path, 100))
3997
+ return;
3998
+ if (!isDirectory && this._watched.size === 1) {
3999
+ this.add(directory, item, true);
4000
+ }
4001
+ const wp = this._getWatchedDir(path);
4002
+ const nestedDirectoryChildren = wp.getChildren();
4003
+ nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));
4004
+ const parent = this._getWatchedDir(directory);
4005
+ const wasTracked = parent.has(item);
4006
+ parent.remove(item);
4007
+ if (this._symlinkPaths.has(fullPath)) {
4008
+ this._symlinkPaths.delete(fullPath);
4009
+ }
4010
+ let relPath = path;
4011
+ if (this.options.cwd)
4012
+ relPath = sp2.relative(this.options.cwd, path);
4013
+ if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
4014
+ const event = this._pendingWrites.get(relPath).cancelWait();
4015
+ if (event === EVENTS.ADD)
4016
+ return;
4017
+ }
4018
+ this._watched.delete(path);
4019
+ this._watched.delete(fullPath);
4020
+ const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
4021
+ if (wasTracked && !this._isIgnored(path))
4022
+ this._emit(eventName, path);
4023
+ this._closePath(path);
4024
+ }
4025
+ _closePath(path) {
4026
+ this._closeFile(path);
4027
+ const dir = sp2.dirname(path);
4028
+ this._getWatchedDir(dir).remove(sp2.basename(path));
4029
+ }
4030
+ _closeFile(path) {
4031
+ const closers = this._closers.get(path);
4032
+ if (!closers)
4033
+ return;
4034
+ closers.forEach((closer) => closer());
4035
+ this._closers.delete(path);
4036
+ }
4037
+ _addPathCloser(path, closer) {
4038
+ if (!closer)
4039
+ return;
4040
+ let list = this._closers.get(path);
4041
+ if (!list) {
4042
+ list = [];
4043
+ this._closers.set(path, list);
4044
+ }
4045
+ list.push(closer);
4046
+ }
4047
+ _readdirp(root, opts) {
4048
+ if (this.closed)
4049
+ return;
4050
+ const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
4051
+ let stream = readdirp(root, options);
4052
+ this._streams.add(stream);
4053
+ stream.once(STR_CLOSE, () => {
4054
+ stream = undefined;
4055
+ });
4056
+ stream.once(STR_END, () => {
4057
+ if (stream) {
4058
+ this._streams.delete(stream);
4059
+ stream = undefined;
4060
+ }
4061
+ });
4062
+ return stream;
4063
+ }
4064
+ }
4065
+ function watch(paths, options = {}) {
4066
+ const watcher = new FSWatcher(options);
4067
+ watcher.add(paths);
4068
+ return watcher;
4069
+ }
4070
+
2432
4071
  // node_modules/uuid/dist/esm/stringify.js
2433
4072
  var byteToHex = [];
2434
4073
  for (let i = 0;i < 256; ++i) {
@@ -2460,11 +4099,17 @@ function v4(options, buf, offset) {
2460
4099
  return native_default.randomUUID();
2461
4100
  }
2462
4101
  options = options || {};
2463
- const rnds = options.random || (options.rng || rng)();
4102
+ const rnds = options.random ?? options.rng?.() ?? rng();
4103
+ if (rnds.length < 16) {
4104
+ throw new Error("Random bytes length must be >= 16");
4105
+ }
2464
4106
  rnds[6] = rnds[6] & 15 | 64;
2465
4107
  rnds[8] = rnds[8] & 63 | 128;
2466
4108
  if (buf) {
2467
4109
  offset = offset || 0;
4110
+ if (offset < 0 || offset + 16 > buf.length) {
4111
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
4112
+ }
2468
4113
  for (let i = 0;i < 16; ++i) {
2469
4114
  buf[offset + i] = rnds[i];
2470
4115
  }
@@ -2474,19 +4119,19 @@ function v4(options, buf, offset) {
2474
4119
  }
2475
4120
  var v4_default = v4;
2476
4121
  // src/vendor/vyi/index.js
2477
- /*!
2478
- * vyi@4.1.0 https://github.com/EvitcaStudio/vyi
2479
- * Compiled Sun, 21 Jun 2026 10:57:24 UTC
2480
- * Copyright (c) 2026 Evitca Studio, "doubleactii"
2481
- *
2482
- * vyi is privately licensed.
4122
+ /*!
4123
+ * vyi@4.1.0 https://github.com/EvitcaStudio/vyi
4124
+ * Compiled Sun, 21 Jun 2026 10:57:24 UTC
4125
+ * Copyright (c) 2026 Evitca Studio, "doubleactii"
4126
+ *
4127
+ * vyi is privately licensed.
2483
4128
  */
2484
- /*!
2485
- * logger@1.0.0 https://github.com/EvitcaStudio/Logger
2486
- * Compiled Mon, 10 Nov 2025 05:36:23 UTC
2487
- * Copyright (c) 2025 Evitca Studio, "doubleactii"
2488
- *
2489
- * logger is privately licensed.
4129
+ /*!
4130
+ * logger@1.0.0 https://github.com/EvitcaStudio/Logger
4131
+ * Compiled Mon, 10 Nov 2025 05:36:23 UTC
4132
+ * Copyright (c) 2025 Evitca Studio, "doubleactii"
4133
+ *
4134
+ * logger is privately licensed.
2490
4135
  */
2491
4136
 
2492
4137
  class Logger {
@@ -2757,19 +4402,19 @@ class Frame {
2757
4402
  return frameData;
2758
4403
  }
2759
4404
  }
2760
- /*!
2761
- * icon-point@2.1.0 https://github.com/EvitcaStudio/IconPoint
2762
- * Compiled Mon, 10 Nov 2025 09:52:21 UTC
2763
- * Copyright (c) 2025 Evitca Studio, "doubleactii"
2764
- *
2765
- * icon-point is privately licensed.
4405
+ /*!
4406
+ * icon-point@2.1.0 https://github.com/EvitcaStudio/IconPoint
4407
+ * Compiled Mon, 10 Nov 2025 09:52:21 UTC
4408
+ * Copyright (c) 2025 Evitca Studio, "doubleactii"
4409
+ *
4410
+ * icon-point is privately licensed.
2766
4411
  */
2767
- /*!
2768
- * logger@1.0.0 https://github.com/EvitcaStudio/Logger
2769
- * Compiled Mon, 10 Nov 2025 05:36:23 UTC
2770
- * Copyright (c) 2025 Evitca Studio, "doubleactii"
2771
- *
2772
- * logger is privately licensed.
4412
+ /*!
4413
+ * logger@1.0.0 https://github.com/EvitcaStudio/Logger
4414
+ * Compiled Mon, 10 Nov 2025 05:36:23 UTC
4415
+ * Copyright (c) 2025 Evitca Studio, "doubleactii"
4416
+ *
4417
+ * logger is privately licensed.
2773
4418
  */
2774
4419
 
2775
4420
  class Logger2 {
@@ -7948,22 +9593,22 @@ class WorkerPool {
7948
9593
  if (this.workers.length === 0) {
7949
9594
  throw new Error("Workers have been terminated. Create a new VyiWorker instance to continue.");
7950
9595
  }
7951
- return new Promise((resolve) => {
7952
- this.waitQueue.push(resolve);
9596
+ return new Promise((resolve3) => {
9597
+ this.waitQueue.push(resolve3);
7953
9598
  });
7954
9599
  }
7955
9600
  returnWorker(worker) {
7956
9601
  if (this.waitQueue.length > 0) {
7957
- const resolve = this.waitQueue.shift();
7958
- resolve(worker);
9602
+ const resolve3 = this.waitQueue.shift();
9603
+ resolve3(worker);
7959
9604
  } else if (this.workers.includes(worker)) {
7960
9605
  this.availableWorkers.push(worker);
7961
9606
  }
7962
9607
  }
7963
9608
  async sendMessage(worker, type, data) {
7964
9609
  const id = `${this.messageId++}`;
7965
- return new Promise((resolve, reject) => {
7966
- this.pendingMessages.set(id, { resolve, reject });
9610
+ return new Promise((resolve3, reject) => {
9611
+ this.pendingMessages.set(id, { resolve: resolve3, reject });
7967
9612
  worker.postMessage({ id, type, data });
7968
9613
  setTimeout(() => {
7969
9614
  if (this.pendingMessages.has(id)) {
@@ -7988,12 +9633,12 @@ class WorkerPool {
7988
9633
 
7989
9634
  // src/cli/app-bundler.ts
7990
9635
  import { promises as fs, existsSync } from "fs";
7991
- import { join, dirname, extname } from "path";
9636
+ import { join as join3, dirname as dirname3, extname as extname2 } from "path";
7992
9637
  var Bun2 = globalThis.Bun;
7993
9638
  function detectArchitecture(pSrcDir) {
7994
- const hasClientEntry = existsSync(join(pSrcDir, "client", "index.ts"));
7995
- const hasServerEntry = existsSync(join(pSrcDir, "server", "index.ts"));
7996
- const hasSingleEntry = existsSync(join(pSrcDir, "index.ts"));
9639
+ const hasClientEntry = existsSync(join3(pSrcDir, "client", "index.ts"));
9640
+ const hasServerEntry = existsSync(join3(pSrcDir, "server", "index.ts"));
9641
+ const hasSingleEntry = existsSync(join3(pSrcDir, "index.ts"));
7997
9642
  if (hasClientEntry || hasServerEntry) {
7998
9643
  return "multi";
7999
9644
  }
@@ -8008,8 +9653,8 @@ async function copyDirectoryRecursive(pSourceDir, pDestDir) {
8008
9653
  const entries = await fs.readdir(pSourceDir, { withFileTypes: true });
8009
9654
  await fs.mkdir(pDestDir, { recursive: true });
8010
9655
  for (const entry of entries) {
8011
- const srcPath = join(pSourceDir, entry.name);
8012
- const destPath = join(pDestDir, entry.name);
9656
+ const srcPath = join3(pSourceDir, entry.name);
9657
+ const destPath = join3(pDestDir, entry.name);
8013
9658
  if (entry.isDirectory()) {
8014
9659
  await copyDirectoryRecursive(srcPath, destPath);
8015
9660
  } else {
@@ -8022,21 +9667,21 @@ async function copyStaticWebFiles(pSourceDir, pDestDir, pBaseDir) {
8022
9667
  return;
8023
9668
  const entries = await fs.readdir(pSourceDir, { withFileTypes: true });
8024
9669
  for (const entry of entries) {
8025
- const fullPath = join(pSourceDir, entry.name);
9670
+ const fullPath = join3(pSourceDir, entry.name);
8026
9671
  if (entry.isDirectory()) {
8027
9672
  if (entry.name === "vendor" || entry.name === "resources" || entry.name === "node_modules") {
8028
9673
  continue;
8029
9674
  }
8030
9675
  await copyStaticWebFiles(fullPath, pDestDir, pBaseDir);
8031
9676
  } else {
8032
- const ext = extname(entry.name).toLowerCase();
9677
+ const ext = extname2(entry.name).toLowerCase();
8033
9678
  if ([".html", ".css", ".ico"].includes(ext)) {
8034
9679
  const relativePath = fullPath.slice(pBaseDir.length).replace(/^[/\\]+/, "");
8035
- const targetPath = join(pDestDir, relativePath);
8036
- await fs.mkdir(dirname(targetPath), { recursive: true });
9680
+ const targetPath = join3(pDestDir, relativePath);
9681
+ await fs.mkdir(dirname3(targetPath), { recursive: true });
8037
9682
  await fs.copyFile(fullPath, targetPath);
8038
9683
  if ([".css", ".ico"].includes(ext)) {
8039
- const rootTargetPath = join(pDestDir, entry.name);
9684
+ const rootTargetPath = join3(pDestDir, entry.name);
8040
9685
  if (targetPath !== rootTargetPath && !existsSync(rootTargetPath)) {
8041
9686
  await fs.copyFile(fullPath, rootTargetPath);
8042
9687
  }
@@ -8046,7 +9691,7 @@ async function copyStaticWebFiles(pSourceDir, pDestDir, pBaseDir) {
8046
9691
  }
8047
9692
  }
8048
9693
  async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
8049
- const srcDir = join(pProjectRoot, "src");
9694
+ const srcDir = join3(pProjectRoot, "src");
8050
9695
  const architecture = detectArchitecture(srcDir);
8051
9696
  const isVerbose = Boolean(pOptions.verbose);
8052
9697
  if (architecture === "none") {
@@ -8060,7 +9705,7 @@ async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
8060
9705
  const shouldObfuscate = isProd || Boolean(pOptions.obfuscate);
8061
9706
  const sourcemapMode = pOptions.sourcemap ?? (isProd ? "none" : "linked");
8062
9707
  let banner = "";
8063
- const pkgPath = join(pProjectRoot, "package.json");
9708
+ const pkgPath = join3(pProjectRoot, "package.json");
8064
9709
  if (existsSync(pkgPath)) {
8065
9710
  try {
8066
9711
  const pkg = JSON.parse(await fs.readFile(pkgPath, "utf8"));
@@ -8081,8 +9726,12 @@ async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
8081
9726
  if (architecture === "single") {
8082
9727
  const startStamp = Date.now();
8083
9728
  const clientResult = await Bun2.build({
8084
- entrypoints: [join(srcDir, "index.ts")],
8085
- naming: "index.js",
9729
+ entrypoints: [join3(srcDir, "index.ts")],
9730
+ naming: {
9731
+ entry: "index.[ext]",
9732
+ chunk: "[name]-[hash].[ext]",
9733
+ asset: "[name].[ext]"
9734
+ },
8086
9735
  outdir: pOutDir,
8087
9736
  target: "browser",
8088
9737
  banner,
@@ -8098,13 +9747,13 @@ async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
8098
9747
  throw new AggregateError(clientResult.logs, "Client build failed");
8099
9748
  }
8100
9749
  await copyStaticWebFiles(srcDir, pOutDir, srcDir);
8101
- const rootFavicon = join(pProjectRoot, "favicon.ico");
9750
+ const rootFavicon = join3(pProjectRoot, "favicon.ico");
8102
9751
  if (existsSync(rootFavicon)) {
8103
- await fs.copyFile(rootFavicon, join(pOutDir, "favicon.ico"));
9752
+ await fs.copyFile(rootFavicon, join3(pOutDir, "favicon.ico"));
8104
9753
  }
8105
- const vendorDir = join(srcDir, "vendor");
9754
+ const vendorDir = join3(srcDir, "vendor");
8106
9755
  if (existsSync(vendorDir)) {
8107
- await copyDirectoryRecursive(vendorDir, join(pOutDir, "vendor"));
9756
+ await copyDirectoryRecursive(vendorDir, join3(pOutDir, "vendor"));
8108
9757
  }
8109
9758
  const elapsed = Date.now() - startStamp;
8110
9759
  if (isVerbose) {
@@ -8113,15 +9762,19 @@ async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
8113
9762
  return { architecture: "single", clientBuildTime: elapsed, success: true };
8114
9763
  }
8115
9764
  if (architecture === "multi") {
8116
- const clientEntry = join(srcDir, "client", "index.ts");
8117
- const serverEntry = join(srcDir, "server", "index.ts");
9765
+ const clientEntry = join3(srcDir, "client", "index.ts");
9766
+ const serverEntry = join3(srcDir, "server", "index.ts");
8118
9767
  let clientElapsed = 0;
8119
9768
  let serverElapsed = 0;
8120
9769
  if (existsSync(clientEntry)) {
8121
9770
  const clientStart = Date.now();
8122
9771
  const clientResult = await Bun2.build({
8123
9772
  entrypoints: [clientEntry],
8124
- naming: "index.js",
9773
+ naming: {
9774
+ entry: "index.[ext]",
9775
+ chunk: "[name]-[hash].[ext]",
9776
+ asset: "[name].[ext]"
9777
+ },
8125
9778
  outdir: pOutDir,
8126
9779
  target: "browser",
8127
9780
  banner,
@@ -8136,11 +9789,11 @@ async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
8136
9789
  console.error(clientResult.logs);
8137
9790
  throw new AggregateError(clientResult.logs, "Multiplayer client build failed");
8138
9791
  }
8139
- const clientSrc = join(srcDir, "client");
9792
+ const clientSrc = join3(srcDir, "client");
8140
9793
  await copyStaticWebFiles(clientSrc, pOutDir, clientSrc);
8141
- const clientVendor = join(clientSrc, "vendor");
9794
+ const clientVendor = join3(clientSrc, "vendor");
8142
9795
  if (existsSync(clientVendor)) {
8143
- await copyDirectoryRecursive(clientVendor, join(pOutDir, "vendor"));
9796
+ await copyDirectoryRecursive(clientVendor, join3(pOutDir, "vendor"));
8144
9797
  }
8145
9798
  clientElapsed = Date.now() - clientStart;
8146
9799
  }
@@ -8148,7 +9801,11 @@ async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
8148
9801
  const serverStart = Date.now();
8149
9802
  const serverResult = await Bun2.build({
8150
9803
  entrypoints: [serverEntry],
8151
- naming: "server.js",
9804
+ naming: {
9805
+ entry: "server.[ext]",
9806
+ chunk: "[name]-[hash].[ext]",
9807
+ asset: "[name].[ext]"
9808
+ },
8152
9809
  outdir: pOutDir,
8153
9810
  target: "node",
8154
9811
  banner,
@@ -8163,15 +9820,15 @@ async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
8163
9820
  console.error(serverResult.logs);
8164
9821
  throw new AggregateError(serverResult.logs, "Multiplayer server build failed");
8165
9822
  }
8166
- const settingsFile = join(srcDir, "server", "settings.json");
9823
+ const settingsFile = join3(srcDir, "server", "settings.json");
8167
9824
  if (existsSync(settingsFile)) {
8168
- await fs.copyFile(settingsFile, join(pOutDir, "settings.json"));
9825
+ await fs.copyFile(settingsFile, join3(pOutDir, "settings.json"));
8169
9826
  }
8170
9827
  serverElapsed = Date.now() - serverStart;
8171
9828
  }
8172
- const rootFavicon = join(pProjectRoot, "favicon.ico");
9829
+ const rootFavicon = join3(pProjectRoot, "favicon.ico");
8173
9830
  if (existsSync(rootFavicon)) {
8174
- await fs.copyFile(rootFavicon, join(pOutDir, "favicon.ico"));
9831
+ await fs.copyFile(rootFavicon, join3(pOutDir, "favicon.ico"));
8175
9832
  }
8176
9833
  if (isVerbose) {
8177
9834
  if (clientElapsed) {
@@ -8217,8 +9874,8 @@ function initializeResourceJSON() {
8217
9874
  }, {});
8218
9875
  }
8219
9876
  function prepareFileForProcessing(pFilePath) {
8220
- const extension = extname2(pFilePath).slice(1);
8221
- const fileName = basename(pFilePath);
9877
+ const extension = extname3(pFilePath).slice(1);
9878
+ const fileName = basename3(pFilePath);
8222
9879
  const resourceIdentifier = `${v4_default()}.vyr`;
8223
9880
  const type = getResourceType(extension);
8224
9881
  if (!type)
@@ -8255,8 +9912,8 @@ async function processDirectory(pDirectoryPath) {
8255
9912
  try {
8256
9913
  const contents = await fs2.readdir(pDirectoryPath);
8257
9914
  for (const item of contents) {
8258
- const itemPath = join2(pDirectoryPath, item);
8259
- if (resolve(itemPath) === resourceOutDirectory) {
9915
+ const itemPath = join4(pDirectoryPath, item);
9916
+ if (resolve3(itemPath) === resourceOutDirectory) {
8260
9917
  continue;
8261
9918
  }
8262
9919
  const stats = await fs2.stat(itemPath);
@@ -8265,7 +9922,7 @@ async function processDirectory(pDirectoryPath) {
8265
9922
  subdirectoriesToMirror.push(item);
8266
9923
  }
8267
9924
  await processDirectory(itemPath);
8268
- } else if (isValidExtension(extname2(itemPath).slice(1))) {
9925
+ } else if (isValidExtension(extname3(itemPath).slice(1))) {
8269
9926
  prepareFileForProcessing(itemPath);
8270
9927
  }
8271
9928
  }
@@ -8284,14 +9941,15 @@ async function mirrorDirectory(pSourceDir, pDestDir) {
8284
9941
  const entries = await fs2.readdir(pSourceDir, { withFileTypes: true });
8285
9942
  await fs2.mkdir(pDestDir, { recursive: true });
8286
9943
  for (const entry of entries) {
8287
- const srcPath = join2(pSourceDir, entry.name);
8288
- const destPath = join2(pDestDir, entry.name);
9944
+ const srcPath = join4(pSourceDir, entry.name);
9945
+ const destPath = join4(pDestDir, entry.name);
8289
9946
  if (entry.isDirectory()) {
8290
9947
  await mirrorDirectory(srcPath, destPath);
8291
9948
  } else {
8292
- const ext = extname2(entry.name).slice(1);
9949
+ const ext = extname3(entry.name).slice(1);
8293
9950
  if (!isEngineExtension(ext)) {
8294
- await fs2.copyFile(srcPath, destPath);
9951
+ const data = await fs2.readFile(srcPath);
9952
+ await fs2.writeFile(destPath, data);
8295
9953
  }
8296
9954
  }
8297
9955
  }
@@ -8300,19 +9958,19 @@ async function processAllFiles() {
8300
9958
  try {
8301
9959
  await clearResourceTypeDirectories(`${resourceOutDirectory}/resources`);
8302
9960
  const copyOperations = resourcesToProcess.map(({ filePath, type }) => {
8303
- const fileName = basename(filePath);
9961
+ const fileName = basename3(filePath);
8304
9962
  const resource = resourceJSON[type].find((res) => res.fileName === fileName);
8305
9963
  if (!resource) {
8306
9964
  throw new Error(`Resource not found for file: ${fileName}`);
8307
9965
  }
8308
- const destination = join2(resourceOutDirectory, "resources");
9966
+ const destination = join4(resourceOutDirectory, "resources");
8309
9967
  const resourceName = resource.resourceIdentifier;
8310
9968
  return copyFile(filePath, destination, resourceName);
8311
9969
  });
8312
9970
  await Promise.all(copyOperations);
8313
9971
  for (const subDir of subdirectoriesToMirror) {
8314
- const srcPath = join2(resourceInDirectory, subDir);
8315
- const destPath = join2(resourceOutDirectory, "resources", subDir);
9972
+ const srcPath = join4(resourceInDirectory, subDir);
9973
+ const destPath = join4(resourceOutDirectory, "resources", subDir);
8316
9974
  await mirrorDirectory(srcPath, destPath);
8317
9975
  }
8318
9976
  logVerbose(`[Kit CLI] All resources have been processed.`);
@@ -8336,7 +9994,7 @@ async function buildBoundsJSON() {
8336
9994
  try {
8337
9995
  const fileBuffer = await fs2.readFile(filePath);
8338
9996
  const vyi = new VYI().parse(fileBuffer);
8339
- const atlasName = basename(filePath, ".vyi");
9997
+ const atlasName = basename3(filePath, ".vyi");
8340
9998
  const atlasEntry = {};
8341
9999
  for (const icon of vyi.getIcons()) {
8342
10000
  const iconName = icon.getName();
@@ -8388,7 +10046,7 @@ async function buildIconPointsJSON() {
8388
10046
  try {
8389
10047
  const fileBuffer = await fs2.readFile(filePath);
8390
10048
  const vyi = new VYI().parse(fileBuffer);
8391
- const atlasName = basename(filePath, ".vyi");
10049
+ const atlasName = basename3(filePath, ".vyi");
8392
10050
  const atlasEntry = {};
8393
10051
  for (const icon of vyi.getIcons()) {
8394
10052
  const iconName = icon.getName();
@@ -8458,7 +10116,7 @@ async function buildSizesJSON() {
8458
10116
  try {
8459
10117
  const fileBuffer = await fs2.readFile(filePath);
8460
10118
  const vyi = new VYI().parse(fileBuffer);
8461
- const atlasName = basename(filePath, ".vyi");
10119
+ const atlasName = basename3(filePath, ".vyi");
8462
10120
  const atlasEntry = {};
8463
10121
  for (const icon of vyi.getIcons()) {
8464
10122
  atlasEntry[icon.getName()] = {
@@ -8485,7 +10143,7 @@ async function saveSizesJSON(pSizesData) {
8485
10143
  }
8486
10144
  async function clearResourceTypeDirectories(pBaseDirectory) {
8487
10145
  try {
8488
- const directoryExists = await fs2.stat(pBaseDirectory).then((stat) => stat.isDirectory()).catch(() => false);
10146
+ const directoryExists = await fs2.stat(pBaseDirectory).then((stat4) => stat4.isDirectory()).catch(() => false);
8489
10147
  if (directoryExists) {
8490
10148
  await fs2.rm(pBaseDirectory, { recursive: true });
8491
10149
  }
@@ -8496,7 +10154,8 @@ async function clearResourceTypeDirectories(pBaseDirectory) {
8496
10154
  async function copyFile(pSource, pDestinationDir, pNewName) {
8497
10155
  try {
8498
10156
  await fs2.mkdir(pDestinationDir, { recursive: true });
8499
- await fs2.copyFile(pSource, join2(pDestinationDir, pNewName));
10157
+ const data = await fs2.readFile(pSource);
10158
+ await fs2.writeFile(join4(pDestinationDir, pNewName), data);
8500
10159
  } catch (pError) {
8501
10160
  logError(`[Error] Copying file ${pSource}: ${pError}`);
8502
10161
  }
@@ -8539,49 +10198,132 @@ async function runBuild() {
8539
10198
  }
8540
10199
  async function runWatch() {
8541
10200
  await runBuild();
10201
+ const pathsToWatch = [];
10202
+ if (existsSync2(resourceInDirectory)) {
10203
+ pathsToWatch.push(resourceInDirectory);
10204
+ }
10205
+ const srcDir = join4(projectRootDirectory, "src");
10206
+ if (shouldBundleApp && existsSync2(srcDir) && srcDir !== resourceInDirectory) {
10207
+ pathsToWatch.push(srcDir);
10208
+ }
10209
+ const displayPaths = pathsToWatch.map((p) => source_default.bold(relative3(projectRootDirectory, p) || p)).join(", ");
8542
10210
  console.log(source_default.cyan(`
8543
- Watching for changes in: ${source_default.bold(resourceInDirectory)}`));
10211
+ Watching for changes in: ${displayPaths}`));
8544
10212
  let debounceTimer = null;
10213
+ let isRebuilding = false;
10214
+ let queuedChange = null;
8545
10215
  const triggerRebuild = (pFilename) => {
8546
10216
  if (debounceTimer)
8547
10217
  clearTimeout(debounceTimer);
8548
10218
  debounceTimer = setTimeout(async () => {
8549
- console.log(source_default.dim(`
10219
+ if (isRebuilding) {
10220
+ queuedChange = pFilename;
10221
+ return;
10222
+ }
10223
+ isRebuilding = true;
10224
+ try {
10225
+ console.log(source_default.dim(`
8550
10226
  File changed: ${pFilename}, rebuilding...`));
8551
- await runBuild();
10227
+ await runBuild();
10228
+ } finally {
10229
+ isRebuilding = false;
10230
+ if (queuedChange) {
10231
+ const next = queuedChange;
10232
+ queuedChange = null;
10233
+ triggerRebuild(next);
10234
+ }
10235
+ }
8552
10236
  }, 150);
8553
10237
  };
8554
- const watchers = [];
8555
- if (existsSync2(resourceInDirectory)) {
8556
- const resWatcher = fsWatch(resourceInDirectory, { recursive: true }, (_eventType, pFilename) => {
8557
- if (pFilename)
8558
- triggerRebuild(pFilename);
8559
- });
8560
- watchers.push(resWatcher);
8561
- }
8562
- const srcDir = join2(projectRootDirectory, "src");
8563
- if (shouldBundleApp && existsSync2(srcDir) && srcDir !== resourceInDirectory) {
8564
- const srcWatcher = fsWatch(srcDir, { recursive: true }, (_eventType, pFilename) => {
8565
- if (!pFilename)
8566
- return;
8567
- if (pFilename.startsWith("resources"))
8568
- return;
8569
- triggerRebuild(pFilename);
8570
- });
8571
- watchers.push(srcWatcher);
10238
+ const normalizedOutDir = resourceOutDirectory ? resourceOutDirectory.replace(/\\/g, "/") : "";
10239
+ const isIgnored = (pPath) => {
10240
+ const normalized = pPath.replace(/\\/g, "/");
10241
+ if (normalizedOutDir && (normalized === normalizedOutDir || normalized.startsWith(`${normalizedOutDir}/`))) {
10242
+ return true;
10243
+ }
10244
+ if (/(^|[/\\])(\.git|node_modules|\.DS_Store|Thumbs\.db)($|[/\\])/.test(normalized)) {
10245
+ return true;
10246
+ }
10247
+ if (/(^|[/\\])vendor([/\\]|$)/.test(normalized)) {
10248
+ return true;
10249
+ }
10250
+ if (normalized.endsWith(".map")) {
10251
+ return true;
10252
+ }
10253
+ if (normalized.endsWith("resource.json") || normalized.endsWith("bounds.json") || normalized.endsWith("icon-points.json") || normalized.endsWith("sizes.json")) {
10254
+ return true;
10255
+ }
10256
+ return false;
10257
+ };
10258
+ const fileStats = new Map;
10259
+ const recordFileStat = async (pFilePath) => {
10260
+ try {
10261
+ const stats = await fs2.stat(pFilePath);
10262
+ if (stats.isFile()) {
10263
+ fileStats.set(resolve3(pFilePath), { mtime: stats.mtimeMs, size: stats.size });
10264
+ }
10265
+ } catch {
10266
+ }
10267
+ };
10268
+ const primeDirectoryStats = async (pDirPath) => {
10269
+ try {
10270
+ const entries = await fs2.readdir(pDirPath, { withFileTypes: true });
10271
+ for (const entry of entries) {
10272
+ const fullPath = join4(pDirPath, entry.name);
10273
+ if (isIgnored(fullPath))
10274
+ continue;
10275
+ if (entry.isDirectory()) {
10276
+ await primeDirectoryStats(fullPath);
10277
+ } else if (entry.isFile()) {
10278
+ await recordFileStat(fullPath);
10279
+ }
10280
+ }
10281
+ } catch {
10282
+ }
10283
+ };
10284
+ for (const p of pathsToWatch) {
10285
+ await primeDirectoryStats(p);
8572
10286
  }
8573
- process.on("SIGINT", () => {
8574
- for (const w of watchers)
8575
- w.close();
10287
+ const watcher = watch(pathsToWatch, {
10288
+ ignored: isIgnored,
10289
+ ignoreInitial: true,
10290
+ awaitWriteFinish: {
10291
+ stabilityThreshold: 100,
10292
+ pollInterval: 50
10293
+ }
10294
+ });
10295
+ watcher.on("all", async (event, filePath) => {
10296
+ if (event === "addDir" || event === "unlinkDir")
10297
+ return;
10298
+ const absPath = resolve3(filePath);
10299
+ if (event === "unlink") {
10300
+ fileStats.delete(absPath);
10301
+ const relativePath2 = relative3(projectRootDirectory, filePath).replace(/\\/g, "/");
10302
+ triggerRebuild(relativePath2);
10303
+ return;
10304
+ }
10305
+ const stats = await fs2.stat(absPath).catch(() => null);
10306
+ if (!stats)
10307
+ return;
10308
+ const prev = fileStats.get(absPath);
10309
+ if (prev && prev.mtime === stats.mtimeMs && prev.size === stats.size) {
10310
+ return;
10311
+ }
10312
+ fileStats.set(absPath, { mtime: stats.mtimeMs, size: stats.size });
10313
+ const relativePath = relative3(projectRootDirectory, filePath).replace(/\\/g, "/");
10314
+ triggerRebuild(relativePath);
10315
+ });
10316
+ process.on("SIGINT", async () => {
10317
+ await watcher.close();
8576
10318
  process.exit(0);
8577
10319
  });
8578
10320
  }
8579
- async function processResources({ inDirectory, outDirectory, manifestPath, watch, verbose, ignoreSound, app, minify, obfuscate, sourcemap, prod }) {
10321
+ async function processResources({ inDirectory, outDirectory, manifestPath, watch: watch2, verbose, ignoreSound, app, minify, obfuscate, sourcemap, prod }) {
8580
10322
  projectRootDirectory = process.cwd();
8581
- const resolvedIn = inDirectory || (existsSync2(join2(projectRootDirectory, "src", "resources")) ? "src/resources" : "");
10323
+ const resolvedIn = inDirectory || (existsSync2(join4(projectRootDirectory, "src", "resources")) ? "src/resources" : "");
8582
10324
  const resolvedOut = outDirectory || "dist";
8583
- resourceInDirectory = resolvedIn ? resolve(resolvedIn) : "";
8584
- resourceOutDirectory = resolvedOut ? resolve(resolvedOut) : "";
10325
+ resourceInDirectory = resolvedIn ? resolve3(resolvedIn) : "";
10326
+ resourceOutDirectory = resolvedOut ? resolve3(resolvedOut) : "";
8585
10327
  customManifestPath = manifestPath;
8586
10328
  isVerbose = verbose;
8587
10329
  ignoringSound = ignoreSound;
@@ -8591,13 +10333,13 @@ async function processResources({ inDirectory, outDirectory, manifestPath, watch
8591
10333
  sourcemap,
8592
10334
  prod
8593
10335
  };
8594
- const hasAppEntry = existsSync2(join2(projectRootDirectory, "src", "index.ts")) || existsSync2(join2(projectRootDirectory, "src", "client", "index.ts")) || existsSync2(join2(projectRootDirectory, "src", "server", "index.ts"));
10336
+ const hasAppEntry = existsSync2(join4(projectRootDirectory, "src", "index.ts")) || existsSync2(join4(projectRootDirectory, "src", "client", "index.ts")) || existsSync2(join4(projectRootDirectory, "src", "server", "index.ts"));
8595
10337
  shouldBundleApp = app !== undefined ? app : hasAppEntry;
8596
10338
  if (!resourceInDirectory || !resourceOutDirectory) {
8597
10339
  logError("[Error] Input and output directories must be specified");
8598
10340
  return;
8599
10341
  }
8600
- if (watch) {
10342
+ if (watch2) {
8601
10343
  await runWatch();
8602
10344
  } else {
8603
10345
  await runBuild();
@@ -9668,7 +11410,7 @@ import os2 from "os";
9668
11410
  // package.json
9669
11411
  var package_default = {
9670
11412
  name: "@evitcastudio/kit",
9671
- version: "3.2.2",
11413
+ version: "3.3.1",
9672
11414
  author: "doubleactii 56242467+doubleactii@users.noreply.github.com (https://evitcastudio.com)",
9673
11415
  main: "./lib/index.js",
9674
11416
  types: "./lib/index.d.ts",
@@ -9729,6 +11471,7 @@ var package_default = {
9729
11471
  dependencies: {
9730
11472
  "@clack/prompts": "^1.1.0",
9731
11473
  chalk: "^5.4.0",
11474
+ chokidar: "^5.0.0",
9732
11475
  commander: "^12.1.0",
9733
11476
  uuid: "^11.0.3"
9734
11477
  },
@@ -9758,8 +11501,8 @@ function checkBun() {
9758
11501
  return !result.error && result.status === 0;
9759
11502
  }
9760
11503
  function installBun() {
9761
- const isWindows = os2.platform() === "win32";
9762
- const command = isWindows ? 'powershell -c "irm bun.sh/install.ps1 | iex"' : "curl -fsSL https://bun.sh/install | bash";
11504
+ const isWindows2 = os2.platform() === "win32";
11505
+ const command = isWindows2 ? 'powershell -c "irm bun.sh/install.ps1 | iex"' : "curl -fsSL https://bun.sh/install | bash";
9763
11506
  try {
9764
11507
  execSync(command, { stdio: "inherit" });
9765
11508
  return true;
@@ -9957,7 +11700,7 @@ Error: Destination directory '${projectName}' already exists. Use --force (-f) t
9957
11700
  // src/cli/doctor.ts
9958
11701
  import { spawnSync as spawnSync2 } from "child_process";
9959
11702
  import { existsSync as existsSync3, readFileSync } from "fs";
9960
- import { join as join3 } from "path";
11703
+ import { join as join5 } from "path";
9961
11704
  async function processDoctor(pOptions = {}) {
9962
11705
  const isVerbose2 = Boolean(pOptions.verbose);
9963
11706
  const results = [];
@@ -9997,7 +11740,7 @@ async function processDoctor(pOptions = {}) {
9997
11740
  });
9998
11741
  }
9999
11742
  const cwd = process.cwd();
10000
- const pkgPath = join3(cwd, "package.json");
11743
+ const pkgPath = join5(cwd, "package.json");
10001
11744
  const hasPackageJson = existsSync3(pkgPath);
10002
11745
  if (hasPackageJson) {
10003
11746
  try {
@@ -10018,7 +11761,7 @@ async function processDoctor(pOptions = {}) {
10018
11761
  });
10019
11762
  const isKitCoreRepo = pkg.name === "@evitcastudio/kit";
10020
11763
  if (!isKitCoreRepo) {
10021
- const resourcesDir = join3(cwd, "src", "resources");
11764
+ const resourcesDir = join5(cwd, "src", "resources");
10022
11765
  const hasResources = existsSync3(resourcesDir);
10023
11766
  results.push({
10024
11767
  category: "Project",
@@ -10027,9 +11770,9 @@ async function processDoctor(pOptions = {}) {
10027
11770
  details: hasResources ? "Asset directory present" : "src/resources not found"
10028
11771
  });
10029
11772
  }
10030
- const hasClientEntry = existsSync3(join3(cwd, "src", "client", "index.ts"));
10031
- const hasServerEntry = existsSync3(join3(cwd, "src", "server", "index.ts"));
10032
- const hasSingleEntry = existsSync3(join3(cwd, "src", "index.ts"));
11773
+ const hasClientEntry = existsSync3(join5(cwd, "src", "client", "index.ts"));
11774
+ const hasServerEntry = existsSync3(join5(cwd, "src", "server", "index.ts"));
11775
+ const hasSingleEntry = existsSync3(join5(cwd, "src", "index.ts"));
10033
11776
  let projectType = "Unknown";
10034
11777
  if (hasClientEntry && hasServerEntry) {
10035
11778
  projectType = "Multiplayer (Client & Server)";
@@ -10054,7 +11797,7 @@ async function processDoctor(pOptions = {}) {
10054
11797
  details: "package.json is malformed or invalid JSON"
10055
11798
  });
10056
11799
  }
10057
- const buildScript = join3(cwd, "bun-build.ts");
11800
+ const buildScript = join5(cwd, "bun-build.ts");
10058
11801
  const hasBuildScript = existsSync3(buildScript);
10059
11802
  let hasKitBuildScript = false;
10060
11803
  try {
@@ -10114,7 +11857,7 @@ async function processDoctor(pOptions = {}) {
10114
11857
 
10115
11858
  // src/cli/create.ts
10116
11859
  import { promises as fs4 } from "fs";
10117
- import { join as join4 } from "path";
11860
+ import { join as join6 } from "path";
10118
11861
  function toPascalCase(pName) {
10119
11862
  return pName.replace(/[-_](\w)/g, (_2, c) => c.toUpperCase()).replace(/^\w/, (c) => c.toUpperCase());
10120
11863
  }
@@ -10157,8 +11900,8 @@ Error: Unknown create type '${type}'. Supported types: 'plugin'`));
10157
11900
  }
10158
11901
  const className = toPascalCase(name);
10159
11902
  const fileName = `${toKebabCase(name)}.ts`;
10160
- const pluginsDir = join4(process.cwd(), "src", "plugins");
10161
- const targetPath = join4(pluginsDir, fileName);
11903
+ const pluginsDir = join6(process.cwd(), "src", "plugins");
11904
+ const targetPath = join6(pluginsDir, fileName);
10162
11905
  try {
10163
11906
  await fs4.mkdir(pluginsDir, { recursive: true });
10164
11907
  const fileExists = await fs4.stat(targetPath).then(() => true).catch(() => false);
@@ -10185,7 +11928,7 @@ Error creating plugin: ${message}`));
10185
11928
 
10186
11929
  // src/cli/host.ts
10187
11930
  import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
10188
- import { join as join5, resolve as resolve2 } from "path";
11931
+ import { join as join7, resolve as resolve4 } from "path";
10189
11932
  import { networkInterfaces } from "os";
10190
11933
  function getNetworkAddress() {
10191
11934
  const interfaces = networkInterfaces();
@@ -10205,8 +11948,8 @@ async function processHost(pOptions = {}) {
10205
11948
  const cwd = process.cwd();
10206
11949
  const defaultPort = 8090;
10207
11950
  const port = pOptions.port || defaultPort;
10208
- const distDir = pOptions.directory ? resolve2(pOptions.directory) : join5(cwd, "dist");
10209
- const architecture = detectArchitecture(join5(cwd, "src"));
11951
+ const distDir = pOptions.directory ? resolve4(pOptions.directory) : join7(cwd, "dist");
11952
+ const architecture = detectArchitecture(join7(cwd, "src"));
10210
11953
  if (!existsSync4(distDir)) {
10211
11954
  const message = `Target directory "${distDir}" does not exist. Run "kit build" or use "kit host -b" first.`;
10212
11955
  console.error(source_default.red(`
@@ -10215,7 +11958,7 @@ async function processHost(pOptions = {}) {
10215
11958
  return { success: false, message };
10216
11959
  }
10217
11960
  if (architecture === "multi") {
10218
- const serverJsPath = join5(distDir, "server.js");
11961
+ const serverJsPath = join7(distDir, "server.js");
10219
11962
  if (!existsSync4(serverJsPath)) {
10220
11963
  const message = `Cannot host multiplayer project: "${serverJsPath}" was not found. Please compile the server first using "kit build".`;
10221
11964
  console.error(source_default.red(`
@@ -10227,7 +11970,7 @@ async function processHost(pOptions = {}) {
10227
11970
  Starting Multiplayer Server from ${source_default.bold(distDir)}...
10228
11971
  `));
10229
11972
  let serverSettingsPort = port;
10230
- const settingsPath = join5(distDir, "settings.json");
11973
+ const settingsPath = join7(distDir, "settings.json");
10231
11974
  if (existsSync4(settingsPath)) {
10232
11975
  try {
10233
11976
  const settings = JSON.parse(readFileSync2(settingsPath, "utf8"));
@@ -10254,7 +11997,7 @@ Starting Multiplayer Server from ${source_default.bold(distDir)}...
10254
11997
  await proc.exited;
10255
11998
  return { success: true, message: "Multiplayer server finished running." };
10256
11999
  }
10257
- const indexPath = join5(distDir, "index.html");
12000
+ const indexPath = join7(distDir, "index.html");
10258
12001
  if (!existsSync4(indexPath)) {
10259
12002
  const message = `Missing entrypoint: "${indexPath}" was not found in dist. Run "kit build" or use "kit host -b" to compile.`;
10260
12003
  console.error(source_default.red(`
@@ -10268,7 +12011,7 @@ Starting Multiplayer Server from ${source_default.bold(distDir)}...
10268
12011
  async fetch(pReq) {
10269
12012
  const path2 = new URL(pReq.url).pathname;
10270
12013
  const target = path2 === "/" ? "/index.html" : decodeURIComponent(path2);
10271
- const file = Bun.file(join5(distDir, target));
12014
+ const file = Bun.file(join7(distDir, target));
10272
12015
  if (!await file.exists()) {
10273
12016
  if (pOptions.verbose) {
10274
12017
  console.warn(source_default.yellow(`[Kit Host] 404 Not Found: ${target}`));