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