agent-web-os 0.1.1 → 0.1.3
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/README.md +80 -0
- package/README.zh-CN.md +80 -0
- package/dist/index.cjs +552 -489
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +457 -396
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2134,16 +2134,16 @@ var Diff = class {
|
|
|
2134
2134
|
}
|
|
2135
2135
|
}
|
|
2136
2136
|
}
|
|
2137
|
-
addToPath(
|
|
2138
|
-
const last =
|
|
2137
|
+
addToPath(path2, added, removed, oldPosInc, options2) {
|
|
2138
|
+
const last = path2.lastComponent;
|
|
2139
2139
|
if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
2140
2140
|
return {
|
|
2141
|
-
oldPos:
|
|
2141
|
+
oldPos: path2.oldPos + oldPosInc,
|
|
2142
2142
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
2143
2143
|
};
|
|
2144
2144
|
} else {
|
|
2145
2145
|
return {
|
|
2146
|
-
oldPos:
|
|
2146
|
+
oldPos: path2.oldPos + oldPosInc,
|
|
2147
2147
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
2148
2148
|
};
|
|
2149
2149
|
}
|
|
@@ -36465,8 +36465,71 @@ function G7(e10) {
|
|
|
36465
36465
|
}
|
|
36466
36466
|
}
|
|
36467
36467
|
|
|
36468
|
+
// src/posix-path.ts
|
|
36469
|
+
function normalize(p) {
|
|
36470
|
+
if (p === "") return ".";
|
|
36471
|
+
const isAbsolute2 = p.charCodeAt(0) === 47;
|
|
36472
|
+
const trailingSlash = p.charCodeAt(p.length - 1) === 47;
|
|
36473
|
+
const segments = [];
|
|
36474
|
+
for (const seg of p.split("/")) {
|
|
36475
|
+
if (seg === ".." && segments.length > 0 && segments[segments.length - 1] !== "..") {
|
|
36476
|
+
segments.pop();
|
|
36477
|
+
} else if (seg !== "." && seg !== "") {
|
|
36478
|
+
segments.push(seg);
|
|
36479
|
+
}
|
|
36480
|
+
}
|
|
36481
|
+
let result = segments.join("/");
|
|
36482
|
+
if (isAbsolute2) result = "/" + result;
|
|
36483
|
+
if (trailingSlash && result.length > 1) result += "/";
|
|
36484
|
+
return result || (isAbsolute2 ? "/" : ".");
|
|
36485
|
+
}
|
|
36486
|
+
function join3(...parts) {
|
|
36487
|
+
return normalize(parts.filter(Boolean).join("/"));
|
|
36488
|
+
}
|
|
36489
|
+
function resolve2(...parts) {
|
|
36490
|
+
let resolved = "";
|
|
36491
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
36492
|
+
const p = parts[i];
|
|
36493
|
+
if (!p) continue;
|
|
36494
|
+
resolved = resolved ? p + "/" + resolved : p;
|
|
36495
|
+
if (p.charCodeAt(0) === 47) break;
|
|
36496
|
+
}
|
|
36497
|
+
return normalize(resolved || "/");
|
|
36498
|
+
}
|
|
36499
|
+
function dirname3(p) {
|
|
36500
|
+
if (p === "" || p === "/") return p || ".";
|
|
36501
|
+
const i = p.lastIndexOf("/");
|
|
36502
|
+
if (i === -1) return ".";
|
|
36503
|
+
if (i === 0) return "/";
|
|
36504
|
+
return p.slice(0, i);
|
|
36505
|
+
}
|
|
36506
|
+
function basename(p, ext2) {
|
|
36507
|
+
let base = p.slice(p.lastIndexOf("/") + 1);
|
|
36508
|
+
if (ext2 && base.endsWith(ext2)) {
|
|
36509
|
+
base = base.slice(0, -ext2.length);
|
|
36510
|
+
}
|
|
36511
|
+
return base;
|
|
36512
|
+
}
|
|
36513
|
+
function relative2(from, to2) {
|
|
36514
|
+
from = resolve2(from);
|
|
36515
|
+
to2 = resolve2(to2);
|
|
36516
|
+
if (from === to2) return "";
|
|
36517
|
+
const fromParts = from.split("/").filter(Boolean);
|
|
36518
|
+
const toParts = to2.split("/").filter(Boolean);
|
|
36519
|
+
let common = 0;
|
|
36520
|
+
while (common < fromParts.length && common < toParts.length && fromParts[common] === toParts[common]) {
|
|
36521
|
+
common++;
|
|
36522
|
+
}
|
|
36523
|
+
const ups = fromParts.length - common;
|
|
36524
|
+
const remaining = toParts.slice(common);
|
|
36525
|
+
return [...Array(ups).fill(".."), ...remaining].join("/");
|
|
36526
|
+
}
|
|
36527
|
+
function isAbsolute(p) {
|
|
36528
|
+
return p.length > 0 && p.charCodeAt(0) === 47;
|
|
36529
|
+
}
|
|
36530
|
+
var posixPath = { normalize, join: join3, resolve: resolve2, dirname: dirname3, basename, relative: relative2, isAbsolute };
|
|
36531
|
+
|
|
36468
36532
|
// src/observable-in-memory-fs.ts
|
|
36469
|
-
import path2 from "path";
|
|
36470
36533
|
function isObservableInMemoryFsLike(value) {
|
|
36471
36534
|
if (!value || typeof value !== "object") {
|
|
36472
36535
|
return false;
|
|
@@ -36493,18 +36556,18 @@ function normalizeEntryType(stat) {
|
|
|
36493
36556
|
}
|
|
36494
36557
|
return "file";
|
|
36495
36558
|
}
|
|
36496
|
-
async function readPathState(fs,
|
|
36497
|
-
const exists = await fs.exists(
|
|
36559
|
+
async function readPathState(fs, path2) {
|
|
36560
|
+
const exists = await fs.exists(path2);
|
|
36498
36561
|
if (!exists) {
|
|
36499
36562
|
return { exists: false };
|
|
36500
36563
|
}
|
|
36501
|
-
if (isObservableInMemoryFsLike(fs) && fs.isPathLazy(
|
|
36564
|
+
if (isObservableInMemoryFsLike(fs) && fs.isPathLazy(path2)) {
|
|
36502
36565
|
return {
|
|
36503
36566
|
exists: true,
|
|
36504
36567
|
entryType: "file"
|
|
36505
36568
|
};
|
|
36506
36569
|
}
|
|
36507
|
-
const stat = await fs.lstat(
|
|
36570
|
+
const stat = await fs.lstat(path2);
|
|
36508
36571
|
return {
|
|
36509
36572
|
exists: true,
|
|
36510
36573
|
entryType: normalizeEntryType(stat)
|
|
@@ -36517,7 +36580,7 @@ function mapUnlinkEvent(entryType) {
|
|
|
36517
36580
|
return entryType === "directory" ? "unlinkDir" : "unlink";
|
|
36518
36581
|
}
|
|
36519
36582
|
function normalizeFsPathForLogScope(fsPath) {
|
|
36520
|
-
const normalized =
|
|
36583
|
+
const normalized = posixPath.normalize(fsPath);
|
|
36521
36584
|
return normalized === "." ? "/" : normalized;
|
|
36522
36585
|
}
|
|
36523
36586
|
function createWorkspacePathFilter(workspaceRoot) {
|
|
@@ -36527,7 +36590,7 @@ function createWorkspacePathFilter(workspaceRoot) {
|
|
|
36527
36590
|
if (normalizedPath !== normalizedWorkspaceRoot && !normalizedPath.startsWith(`${normalizedWorkspaceRoot}/`)) {
|
|
36528
36591
|
return false;
|
|
36529
36592
|
}
|
|
36530
|
-
const relativePath =
|
|
36593
|
+
const relativePath = posixPath.relative(normalizedWorkspaceRoot, normalizedPath);
|
|
36531
36594
|
if (!relativePath || relativePath === ".") {
|
|
36532
36595
|
return true;
|
|
36533
36596
|
}
|
|
@@ -36641,124 +36704,124 @@ var ObservableInMemoryFs = class extends Ir {
|
|
|
36641
36704
|
this.suppressSyncEventCount -= 1;
|
|
36642
36705
|
}
|
|
36643
36706
|
}
|
|
36644
|
-
writeFileSync(
|
|
36645
|
-
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this,
|
|
36646
|
-
super.writeFileSync(
|
|
36647
|
-
this.clearLazyPath(
|
|
36707
|
+
writeFileSync(path2, content, options2, metadata) {
|
|
36708
|
+
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this, path2);
|
|
36709
|
+
super.writeFileSync(path2, content, options2, metadata);
|
|
36710
|
+
this.clearLazyPath(path2);
|
|
36648
36711
|
if (!previous) {
|
|
36649
36712
|
return;
|
|
36650
36713
|
}
|
|
36651
|
-
this.queueChangeEmission(previous.then((state) => this.emitWriteEvent(
|
|
36714
|
+
this.queueChangeEmission(previous.then((state) => this.emitWriteEvent(path2, state)));
|
|
36652
36715
|
}
|
|
36653
|
-
writeFileLazy(
|
|
36654
|
-
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this,
|
|
36655
|
-
super.writeFileLazy(
|
|
36656
|
-
this.lazyPaths.add(normalizeFsPathForLogScope(
|
|
36716
|
+
writeFileLazy(path2, lazy, metadata) {
|
|
36717
|
+
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this, path2);
|
|
36718
|
+
super.writeFileLazy(path2, lazy, metadata);
|
|
36719
|
+
this.lazyPaths.add(normalizeFsPathForLogScope(path2));
|
|
36657
36720
|
if (!previous) {
|
|
36658
36721
|
return;
|
|
36659
36722
|
}
|
|
36660
|
-
this.queueChangeEmission(previous.then((state) => this.emitWriteEvent(
|
|
36723
|
+
this.queueChangeEmission(previous.then((state) => this.emitWriteEvent(path2, state)));
|
|
36661
36724
|
}
|
|
36662
|
-
async emitWriteEvent(
|
|
36663
|
-
const current2 = await readPathState(this,
|
|
36725
|
+
async emitWriteEvent(path2, previous) {
|
|
36726
|
+
const current2 = await readPathState(this, path2);
|
|
36664
36727
|
if (!current2.exists || !current2.entryType) {
|
|
36665
36728
|
return;
|
|
36666
36729
|
}
|
|
36667
36730
|
if (!previous.exists) {
|
|
36668
36731
|
this.emit({
|
|
36669
36732
|
event: mapAddEvent(current2.entryType),
|
|
36670
|
-
path:
|
|
36733
|
+
path: path2,
|
|
36671
36734
|
entryType: current2.entryType
|
|
36672
36735
|
});
|
|
36673
36736
|
return;
|
|
36674
36737
|
}
|
|
36675
36738
|
this.emit({
|
|
36676
36739
|
event: "change",
|
|
36677
|
-
path:
|
|
36740
|
+
path: path2,
|
|
36678
36741
|
entryType: current2.entryType
|
|
36679
36742
|
});
|
|
36680
36743
|
}
|
|
36681
|
-
async emitMkdirEvent(
|
|
36682
|
-
const current2 = await readPathState(this,
|
|
36744
|
+
async emitMkdirEvent(path2, previous) {
|
|
36745
|
+
const current2 = await readPathState(this, path2);
|
|
36683
36746
|
if (!current2.exists || current2.entryType !== "directory" || previous.exists) {
|
|
36684
36747
|
return;
|
|
36685
36748
|
}
|
|
36686
36749
|
this.emit({
|
|
36687
36750
|
event: "addDir",
|
|
36688
|
-
path:
|
|
36751
|
+
path: path2,
|
|
36689
36752
|
entryType: "directory"
|
|
36690
36753
|
});
|
|
36691
36754
|
}
|
|
36692
|
-
emitRemovalEvent(
|
|
36755
|
+
emitRemovalEvent(path2, previous, options2) {
|
|
36693
36756
|
if (!previous.exists || !previous.entryType) {
|
|
36694
36757
|
return;
|
|
36695
36758
|
}
|
|
36696
36759
|
this.emit({
|
|
36697
36760
|
event: mapUnlinkEvent(previous.entryType),
|
|
36698
|
-
path:
|
|
36761
|
+
path: path2,
|
|
36699
36762
|
entryType: previous.entryType
|
|
36700
36763
|
}, options2);
|
|
36701
36764
|
}
|
|
36702
|
-
mkdirSync(
|
|
36703
|
-
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this,
|
|
36704
|
-
super.mkdirSync(
|
|
36765
|
+
mkdirSync(path2, options2) {
|
|
36766
|
+
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this, path2);
|
|
36767
|
+
super.mkdirSync(path2, options2);
|
|
36705
36768
|
if (!previous) {
|
|
36706
36769
|
return;
|
|
36707
36770
|
}
|
|
36708
|
-
this.queueChangeEmission(previous.then((state) => this.emitMkdirEvent(
|
|
36771
|
+
this.queueChangeEmission(previous.then((state) => this.emitMkdirEvent(path2, state)));
|
|
36709
36772
|
}
|
|
36710
|
-
async readFileBuffer(
|
|
36711
|
-
const content = await super.readFileBuffer(
|
|
36712
|
-
this.clearLazyPath(
|
|
36773
|
+
async readFileBuffer(path2) {
|
|
36774
|
+
const content = await super.readFileBuffer(path2);
|
|
36775
|
+
this.clearLazyPath(path2);
|
|
36713
36776
|
return content;
|
|
36714
36777
|
}
|
|
36715
|
-
async stat(
|
|
36716
|
-
const stat = await super.stat(
|
|
36717
|
-
this.clearLazyPath(
|
|
36778
|
+
async stat(path2) {
|
|
36779
|
+
const stat = await super.stat(path2);
|
|
36780
|
+
this.clearLazyPath(path2);
|
|
36718
36781
|
return stat;
|
|
36719
36782
|
}
|
|
36720
|
-
async lstat(
|
|
36721
|
-
const stat = await super.lstat(
|
|
36722
|
-
this.clearLazyPath(
|
|
36783
|
+
async lstat(path2) {
|
|
36784
|
+
const stat = await super.lstat(path2);
|
|
36785
|
+
this.clearLazyPath(path2);
|
|
36723
36786
|
return stat;
|
|
36724
36787
|
}
|
|
36725
|
-
async writeFile(
|
|
36788
|
+
async writeFile(path2, content, options2) {
|
|
36726
36789
|
if (!this.shouldEmitChanges()) {
|
|
36727
|
-
await super.writeFile(
|
|
36790
|
+
await super.writeFile(path2, content, options2);
|
|
36728
36791
|
return;
|
|
36729
36792
|
}
|
|
36730
|
-
const previous = await readPathState(this,
|
|
36731
|
-
await this.runWithSuppressedSyncEvents(() => super.writeFile(
|
|
36732
|
-
await this.emitWriteEvent(
|
|
36793
|
+
const previous = await readPathState(this, path2);
|
|
36794
|
+
await this.runWithSuppressedSyncEvents(() => super.writeFile(path2, content, options2));
|
|
36795
|
+
await this.emitWriteEvent(path2, previous);
|
|
36733
36796
|
}
|
|
36734
|
-
async appendFile(
|
|
36797
|
+
async appendFile(path2, content, options2) {
|
|
36735
36798
|
if (!this.shouldEmitChanges()) {
|
|
36736
|
-
await super.appendFile(
|
|
36799
|
+
await super.appendFile(path2, content, options2);
|
|
36737
36800
|
return;
|
|
36738
36801
|
}
|
|
36739
|
-
const previous = await readPathState(this,
|
|
36740
|
-
await this.runWithSuppressedSyncEvents(() => super.appendFile(
|
|
36741
|
-
await this.emitWriteEvent(
|
|
36802
|
+
const previous = await readPathState(this, path2);
|
|
36803
|
+
await this.runWithSuppressedSyncEvents(() => super.appendFile(path2, content, options2));
|
|
36804
|
+
await this.emitWriteEvent(path2, previous);
|
|
36742
36805
|
}
|
|
36743
|
-
async mkdir(
|
|
36806
|
+
async mkdir(path2, options2) {
|
|
36744
36807
|
if (!this.shouldEmitChanges()) {
|
|
36745
|
-
await super.mkdir(
|
|
36808
|
+
await super.mkdir(path2, options2);
|
|
36746
36809
|
return;
|
|
36747
36810
|
}
|
|
36748
|
-
const previous = await readPathState(this,
|
|
36749
|
-
await this.runWithSuppressedSyncEvents(() => super.mkdir(
|
|
36750
|
-
await this.emitMkdirEvent(
|
|
36811
|
+
const previous = await readPathState(this, path2);
|
|
36812
|
+
await this.runWithSuppressedSyncEvents(() => super.mkdir(path2, options2));
|
|
36813
|
+
await this.emitMkdirEvent(path2, previous);
|
|
36751
36814
|
}
|
|
36752
|
-
async rm(
|
|
36815
|
+
async rm(path2, options2) {
|
|
36753
36816
|
if (!this.shouldEmitChanges()) {
|
|
36754
|
-
await super.rm(
|
|
36755
|
-
this.clearLazyPathsUnder(
|
|
36817
|
+
await super.rm(path2, options2);
|
|
36818
|
+
this.clearLazyPathsUnder(path2);
|
|
36756
36819
|
return;
|
|
36757
36820
|
}
|
|
36758
|
-
const previous = await readPathState(this,
|
|
36759
|
-
await super.rm(
|
|
36760
|
-
this.clearLazyPathsUnder(
|
|
36761
|
-
this.emitRemovalEvent(
|
|
36821
|
+
const previous = await readPathState(this, path2);
|
|
36822
|
+
await super.rm(path2, options2);
|
|
36823
|
+
this.clearLazyPathsUnder(path2);
|
|
36824
|
+
this.emitRemovalEvent(path2, previous);
|
|
36762
36825
|
}
|
|
36763
36826
|
async cp(src, dest, options2) {
|
|
36764
36827
|
if (!this.shouldEmitChanges()) {
|
|
@@ -36831,19 +36894,19 @@ var ObservableInMemoryFs = class extends Ir {
|
|
|
36831
36894
|
shouldConsoleLog: shouldConsoleLogMove
|
|
36832
36895
|
});
|
|
36833
36896
|
}
|
|
36834
|
-
async chmod(
|
|
36897
|
+
async chmod(path2, mode) {
|
|
36835
36898
|
if (!this.shouldEmitChanges()) {
|
|
36836
|
-
await super.chmod(
|
|
36899
|
+
await super.chmod(path2, mode);
|
|
36837
36900
|
return;
|
|
36838
36901
|
}
|
|
36839
|
-
await super.chmod(
|
|
36840
|
-
const current2 = await readPathState(this,
|
|
36902
|
+
await super.chmod(path2, mode);
|
|
36903
|
+
const current2 = await readPathState(this, path2);
|
|
36841
36904
|
if (!current2.exists || !current2.entryType) {
|
|
36842
36905
|
return;
|
|
36843
36906
|
}
|
|
36844
36907
|
this.emit({
|
|
36845
36908
|
event: "change",
|
|
36846
|
-
path:
|
|
36909
|
+
path: path2,
|
|
36847
36910
|
entryType: current2.entryType
|
|
36848
36911
|
});
|
|
36849
36912
|
}
|
|
@@ -36865,27 +36928,24 @@ var ObservableInMemoryFs = class extends Ir {
|
|
|
36865
36928
|
await super.link(existingPath, newPath);
|
|
36866
36929
|
await this.emitWriteEvent(newPath, previous);
|
|
36867
36930
|
}
|
|
36868
|
-
async utimes(
|
|
36931
|
+
async utimes(path2, atime, mtime) {
|
|
36869
36932
|
if (!this.shouldEmitChanges()) {
|
|
36870
|
-
await super.utimes(
|
|
36933
|
+
await super.utimes(path2, atime, mtime);
|
|
36871
36934
|
return;
|
|
36872
36935
|
}
|
|
36873
|
-
await super.utimes(
|
|
36874
|
-
const current2 = await readPathState(this,
|
|
36936
|
+
await super.utimes(path2, atime, mtime);
|
|
36937
|
+
const current2 = await readPathState(this, path2);
|
|
36875
36938
|
if (!current2.exists || !current2.entryType) {
|
|
36876
36939
|
return;
|
|
36877
36940
|
}
|
|
36878
36941
|
this.emit({
|
|
36879
36942
|
event: "change",
|
|
36880
|
-
path:
|
|
36943
|
+
path: path2,
|
|
36881
36944
|
entryType: current2.entryType
|
|
36882
36945
|
});
|
|
36883
36946
|
}
|
|
36884
36947
|
};
|
|
36885
36948
|
|
|
36886
|
-
// src/almostnode-session.ts
|
|
36887
|
-
import path3 from "path";
|
|
36888
|
-
|
|
36889
36949
|
// node_modules/almostnode/src/utils/hash.ts
|
|
36890
36950
|
function simpleHash(str) {
|
|
36891
36951
|
let hash = 0;
|
|
@@ -36929,7 +36989,7 @@ function uint8ToBinaryString(bytes) {
|
|
|
36929
36989
|
}
|
|
36930
36990
|
|
|
36931
36991
|
// node_modules/almostnode/src/virtual-fs.ts
|
|
36932
|
-
function createNodeError(code2, syscall,
|
|
36992
|
+
function createNodeError(code2, syscall, path2, message) {
|
|
36933
36993
|
const errno = {
|
|
36934
36994
|
ENOENT: -2,
|
|
36935
36995
|
ENOTDIR: -20,
|
|
@@ -36945,12 +37005,12 @@ function createNodeError(code2, syscall, path4, message) {
|
|
|
36945
37005
|
ENOTEMPTY: "directory not empty"
|
|
36946
37006
|
};
|
|
36947
37007
|
const err = new Error(
|
|
36948
|
-
message || `${code2}: ${messages[code2]}, ${syscall} '${
|
|
37008
|
+
message || `${code2}: ${messages[code2]}, ${syscall} '${path2}'`
|
|
36949
37009
|
);
|
|
36950
37010
|
err.code = code2;
|
|
36951
37011
|
err.errno = errno[code2];
|
|
36952
37012
|
err.syscall = syscall;
|
|
36953
|
-
err.path =
|
|
37013
|
+
err.path = path2;
|
|
36954
37014
|
return err;
|
|
36955
37015
|
}
|
|
36956
37016
|
var VirtualFS = class _VirtualFS {
|
|
@@ -37000,18 +37060,18 @@ var VirtualFS = class _VirtualFS {
|
|
|
37000
37060
|
this.serializeNode("/", this.root, files);
|
|
37001
37061
|
return { files };
|
|
37002
37062
|
}
|
|
37003
|
-
serializeNode(
|
|
37063
|
+
serializeNode(path2, node, files) {
|
|
37004
37064
|
if (node.type === "file") {
|
|
37005
37065
|
let content = "";
|
|
37006
37066
|
if (node.content && node.content.length > 0) {
|
|
37007
37067
|
content = uint8ToBase64(node.content);
|
|
37008
37068
|
}
|
|
37009
|
-
files.push({ path:
|
|
37069
|
+
files.push({ path: path2, type: "file", content });
|
|
37010
37070
|
} else if (node.type === "directory") {
|
|
37011
|
-
files.push({ path:
|
|
37071
|
+
files.push({ path: path2, type: "directory" });
|
|
37012
37072
|
if (node.children) {
|
|
37013
37073
|
for (const [name, child] of node.children) {
|
|
37014
|
-
const childPath =
|
|
37074
|
+
const childPath = path2 === "/" ? `/${name}` : `${path2}/${name}`;
|
|
37015
37075
|
this.serializeNode(childPath, child, files);
|
|
37016
37076
|
}
|
|
37017
37077
|
}
|
|
@@ -37046,17 +37106,17 @@ var VirtualFS = class _VirtualFS {
|
|
|
37046
37106
|
/**
|
|
37047
37107
|
* Internal write that optionally emits events
|
|
37048
37108
|
*/
|
|
37049
|
-
writeFileSyncInternal(
|
|
37050
|
-
const normalized = this.normalizePath(
|
|
37109
|
+
writeFileSyncInternal(path2, data2, emitEvent) {
|
|
37110
|
+
const normalized = this.normalizePath(path2);
|
|
37051
37111
|
const parentPath = this.getParentPath(normalized);
|
|
37052
|
-
const
|
|
37053
|
-
if (!
|
|
37054
|
-
throw new Error(`EISDIR: illegal operation on a directory, '${
|
|
37112
|
+
const basename2 = this.getBasename(normalized);
|
|
37113
|
+
if (!basename2) {
|
|
37114
|
+
throw new Error(`EISDIR: illegal operation on a directory, '${path2}'`);
|
|
37055
37115
|
}
|
|
37056
37116
|
const parent = this.ensureDirectory(parentPath);
|
|
37057
|
-
const existed = parent.children.has(
|
|
37117
|
+
const existed = parent.children.has(basename2);
|
|
37058
37118
|
const content = typeof data2 === "string" ? this.encoder.encode(data2) : data2;
|
|
37059
|
-
parent.children.set(
|
|
37119
|
+
parent.children.set(basename2, {
|
|
37060
37120
|
type: "file",
|
|
37061
37121
|
content,
|
|
37062
37122
|
mtime: Date.now()
|
|
@@ -37069,11 +37129,11 @@ var VirtualFS = class _VirtualFS {
|
|
|
37069
37129
|
/**
|
|
37070
37130
|
* Normalize path - resolve . and .. segments, ensure leading /
|
|
37071
37131
|
*/
|
|
37072
|
-
normalizePath(
|
|
37073
|
-
if (!
|
|
37074
|
-
|
|
37132
|
+
normalizePath(path2) {
|
|
37133
|
+
if (!path2.startsWith("/")) {
|
|
37134
|
+
path2 = "/" + path2;
|
|
37075
37135
|
}
|
|
37076
|
-
const parts =
|
|
37136
|
+
const parts = path2.split("/").filter(Boolean);
|
|
37077
37137
|
const resolved = [];
|
|
37078
37138
|
for (const part of parts) {
|
|
37079
37139
|
if (part === "..") {
|
|
@@ -37087,30 +37147,30 @@ var VirtualFS = class _VirtualFS {
|
|
|
37087
37147
|
/**
|
|
37088
37148
|
* Get path segments from normalized path
|
|
37089
37149
|
*/
|
|
37090
|
-
getPathSegments(
|
|
37091
|
-
return this.normalizePath(
|
|
37150
|
+
getPathSegments(path2) {
|
|
37151
|
+
return this.normalizePath(path2).split("/").filter(Boolean);
|
|
37092
37152
|
}
|
|
37093
37153
|
/**
|
|
37094
37154
|
* Get parent directory path
|
|
37095
37155
|
*/
|
|
37096
|
-
getParentPath(
|
|
37097
|
-
const normalized = this.normalizePath(
|
|
37156
|
+
getParentPath(path2) {
|
|
37157
|
+
const normalized = this.normalizePath(path2);
|
|
37098
37158
|
const lastSlash = normalized.lastIndexOf("/");
|
|
37099
37159
|
return lastSlash <= 0 ? "/" : normalized.slice(0, lastSlash);
|
|
37100
37160
|
}
|
|
37101
37161
|
/**
|
|
37102
37162
|
* Get basename from path
|
|
37103
37163
|
*/
|
|
37104
|
-
getBasename(
|
|
37105
|
-
const normalized = this.normalizePath(
|
|
37164
|
+
getBasename(path2) {
|
|
37165
|
+
const normalized = this.normalizePath(path2);
|
|
37106
37166
|
const lastSlash = normalized.lastIndexOf("/");
|
|
37107
37167
|
return normalized.slice(lastSlash + 1);
|
|
37108
37168
|
}
|
|
37109
37169
|
/**
|
|
37110
37170
|
* Get node at path, returns undefined if not found
|
|
37111
37171
|
*/
|
|
37112
|
-
getNode(
|
|
37113
|
-
const segments = this.getPathSegments(
|
|
37172
|
+
getNode(path2) {
|
|
37173
|
+
const segments = this.getPathSegments(path2);
|
|
37114
37174
|
let current2 = this.root;
|
|
37115
37175
|
for (const segment of segments) {
|
|
37116
37176
|
if (current2.type !== "directory" || !current2.children) {
|
|
@@ -37127,8 +37187,8 @@ var VirtualFS = class _VirtualFS {
|
|
|
37127
37187
|
/**
|
|
37128
37188
|
* Get or create directory at path (for mkdir -p behavior)
|
|
37129
37189
|
*/
|
|
37130
|
-
ensureDirectory(
|
|
37131
|
-
const segments = this.getPathSegments(
|
|
37190
|
+
ensureDirectory(path2) {
|
|
37191
|
+
const segments = this.getPathSegments(path2);
|
|
37132
37192
|
let current2 = this.root;
|
|
37133
37193
|
for (const segment of segments) {
|
|
37134
37194
|
if (!current2.children) {
|
|
@@ -37139,7 +37199,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
37139
37199
|
child = { type: "directory", children: /* @__PURE__ */ new Map(), mtime: Date.now() };
|
|
37140
37200
|
current2.children.set(segment, child);
|
|
37141
37201
|
} else if (child.type !== "directory") {
|
|
37142
|
-
throw new Error(`ENOTDIR: not a directory, '${
|
|
37202
|
+
throw new Error(`ENOTDIR: not a directory, '${path2}'`);
|
|
37143
37203
|
}
|
|
37144
37204
|
current2 = child;
|
|
37145
37205
|
}
|
|
@@ -37148,16 +37208,16 @@ var VirtualFS = class _VirtualFS {
|
|
|
37148
37208
|
/**
|
|
37149
37209
|
* Check if path exists
|
|
37150
37210
|
*/
|
|
37151
|
-
existsSync(
|
|
37152
|
-
return this.getNode(
|
|
37211
|
+
existsSync(path2) {
|
|
37212
|
+
return this.getNode(path2) !== void 0;
|
|
37153
37213
|
}
|
|
37154
37214
|
/**
|
|
37155
37215
|
* Get stats for path
|
|
37156
37216
|
*/
|
|
37157
|
-
statSync(
|
|
37158
|
-
const node = this.getNode(
|
|
37217
|
+
statSync(path2) {
|
|
37218
|
+
const node = this.getNode(path2);
|
|
37159
37219
|
if (!node) {
|
|
37160
|
-
throw createNodeError("ENOENT", "stat",
|
|
37220
|
+
throw createNodeError("ENOENT", "stat", path2);
|
|
37161
37221
|
}
|
|
37162
37222
|
const size = node.type === "file" ? node.content?.length || 0 : 0;
|
|
37163
37223
|
const mtime = node.mtime;
|
|
@@ -37192,16 +37252,16 @@ var VirtualFS = class _VirtualFS {
|
|
|
37192
37252
|
/**
|
|
37193
37253
|
* lstatSync - same as statSync for our virtual FS (no symlinks)
|
|
37194
37254
|
*/
|
|
37195
|
-
lstatSync(
|
|
37196
|
-
return this.statSync(
|
|
37255
|
+
lstatSync(path2) {
|
|
37256
|
+
return this.statSync(path2);
|
|
37197
37257
|
}
|
|
37198
|
-
readFileSync(
|
|
37199
|
-
const node = this.getNode(
|
|
37258
|
+
readFileSync(path2, encoding) {
|
|
37259
|
+
const node = this.getNode(path2);
|
|
37200
37260
|
if (!node) {
|
|
37201
|
-
throw createNodeError("ENOENT", "open",
|
|
37261
|
+
throw createNodeError("ENOENT", "open", path2);
|
|
37202
37262
|
}
|
|
37203
37263
|
if (node.type !== "file") {
|
|
37204
|
-
throw createNodeError("EISDIR", "read",
|
|
37264
|
+
throw createNodeError("EISDIR", "read", path2);
|
|
37205
37265
|
}
|
|
37206
37266
|
const content = node.content || new Uint8Array(0);
|
|
37207
37267
|
if (encoding === "utf8" || encoding === "utf-8") {
|
|
@@ -37212,21 +37272,21 @@ var VirtualFS = class _VirtualFS {
|
|
|
37212
37272
|
/**
|
|
37213
37273
|
* Write data to file, creating parent directories as needed
|
|
37214
37274
|
*/
|
|
37215
|
-
writeFileSync(
|
|
37216
|
-
this.writeFileSyncInternal(
|
|
37275
|
+
writeFileSync(path2, data2) {
|
|
37276
|
+
this.writeFileSyncInternal(path2, data2, true);
|
|
37217
37277
|
}
|
|
37218
37278
|
/**
|
|
37219
37279
|
* Create directory, optionally with recursive parent creation
|
|
37220
37280
|
*/
|
|
37221
|
-
mkdirSync(
|
|
37222
|
-
const normalized = this.normalizePath(
|
|
37281
|
+
mkdirSync(path2, options2) {
|
|
37282
|
+
const normalized = this.normalizePath(path2);
|
|
37223
37283
|
if (options2?.recursive) {
|
|
37224
37284
|
this.ensureDirectory(normalized);
|
|
37225
37285
|
return;
|
|
37226
37286
|
}
|
|
37227
37287
|
const parentPath = this.getParentPath(normalized);
|
|
37228
|
-
const
|
|
37229
|
-
if (!
|
|
37288
|
+
const basename2 = this.getBasename(normalized);
|
|
37289
|
+
if (!basename2) {
|
|
37230
37290
|
return;
|
|
37231
37291
|
}
|
|
37232
37292
|
const parent = this.getNode(parentPath);
|
|
@@ -37236,10 +37296,10 @@ var VirtualFS = class _VirtualFS {
|
|
|
37236
37296
|
if (parent.type !== "directory") {
|
|
37237
37297
|
throw createNodeError("ENOTDIR", "mkdir", parentPath);
|
|
37238
37298
|
}
|
|
37239
|
-
if (parent.children.has(
|
|
37240
|
-
throw createNodeError("EEXIST", "mkdir",
|
|
37299
|
+
if (parent.children.has(basename2)) {
|
|
37300
|
+
throw createNodeError("EEXIST", "mkdir", path2);
|
|
37241
37301
|
}
|
|
37242
|
-
parent.children.set(
|
|
37302
|
+
parent.children.set(basename2, {
|
|
37243
37303
|
type: "directory",
|
|
37244
37304
|
children: /* @__PURE__ */ new Map(),
|
|
37245
37305
|
mtime: Date.now()
|
|
@@ -37248,63 +37308,63 @@ var VirtualFS = class _VirtualFS {
|
|
|
37248
37308
|
/**
|
|
37249
37309
|
* Read directory contents
|
|
37250
37310
|
*/
|
|
37251
|
-
readdirSync(
|
|
37252
|
-
const node = this.getNode(
|
|
37311
|
+
readdirSync(path2) {
|
|
37312
|
+
const node = this.getNode(path2);
|
|
37253
37313
|
if (!node) {
|
|
37254
|
-
throw createNodeError("ENOENT", "scandir",
|
|
37314
|
+
throw createNodeError("ENOENT", "scandir", path2);
|
|
37255
37315
|
}
|
|
37256
37316
|
if (node.type !== "directory") {
|
|
37257
|
-
throw createNodeError("ENOTDIR", "scandir",
|
|
37317
|
+
throw createNodeError("ENOTDIR", "scandir", path2);
|
|
37258
37318
|
}
|
|
37259
37319
|
return Array.from(node.children.keys());
|
|
37260
37320
|
}
|
|
37261
37321
|
/**
|
|
37262
37322
|
* Remove file
|
|
37263
37323
|
*/
|
|
37264
|
-
unlinkSync(
|
|
37265
|
-
const normalized = this.normalizePath(
|
|
37324
|
+
unlinkSync(path2) {
|
|
37325
|
+
const normalized = this.normalizePath(path2);
|
|
37266
37326
|
const parentPath = this.getParentPath(normalized);
|
|
37267
|
-
const
|
|
37327
|
+
const basename2 = this.getBasename(normalized);
|
|
37268
37328
|
const parent = this.getNode(parentPath);
|
|
37269
37329
|
if (!parent || parent.type !== "directory") {
|
|
37270
|
-
throw createNodeError("ENOENT", "unlink",
|
|
37330
|
+
throw createNodeError("ENOENT", "unlink", path2);
|
|
37271
37331
|
}
|
|
37272
|
-
const node = parent.children.get(
|
|
37332
|
+
const node = parent.children.get(basename2);
|
|
37273
37333
|
if (!node) {
|
|
37274
|
-
throw createNodeError("ENOENT", "unlink",
|
|
37334
|
+
throw createNodeError("ENOENT", "unlink", path2);
|
|
37275
37335
|
}
|
|
37276
37336
|
if (node.type !== "file") {
|
|
37277
|
-
throw createNodeError("EISDIR", "unlink",
|
|
37337
|
+
throw createNodeError("EISDIR", "unlink", path2);
|
|
37278
37338
|
}
|
|
37279
|
-
parent.children.delete(
|
|
37339
|
+
parent.children.delete(basename2);
|
|
37280
37340
|
this.notifyWatchers(normalized, "rename");
|
|
37281
37341
|
this.emit("delete", normalized);
|
|
37282
37342
|
}
|
|
37283
37343
|
/**
|
|
37284
37344
|
* Remove directory (must be empty)
|
|
37285
37345
|
*/
|
|
37286
|
-
rmdirSync(
|
|
37287
|
-
const normalized = this.normalizePath(
|
|
37346
|
+
rmdirSync(path2) {
|
|
37347
|
+
const normalized = this.normalizePath(path2);
|
|
37288
37348
|
const parentPath = this.getParentPath(normalized);
|
|
37289
|
-
const
|
|
37290
|
-
if (!
|
|
37291
|
-
throw new Error(`EPERM: operation not permitted, '${
|
|
37349
|
+
const basename2 = this.getBasename(normalized);
|
|
37350
|
+
if (!basename2) {
|
|
37351
|
+
throw new Error(`EPERM: operation not permitted, '${path2}'`);
|
|
37292
37352
|
}
|
|
37293
37353
|
const parent = this.getNode(parentPath);
|
|
37294
37354
|
if (!parent || parent.type !== "directory") {
|
|
37295
|
-
throw createNodeError("ENOENT", "rmdir",
|
|
37355
|
+
throw createNodeError("ENOENT", "rmdir", path2);
|
|
37296
37356
|
}
|
|
37297
|
-
const node = parent.children.get(
|
|
37357
|
+
const node = parent.children.get(basename2);
|
|
37298
37358
|
if (!node) {
|
|
37299
|
-
throw createNodeError("ENOENT", "rmdir",
|
|
37359
|
+
throw createNodeError("ENOENT", "rmdir", path2);
|
|
37300
37360
|
}
|
|
37301
37361
|
if (node.type !== "directory") {
|
|
37302
|
-
throw createNodeError("ENOTDIR", "rmdir",
|
|
37362
|
+
throw createNodeError("ENOTDIR", "rmdir", path2);
|
|
37303
37363
|
}
|
|
37304
37364
|
if (node.children.size > 0) {
|
|
37305
|
-
throw createNodeError("ENOTEMPTY", "rmdir",
|
|
37365
|
+
throw createNodeError("ENOTEMPTY", "rmdir", path2);
|
|
37306
37366
|
}
|
|
37307
|
-
parent.children.delete(
|
|
37367
|
+
parent.children.delete(basename2);
|
|
37308
37368
|
}
|
|
37309
37369
|
/**
|
|
37310
37370
|
* Rename/move file or directory
|
|
@@ -37333,11 +37393,11 @@ var VirtualFS = class _VirtualFS {
|
|
|
37333
37393
|
/**
|
|
37334
37394
|
* Read file with optional options parameter
|
|
37335
37395
|
*/
|
|
37336
|
-
readFile(
|
|
37396
|
+
readFile(path2, optionsOrCallback, callback) {
|
|
37337
37397
|
const actualCallback = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
37338
37398
|
const options2 = typeof optionsOrCallback === "object" ? optionsOrCallback : void 0;
|
|
37339
37399
|
try {
|
|
37340
|
-
const data2 = options2?.encoding ? this.readFileSync(
|
|
37400
|
+
const data2 = options2?.encoding ? this.readFileSync(path2, options2.encoding) : this.readFileSync(path2);
|
|
37341
37401
|
if (actualCallback) {
|
|
37342
37402
|
setTimeout(() => actualCallback(null, data2), 0);
|
|
37343
37403
|
}
|
|
@@ -37350,9 +37410,9 @@ var VirtualFS = class _VirtualFS {
|
|
|
37350
37410
|
/**
|
|
37351
37411
|
* Async stat
|
|
37352
37412
|
*/
|
|
37353
|
-
stat(
|
|
37413
|
+
stat(path2, callback) {
|
|
37354
37414
|
try {
|
|
37355
|
-
const stats = this.statSync(
|
|
37415
|
+
const stats = this.statSync(path2);
|
|
37356
37416
|
setTimeout(() => callback(null, stats), 0);
|
|
37357
37417
|
} catch (err) {
|
|
37358
37418
|
setTimeout(() => callback(err), 0);
|
|
@@ -37361,16 +37421,16 @@ var VirtualFS = class _VirtualFS {
|
|
|
37361
37421
|
/**
|
|
37362
37422
|
* Async lstat
|
|
37363
37423
|
*/
|
|
37364
|
-
lstat(
|
|
37365
|
-
this.stat(
|
|
37424
|
+
lstat(path2, callback) {
|
|
37425
|
+
this.stat(path2, callback);
|
|
37366
37426
|
}
|
|
37367
37427
|
/**
|
|
37368
37428
|
* Async readdir
|
|
37369
37429
|
*/
|
|
37370
|
-
readdir(
|
|
37430
|
+
readdir(path2, optionsOrCallback, callback) {
|
|
37371
37431
|
const actualCallback = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
37372
37432
|
try {
|
|
37373
|
-
const files = this.readdirSync(
|
|
37433
|
+
const files = this.readdirSync(path2);
|
|
37374
37434
|
if (actualCallback) {
|
|
37375
37435
|
setTimeout(() => actualCallback(null, files), 0);
|
|
37376
37436
|
}
|
|
@@ -37383,9 +37443,9 @@ var VirtualFS = class _VirtualFS {
|
|
|
37383
37443
|
/**
|
|
37384
37444
|
* Async realpath
|
|
37385
37445
|
*/
|
|
37386
|
-
realpath(
|
|
37446
|
+
realpath(path2, callback) {
|
|
37387
37447
|
try {
|
|
37388
|
-
const resolved = this.realpathSync(
|
|
37448
|
+
const resolved = this.realpathSync(path2);
|
|
37389
37449
|
setTimeout(() => callback(null, resolved), 0);
|
|
37390
37450
|
} catch (err) {
|
|
37391
37451
|
setTimeout(() => callback(err), 0);
|
|
@@ -37394,10 +37454,10 @@ var VirtualFS = class _VirtualFS {
|
|
|
37394
37454
|
/**
|
|
37395
37455
|
* Sync realpath - in our VFS, just normalize the path
|
|
37396
37456
|
*/
|
|
37397
|
-
realpathSync(
|
|
37398
|
-
const normalized = this.normalizePath(
|
|
37457
|
+
realpathSync(path2) {
|
|
37458
|
+
const normalized = this.normalizePath(path2);
|
|
37399
37459
|
if (!this.existsSync(normalized)) {
|
|
37400
|
-
throw createNodeError("ENOENT", "realpath",
|
|
37460
|
+
throw createNodeError("ENOENT", "realpath", path2);
|
|
37401
37461
|
}
|
|
37402
37462
|
return normalized;
|
|
37403
37463
|
}
|
|
@@ -37445,15 +37505,15 @@ var VirtualFS = class _VirtualFS {
|
|
|
37445
37505
|
/**
|
|
37446
37506
|
* Notify watchers of file changes
|
|
37447
37507
|
*/
|
|
37448
|
-
notifyWatchers(
|
|
37449
|
-
const normalized = this.normalizePath(
|
|
37450
|
-
const
|
|
37508
|
+
notifyWatchers(path2, eventType) {
|
|
37509
|
+
const normalized = this.normalizePath(path2);
|
|
37510
|
+
const basename2 = this.getBasename(normalized);
|
|
37451
37511
|
const directWatchers = this.watchers.get(normalized);
|
|
37452
37512
|
if (directWatchers) {
|
|
37453
37513
|
for (const entry of directWatchers) {
|
|
37454
37514
|
if (!entry.closed) {
|
|
37455
37515
|
try {
|
|
37456
|
-
entry.listener(eventType,
|
|
37516
|
+
entry.listener(eventType, basename2);
|
|
37457
37517
|
} catch (err) {
|
|
37458
37518
|
console.error("Error in file watcher:", err);
|
|
37459
37519
|
}
|
|
@@ -37461,7 +37521,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
37461
37521
|
}
|
|
37462
37522
|
}
|
|
37463
37523
|
let currentPath = this.getParentPath(normalized);
|
|
37464
|
-
let relativePath =
|
|
37524
|
+
let relativePath = basename2;
|
|
37465
37525
|
while (currentPath) {
|
|
37466
37526
|
const parentWatchers = this.watchers.get(currentPath);
|
|
37467
37527
|
if (parentWatchers) {
|
|
@@ -37486,18 +37546,18 @@ var VirtualFS = class _VirtualFS {
|
|
|
37486
37546
|
/**
|
|
37487
37547
|
* Access check - in our VFS, always succeeds if file exists
|
|
37488
37548
|
*/
|
|
37489
|
-
accessSync(
|
|
37490
|
-
if (!this.existsSync(
|
|
37491
|
-
throw createNodeError("ENOENT", "access",
|
|
37549
|
+
accessSync(path2, mode) {
|
|
37550
|
+
if (!this.existsSync(path2)) {
|
|
37551
|
+
throw createNodeError("ENOENT", "access", path2);
|
|
37492
37552
|
}
|
|
37493
37553
|
}
|
|
37494
37554
|
/**
|
|
37495
37555
|
* Async access
|
|
37496
37556
|
*/
|
|
37497
|
-
access(
|
|
37557
|
+
access(path2, modeOrCallback, callback) {
|
|
37498
37558
|
const actualCallback = typeof modeOrCallback === "function" ? modeOrCallback : callback;
|
|
37499
37559
|
try {
|
|
37500
|
-
this.accessSync(
|
|
37560
|
+
this.accessSync(path2);
|
|
37501
37561
|
if (actualCallback) setTimeout(() => actualCallback(null), 0);
|
|
37502
37562
|
} catch (err) {
|
|
37503
37563
|
if (actualCallback) setTimeout(() => actualCallback(err), 0);
|
|
@@ -37513,7 +37573,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
37513
37573
|
/**
|
|
37514
37574
|
* Create read stream - simplified implementation
|
|
37515
37575
|
*/
|
|
37516
|
-
createReadStream(
|
|
37576
|
+
createReadStream(path2) {
|
|
37517
37577
|
const self = this;
|
|
37518
37578
|
const listeners = {};
|
|
37519
37579
|
const stream = {
|
|
@@ -37528,7 +37588,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
37528
37588
|
};
|
|
37529
37589
|
setTimeout(() => {
|
|
37530
37590
|
try {
|
|
37531
|
-
const data2 = self.readFileSync(
|
|
37591
|
+
const data2 = self.readFileSync(path2);
|
|
37532
37592
|
listeners["data"]?.forEach((cb2) => cb2(data2));
|
|
37533
37593
|
listeners["end"]?.forEach((cb2) => cb2());
|
|
37534
37594
|
} catch (err) {
|
|
@@ -37540,7 +37600,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
37540
37600
|
/**
|
|
37541
37601
|
* Create write stream - simplified implementation
|
|
37542
37602
|
*/
|
|
37543
|
-
createWriteStream(
|
|
37603
|
+
createWriteStream(path2) {
|
|
37544
37604
|
const self = this;
|
|
37545
37605
|
const chunks = [];
|
|
37546
37606
|
const listeners = {};
|
|
@@ -37563,7 +37623,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
37563
37623
|
combined.set(chunk, offset2);
|
|
37564
37624
|
offset2 += chunk.length;
|
|
37565
37625
|
}
|
|
37566
|
-
self.writeFileSync(
|
|
37626
|
+
self.writeFileSync(path2, combined);
|
|
37567
37627
|
listeners["finish"]?.forEach((cb2) => cb2());
|
|
37568
37628
|
listeners["close"]?.forEach((cb2) => cb2());
|
|
37569
37629
|
},
|
|
@@ -37631,27 +37691,27 @@ function createBuffer(data2) {
|
|
|
37631
37691
|
return buffer;
|
|
37632
37692
|
}
|
|
37633
37693
|
function toPath(pathLike, getCwd) {
|
|
37634
|
-
let
|
|
37694
|
+
let path2;
|
|
37635
37695
|
if (typeof pathLike === "string") {
|
|
37636
|
-
|
|
37696
|
+
path2 = pathLike;
|
|
37637
37697
|
} else if (pathLike instanceof URL) {
|
|
37638
37698
|
if (pathLike.protocol === "file:") {
|
|
37639
|
-
|
|
37699
|
+
path2 = decodeURIComponent(pathLike.pathname);
|
|
37640
37700
|
} else {
|
|
37641
37701
|
throw new Error(`Unsupported URL protocol: ${pathLike.protocol}`);
|
|
37642
37702
|
}
|
|
37643
37703
|
} else if (Buffer.isBuffer(pathLike)) {
|
|
37644
|
-
|
|
37704
|
+
path2 = pathLike.toString("utf8");
|
|
37645
37705
|
} else if (pathLike && typeof pathLike === "object" && "toString" in pathLike) {
|
|
37646
|
-
|
|
37706
|
+
path2 = String(pathLike);
|
|
37647
37707
|
} else {
|
|
37648
37708
|
throw new TypeError(`Path must be a string, URL, or Buffer. Received: ${typeof pathLike}`);
|
|
37649
37709
|
}
|
|
37650
|
-
if (!
|
|
37710
|
+
if (!path2.startsWith("/") && getCwd) {
|
|
37651
37711
|
const cwd = getCwd();
|
|
37652
|
-
|
|
37712
|
+
path2 = cwd.endsWith("/") ? cwd + path2 : cwd + "/" + path2;
|
|
37653
37713
|
}
|
|
37654
|
-
return
|
|
37714
|
+
return path2;
|
|
37655
37715
|
}
|
|
37656
37716
|
var fdMap = /* @__PURE__ */ new Map();
|
|
37657
37717
|
var nextFd = 3;
|
|
@@ -37660,7 +37720,7 @@ var callTracker = {
|
|
|
37660
37720
|
readdirSync: /* @__PURE__ */ new Map(),
|
|
37661
37721
|
lastReset: Date.now()
|
|
37662
37722
|
};
|
|
37663
|
-
function trackCall(method,
|
|
37723
|
+
function trackCall(method, path2) {
|
|
37664
37724
|
const now = Date.now();
|
|
37665
37725
|
if (now - callTracker.lastReset > 500) {
|
|
37666
37726
|
callTracker.statSync.clear();
|
|
@@ -37668,15 +37728,15 @@ function trackCall(method, path4) {
|
|
|
37668
37728
|
callTracker.lastReset = now;
|
|
37669
37729
|
}
|
|
37670
37730
|
const map = callTracker[method];
|
|
37671
|
-
const count = (map.get(
|
|
37672
|
-
map.set(
|
|
37673
|
-
if (count === 10 &&
|
|
37674
|
-
console.warn(`[fs] ${method} called ${count}x on ${
|
|
37731
|
+
const count = (map.get(path2) || 0) + 1;
|
|
37732
|
+
map.set(path2, count);
|
|
37733
|
+
if (count === 10 && path2.includes("_generated")) {
|
|
37734
|
+
console.warn(`[fs] ${method} called ${count}x on ${path2}`);
|
|
37675
37735
|
const err = new Error();
|
|
37676
37736
|
console.log(`[fs] Stack at ${count} calls:`, err.stack?.split("\n").slice(1, 10).join("\n"));
|
|
37677
37737
|
}
|
|
37678
37738
|
if (count === 50) {
|
|
37679
|
-
console.warn(`[fs] Potential infinite loop: ${method} called ${count}+ times on ${
|
|
37739
|
+
console.warn(`[fs] Potential infinite loop: ${method} called ${count}+ times on ${path2}`);
|
|
37680
37740
|
}
|
|
37681
37741
|
}
|
|
37682
37742
|
function createFsShim(vfs2, getCwd) {
|
|
@@ -37691,7 +37751,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37691
37751
|
readFile(pathLike, encodingOrOptions) {
|
|
37692
37752
|
return new Promise((resolve5, reject) => {
|
|
37693
37753
|
try {
|
|
37694
|
-
const
|
|
37754
|
+
const path2 = resolvePath(pathLike);
|
|
37695
37755
|
let encoding;
|
|
37696
37756
|
if (typeof encodingOrOptions === "string") {
|
|
37697
37757
|
encoding = encodingOrOptions;
|
|
@@ -37699,9 +37759,9 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37699
37759
|
encoding = encodingOrOptions.encoding;
|
|
37700
37760
|
}
|
|
37701
37761
|
if (encoding === "utf8" || encoding === "utf-8") {
|
|
37702
|
-
resolve5(vfs2.readFileSync(
|
|
37762
|
+
resolve5(vfs2.readFileSync(path2, "utf8"));
|
|
37703
37763
|
} else {
|
|
37704
|
-
resolve5(createBuffer(vfs2.readFileSync(
|
|
37764
|
+
resolve5(createBuffer(vfs2.readFileSync(path2)));
|
|
37705
37765
|
}
|
|
37706
37766
|
} catch (err) {
|
|
37707
37767
|
reject(err);
|
|
@@ -37721,8 +37781,8 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37721
37781
|
stat(pathLike) {
|
|
37722
37782
|
return new Promise((resolve5, reject) => {
|
|
37723
37783
|
try {
|
|
37724
|
-
const
|
|
37725
|
-
resolve5(vfs2.statSync(
|
|
37784
|
+
const path2 = typeof pathLike === "string" ? pathLike : resolvePath(pathLike);
|
|
37785
|
+
resolve5(vfs2.statSync(path2));
|
|
37726
37786
|
} catch (err) {
|
|
37727
37787
|
reject(err);
|
|
37728
37788
|
}
|
|
@@ -37734,12 +37794,12 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37734
37794
|
readdir(pathLike, options2) {
|
|
37735
37795
|
return new Promise((resolve5, reject) => {
|
|
37736
37796
|
try {
|
|
37737
|
-
const
|
|
37738
|
-
const entries = vfs2.readdirSync(
|
|
37797
|
+
const path2 = resolvePath(pathLike);
|
|
37798
|
+
const entries = vfs2.readdirSync(path2);
|
|
37739
37799
|
const opts = typeof options2 === "string" ? {} : options2;
|
|
37740
37800
|
if (opts?.withFileTypes) {
|
|
37741
37801
|
const dirents = entries.map((name) => {
|
|
37742
|
-
const entryPath =
|
|
37802
|
+
const entryPath = path2.endsWith("/") ? path2 + name : path2 + "/" + name;
|
|
37743
37803
|
let isDir = false;
|
|
37744
37804
|
let isFile = false;
|
|
37745
37805
|
try {
|
|
@@ -37780,10 +37840,10 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37780
37840
|
}
|
|
37781
37841
|
});
|
|
37782
37842
|
},
|
|
37783
|
-
rmdir(
|
|
37843
|
+
rmdir(path2) {
|
|
37784
37844
|
return new Promise((resolve5, reject) => {
|
|
37785
37845
|
try {
|
|
37786
|
-
vfs2.rmdirSync(
|
|
37846
|
+
vfs2.rmdirSync(path2);
|
|
37787
37847
|
resolve5();
|
|
37788
37848
|
} catch (err) {
|
|
37789
37849
|
reject(err);
|
|
@@ -37800,20 +37860,20 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37800
37860
|
}
|
|
37801
37861
|
});
|
|
37802
37862
|
},
|
|
37803
|
-
access(
|
|
37863
|
+
access(path2, mode) {
|
|
37804
37864
|
return new Promise((resolve5, reject) => {
|
|
37805
37865
|
try {
|
|
37806
|
-
vfs2.accessSync(
|
|
37866
|
+
vfs2.accessSync(path2, mode);
|
|
37807
37867
|
resolve5();
|
|
37808
37868
|
} catch (err) {
|
|
37809
37869
|
reject(err);
|
|
37810
37870
|
}
|
|
37811
37871
|
});
|
|
37812
37872
|
},
|
|
37813
|
-
realpath(
|
|
37873
|
+
realpath(path2) {
|
|
37814
37874
|
return new Promise((resolve5, reject) => {
|
|
37815
37875
|
try {
|
|
37816
|
-
resolve5(vfs2.realpathSync(
|
|
37876
|
+
resolve5(vfs2.realpathSync(path2));
|
|
37817
37877
|
} catch (err) {
|
|
37818
37878
|
reject(err);
|
|
37819
37879
|
}
|
|
@@ -37832,7 +37892,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37832
37892
|
};
|
|
37833
37893
|
return {
|
|
37834
37894
|
readFileSync(pathLike, encodingOrOptions) {
|
|
37835
|
-
const
|
|
37895
|
+
const path2 = resolvePath(pathLike);
|
|
37836
37896
|
let encoding;
|
|
37837
37897
|
if (typeof encodingOrOptions === "string") {
|
|
37838
37898
|
encoding = encodingOrOptions;
|
|
@@ -37840,9 +37900,9 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37840
37900
|
encoding = encodingOrOptions.encoding;
|
|
37841
37901
|
}
|
|
37842
37902
|
if (encoding === "utf8" || encoding === "utf-8") {
|
|
37843
|
-
return vfs2.readFileSync(
|
|
37903
|
+
return vfs2.readFileSync(path2, "utf8");
|
|
37844
37904
|
}
|
|
37845
|
-
const data2 = vfs2.readFileSync(
|
|
37905
|
+
const data2 = vfs2.readFileSync(path2);
|
|
37846
37906
|
return createBuffer(data2);
|
|
37847
37907
|
},
|
|
37848
37908
|
writeFileSync(pathLike, data2) {
|
|
@@ -37860,24 +37920,24 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37860
37920
|
entry.position = bytes.length;
|
|
37861
37921
|
return;
|
|
37862
37922
|
}
|
|
37863
|
-
const
|
|
37864
|
-
vfs2.writeFileSync(
|
|
37923
|
+
const path2 = resolvePath(pathLike);
|
|
37924
|
+
vfs2.writeFileSync(path2, data2);
|
|
37865
37925
|
},
|
|
37866
37926
|
existsSync(pathLike) {
|
|
37867
37927
|
return vfs2.existsSync(resolvePath(pathLike));
|
|
37868
37928
|
},
|
|
37869
37929
|
mkdirSync(pathLike, options2) {
|
|
37870
|
-
const
|
|
37871
|
-
vfs2.mkdirSync(
|
|
37930
|
+
const path2 = resolvePath(pathLike);
|
|
37931
|
+
vfs2.mkdirSync(path2, options2);
|
|
37872
37932
|
},
|
|
37873
37933
|
readdirSync(pathLike, options2) {
|
|
37874
|
-
const
|
|
37875
|
-
trackCall("readdirSync",
|
|
37876
|
-
const entries = vfs2.readdirSync(
|
|
37934
|
+
const path2 = resolvePath(pathLike);
|
|
37935
|
+
trackCall("readdirSync", path2);
|
|
37936
|
+
const entries = vfs2.readdirSync(path2);
|
|
37877
37937
|
const opts = typeof options2 === "string" ? { encoding: options2 } : options2;
|
|
37878
37938
|
if (opts?.withFileTypes) {
|
|
37879
37939
|
const dirents = entries.map((name) => {
|
|
37880
|
-
const entryPath =
|
|
37940
|
+
const entryPath = path2.endsWith("/") ? path2 + name : path2 + "/" + name;
|
|
37881
37941
|
let isDir = false;
|
|
37882
37942
|
let isFile = false;
|
|
37883
37943
|
try {
|
|
@@ -37889,24 +37949,24 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37889
37949
|
}
|
|
37890
37950
|
return new Dirent(name, isDir, isFile);
|
|
37891
37951
|
});
|
|
37892
|
-
if (
|
|
37893
|
-
console.log(`[fs] readdirSync(${
|
|
37952
|
+
if (path2.includes("_generated")) {
|
|
37953
|
+
console.log(`[fs] readdirSync(${path2}, withFileTypes) -> [${dirents.map((d) => d.name).join(", ")}]`);
|
|
37894
37954
|
}
|
|
37895
37955
|
return dirents;
|
|
37896
37956
|
}
|
|
37897
|
-
if (
|
|
37898
|
-
console.log(`[fs] readdirSync(${
|
|
37957
|
+
if (path2.includes("_generated")) {
|
|
37958
|
+
console.log(`[fs] readdirSync(${path2}) -> [${entries.join(", ")}]`);
|
|
37899
37959
|
}
|
|
37900
37960
|
return entries;
|
|
37901
37961
|
},
|
|
37902
37962
|
statSync(pathLike) {
|
|
37903
37963
|
const origPath = typeof pathLike === "string" ? pathLike : String(pathLike);
|
|
37904
|
-
const
|
|
37905
|
-
trackCall("statSync",
|
|
37906
|
-
const result = vfs2.statSync(
|
|
37907
|
-
if (
|
|
37908
|
-
const wasRemapped = origPath !==
|
|
37909
|
-
console.log(`[fs] statSync(${origPath}${wasRemapped ? " -> " +
|
|
37964
|
+
const path2 = resolvePath(pathLike);
|
|
37965
|
+
trackCall("statSync", path2);
|
|
37966
|
+
const result = vfs2.statSync(path2);
|
|
37967
|
+
if (path2.includes("_generated")) {
|
|
37968
|
+
const wasRemapped = origPath !== path2;
|
|
37969
|
+
console.log(`[fs] statSync(${origPath}${wasRemapped ? " -> " + path2 : ""}) -> isDir: ${result.isDirectory()}`);
|
|
37910
37970
|
}
|
|
37911
37971
|
return result;
|
|
37912
37972
|
},
|
|
@@ -37924,25 +37984,25 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37924
37984
|
return vfs2.statSync(entry.path);
|
|
37925
37985
|
},
|
|
37926
37986
|
openSync(pathLike, flags, _mode) {
|
|
37927
|
-
const
|
|
37987
|
+
const path2 = resolvePath(pathLike);
|
|
37928
37988
|
const flagStr = typeof flags === "number" ? "r" : flags;
|
|
37929
|
-
const exists = vfs2.existsSync(
|
|
37989
|
+
const exists = vfs2.existsSync(path2);
|
|
37930
37990
|
const isWriteMode = flagStr.includes("w") || flagStr.includes("a");
|
|
37931
37991
|
const isReadMode = flagStr.includes("r") && !flagStr.includes("+");
|
|
37932
37992
|
if (!exists && isReadMode) {
|
|
37933
|
-
const err = new Error(`ENOENT: no such file or directory, open '${
|
|
37993
|
+
const err = new Error(`ENOENT: no such file or directory, open '${path2}'`);
|
|
37934
37994
|
err.code = "ENOENT";
|
|
37935
37995
|
err.errno = -2;
|
|
37936
|
-
err.path =
|
|
37996
|
+
err.path = path2;
|
|
37937
37997
|
throw err;
|
|
37938
37998
|
}
|
|
37939
37999
|
let content;
|
|
37940
38000
|
if (exists && !flagStr.includes("w")) {
|
|
37941
|
-
content = vfs2.readFileSync(
|
|
38001
|
+
content = vfs2.readFileSync(path2);
|
|
37942
38002
|
} else {
|
|
37943
38003
|
content = new Uint8Array(0);
|
|
37944
38004
|
if (isWriteMode) {
|
|
37945
|
-
const parentPath =
|
|
38005
|
+
const parentPath = path2.substring(0, path2.lastIndexOf("/")) || "/";
|
|
37946
38006
|
if (!vfs2.existsSync(parentPath)) {
|
|
37947
38007
|
vfs2.mkdirSync(parentPath, { recursive: true });
|
|
37948
38008
|
}
|
|
@@ -37950,7 +38010,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
37950
38010
|
}
|
|
37951
38011
|
const fd2 = nextFd++;
|
|
37952
38012
|
fdMap.set(fd2, {
|
|
37953
|
-
path:
|
|
38013
|
+
path: path2,
|
|
37954
38014
|
position: flagStr.includes("a") ? content.length : 0,
|
|
37955
38015
|
flags: flagStr,
|
|
37956
38016
|
content: new Uint8Array(content)
|
|
@@ -38049,33 +38109,33 @@ function createFsShim(vfs2, getCwd) {
|
|
|
38049
38109
|
return resolvedPath2;
|
|
38050
38110
|
},
|
|
38051
38111
|
rmSync(pathLike, options2) {
|
|
38052
|
-
const
|
|
38053
|
-
if (!vfs2.existsSync(
|
|
38112
|
+
const path2 = resolvePath(pathLike);
|
|
38113
|
+
if (!vfs2.existsSync(path2)) {
|
|
38054
38114
|
if (options2?.force) return;
|
|
38055
|
-
throw createNodeError("ENOENT", "rm",
|
|
38115
|
+
throw createNodeError("ENOENT", "rm", path2);
|
|
38056
38116
|
}
|
|
38057
|
-
const stats = vfs2.statSync(
|
|
38117
|
+
const stats = vfs2.statSync(path2);
|
|
38058
38118
|
if (stats.isDirectory()) {
|
|
38059
38119
|
if (options2?.recursive) {
|
|
38060
|
-
const entries = vfs2.readdirSync(
|
|
38120
|
+
const entries = vfs2.readdirSync(path2);
|
|
38061
38121
|
for (const entry of entries) {
|
|
38062
|
-
const entryPath =
|
|
38122
|
+
const entryPath = path2.endsWith("/") ? path2 + entry : path2 + "/" + entry;
|
|
38063
38123
|
this.rmSync(entryPath, options2);
|
|
38064
38124
|
}
|
|
38065
|
-
vfs2.rmdirSync(
|
|
38125
|
+
vfs2.rmdirSync(path2);
|
|
38066
38126
|
} else {
|
|
38067
|
-
throw createNodeError("EISDIR", "rm",
|
|
38127
|
+
throw createNodeError("EISDIR", "rm", path2);
|
|
38068
38128
|
}
|
|
38069
38129
|
} else {
|
|
38070
|
-
vfs2.unlinkSync(
|
|
38130
|
+
vfs2.unlinkSync(path2);
|
|
38071
38131
|
}
|
|
38072
38132
|
},
|
|
38073
38133
|
unlinkSync(pathLike) {
|
|
38074
|
-
const
|
|
38075
|
-
if (
|
|
38076
|
-
console.log(`[fs] unlinkSync(${
|
|
38134
|
+
const path2 = resolvePath(pathLike);
|
|
38135
|
+
if (path2.includes("_generated")) {
|
|
38136
|
+
console.log(`[fs] unlinkSync(${path2})`);
|
|
38077
38137
|
}
|
|
38078
|
-
vfs2.unlinkSync(
|
|
38138
|
+
vfs2.unlinkSync(path2);
|
|
38079
38139
|
},
|
|
38080
38140
|
rmdirSync(pathLike) {
|
|
38081
38141
|
vfs2.rmdirSync(resolvePath(pathLike));
|
|
@@ -38106,8 +38166,8 @@ function createFsShim(vfs2, getCwd) {
|
|
|
38106
38166
|
return vfs2.watch(resolvePath(pathLike), optionsOrListener, listener);
|
|
38107
38167
|
},
|
|
38108
38168
|
readFile(pathLike, optionsOrCallback, callback) {
|
|
38109
|
-
const
|
|
38110
|
-
vfs2.readFile(
|
|
38169
|
+
const path2 = resolvePath(pathLike);
|
|
38170
|
+
vfs2.readFile(path2, optionsOrCallback, callback);
|
|
38111
38171
|
},
|
|
38112
38172
|
stat(pathLike, callback) {
|
|
38113
38173
|
vfs2.stat(resolvePath(pathLike), callback);
|
|
@@ -38118,12 +38178,12 @@ function createFsShim(vfs2, getCwd) {
|
|
|
38118
38178
|
readdir(pathLike, optionsOrCallback, callback) {
|
|
38119
38179
|
const cb2 = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
38120
38180
|
const opts = typeof optionsOrCallback === "function" ? void 0 : optionsOrCallback;
|
|
38121
|
-
const
|
|
38181
|
+
const path2 = resolvePath(pathLike);
|
|
38122
38182
|
try {
|
|
38123
|
-
const entries = vfs2.readdirSync(
|
|
38183
|
+
const entries = vfs2.readdirSync(path2);
|
|
38124
38184
|
if (opts?.withFileTypes) {
|
|
38125
38185
|
const dirents = entries.map((name) => {
|
|
38126
|
-
const entryPath =
|
|
38186
|
+
const entryPath = path2.endsWith("/") ? path2 + name : path2 + "/" + name;
|
|
38127
38187
|
let isDir = false;
|
|
38128
38188
|
let isFile = false;
|
|
38129
38189
|
try {
|
|
@@ -40699,8 +40759,8 @@ var ClientRequest = class extends Writable {
|
|
|
40699
40759
|
}
|
|
40700
40760
|
}
|
|
40701
40761
|
if (!hostname2) hostname2 = "localhost";
|
|
40702
|
-
const
|
|
40703
|
-
const url2 = `${protocol}//${hostname2}${port}${
|
|
40762
|
+
const path2 = this._options.path || "/";
|
|
40763
|
+
const url2 = `${protocol}//${hostname2}${port}${path2}`;
|
|
40704
40764
|
if (this.headers["upgrade"]?.toLowerCase() === "websocket") {
|
|
40705
40765
|
this._handleWebSocketUpgrade(url2);
|
|
40706
40766
|
return;
|
|
@@ -41146,7 +41206,7 @@ __export(url_exports, {
|
|
|
41146
41206
|
format: () => format,
|
|
41147
41207
|
parse: () => parse,
|
|
41148
41208
|
pathToFileURL: () => pathToFileURL,
|
|
41149
|
-
resolve: () =>
|
|
41209
|
+
resolve: () => resolve3
|
|
41150
41210
|
});
|
|
41151
41211
|
function parse(urlString, parseQueryString = false, slashesDenoteHost = false) {
|
|
41152
41212
|
try {
|
|
@@ -41238,7 +41298,7 @@ function format(urlObject) {
|
|
|
41238
41298
|
}
|
|
41239
41299
|
return result;
|
|
41240
41300
|
}
|
|
41241
|
-
function
|
|
41301
|
+
function resolve3(from, to2) {
|
|
41242
41302
|
try {
|
|
41243
41303
|
return new URL2(to2, from).href;
|
|
41244
41304
|
} catch {
|
|
@@ -41254,14 +41314,14 @@ function fileURLToPath(url2) {
|
|
|
41254
41314
|
}
|
|
41255
41315
|
return decodeURIComponent(urlObj.pathname);
|
|
41256
41316
|
}
|
|
41257
|
-
function pathToFileURL(
|
|
41258
|
-
const encoded = encodeURIComponent(
|
|
41317
|
+
function pathToFileURL(path2) {
|
|
41318
|
+
const encoded = encodeURIComponent(path2).replace(/%2F/g, "/");
|
|
41259
41319
|
return new globalThis.URL("file://" + encoded);
|
|
41260
41320
|
}
|
|
41261
41321
|
var url_default = {
|
|
41262
41322
|
parse,
|
|
41263
41323
|
format,
|
|
41264
|
-
resolve:
|
|
41324
|
+
resolve: resolve3,
|
|
41265
41325
|
URL: URL2,
|
|
41266
41326
|
URLSearchParams,
|
|
41267
41327
|
fileURLToPath,
|
|
@@ -42105,8 +42165,8 @@ __export(dns_exports, {
|
|
|
42105
42165
|
getServers: () => getServers,
|
|
42106
42166
|
lookup: () => lookup,
|
|
42107
42167
|
promises: () => promises2,
|
|
42108
|
-
resolve: () =>
|
|
42109
|
-
resolve4: () =>
|
|
42168
|
+
resolve: () => resolve4,
|
|
42169
|
+
resolve4: () => resolve42,
|
|
42110
42170
|
resolve6: () => resolve6,
|
|
42111
42171
|
reverse: () => reverse,
|
|
42112
42172
|
setDefaultResultOrder: () => setDefaultResultOrder,
|
|
@@ -42131,13 +42191,13 @@ function lookup(hostname2, optionsOrCallback, callback) {
|
|
|
42131
42191
|
}
|
|
42132
42192
|
});
|
|
42133
42193
|
}
|
|
42134
|
-
function
|
|
42194
|
+
function resolve4(hostname2, callback) {
|
|
42135
42195
|
setImmediate(() => {
|
|
42136
42196
|
callback(null, ["0.0.0.0"]);
|
|
42137
42197
|
});
|
|
42138
42198
|
}
|
|
42139
|
-
function
|
|
42140
|
-
|
|
42199
|
+
function resolve42(hostname2, callback) {
|
|
42200
|
+
resolve4(hostname2, callback);
|
|
42141
42201
|
}
|
|
42142
42202
|
function resolve6(hostname2, callback) {
|
|
42143
42203
|
setImmediate(() => {
|
|
@@ -42177,7 +42237,7 @@ var promises2 = {
|
|
|
42177
42237
|
},
|
|
42178
42238
|
resolve: (hostname2) => {
|
|
42179
42239
|
return new Promise((promiseResolve, promiseReject) => {
|
|
42180
|
-
|
|
42240
|
+
resolve4(hostname2, (err, addresses) => {
|
|
42181
42241
|
if (err) promiseReject(err);
|
|
42182
42242
|
else promiseResolve(addresses || []);
|
|
42183
42243
|
});
|
|
@@ -42203,8 +42263,8 @@ var V4MAPPED = 0;
|
|
|
42203
42263
|
var ALL = 0;
|
|
42204
42264
|
var dns_default = {
|
|
42205
42265
|
lookup,
|
|
42206
|
-
resolve:
|
|
42207
|
-
resolve4,
|
|
42266
|
+
resolve: resolve4,
|
|
42267
|
+
resolve4: resolve42,
|
|
42208
42268
|
resolve6,
|
|
42209
42269
|
reverse,
|
|
42210
42270
|
setServers,
|
|
@@ -42284,63 +42344,63 @@ var VirtualFSAdapter = class {
|
|
|
42284
42344
|
/**
|
|
42285
42345
|
* Read the contents of a file as a string
|
|
42286
42346
|
*/
|
|
42287
|
-
async readFile(
|
|
42347
|
+
async readFile(path2, options2) {
|
|
42288
42348
|
const encoding = typeof options2 === "string" ? options2 : options2?.encoding;
|
|
42289
42349
|
if (!encoding || encoding === "utf8" || encoding === "utf-8") {
|
|
42290
|
-
return this.vfs.readFileSync(
|
|
42350
|
+
return this.vfs.readFileSync(path2, "utf8");
|
|
42291
42351
|
}
|
|
42292
42352
|
if (encoding === "binary" || encoding === "latin1") {
|
|
42293
|
-
const buffer = this.vfs.readFileSync(
|
|
42353
|
+
const buffer = this.vfs.readFileSync(path2);
|
|
42294
42354
|
return uint8ToBinaryString(buffer);
|
|
42295
42355
|
}
|
|
42296
|
-
return this.vfs.readFileSync(
|
|
42356
|
+
return this.vfs.readFileSync(path2, "utf8");
|
|
42297
42357
|
}
|
|
42298
42358
|
/**
|
|
42299
42359
|
* Read the contents of a file as a Uint8Array (binary)
|
|
42300
42360
|
*/
|
|
42301
|
-
async readFileBuffer(
|
|
42302
|
-
return this.vfs.readFileSync(
|
|
42361
|
+
async readFileBuffer(path2) {
|
|
42362
|
+
return this.vfs.readFileSync(path2);
|
|
42303
42363
|
}
|
|
42304
42364
|
/**
|
|
42305
42365
|
* Write content to a file, creating it if it doesn't exist
|
|
42306
42366
|
*/
|
|
42307
|
-
async writeFile(
|
|
42308
|
-
this.vfs.writeFileSync(
|
|
42367
|
+
async writeFile(path2, content, _options2) {
|
|
42368
|
+
this.vfs.writeFileSync(path2, content);
|
|
42309
42369
|
}
|
|
42310
42370
|
/**
|
|
42311
42371
|
* Append content to a file, creating it if it doesn't exist
|
|
42312
42372
|
*/
|
|
42313
|
-
async appendFile(
|
|
42373
|
+
async appendFile(path2, content, _options2) {
|
|
42314
42374
|
let existing = "";
|
|
42315
42375
|
try {
|
|
42316
|
-
existing = this.vfs.readFileSync(
|
|
42376
|
+
existing = this.vfs.readFileSync(path2, "utf8");
|
|
42317
42377
|
} catch {
|
|
42318
42378
|
}
|
|
42319
42379
|
const newContent = typeof content === "string" ? content : _decoder3.decode(content);
|
|
42320
|
-
this.vfs.writeFileSync(
|
|
42380
|
+
this.vfs.writeFileSync(path2, existing + newContent);
|
|
42321
42381
|
}
|
|
42322
42382
|
/**
|
|
42323
42383
|
* Check if a path exists
|
|
42324
42384
|
*/
|
|
42325
|
-
async exists(
|
|
42326
|
-
return this.vfs.existsSync(
|
|
42385
|
+
async exists(path2) {
|
|
42386
|
+
return this.vfs.existsSync(path2);
|
|
42327
42387
|
}
|
|
42328
42388
|
/**
|
|
42329
42389
|
* Get file/directory information
|
|
42330
42390
|
*/
|
|
42331
|
-
async stat(
|
|
42332
|
-
const stats = this.vfs.statSync(
|
|
42391
|
+
async stat(path2) {
|
|
42392
|
+
const stats = this.vfs.statSync(path2);
|
|
42333
42393
|
const isFile = stats.isFile();
|
|
42334
42394
|
const isDirectory = stats.isDirectory();
|
|
42335
42395
|
let size = 0;
|
|
42336
42396
|
if (isFile) {
|
|
42337
42397
|
try {
|
|
42338
|
-
const content = this.vfs.readFileSync(
|
|
42398
|
+
const content = this.vfs.readFileSync(path2);
|
|
42339
42399
|
size = content.length;
|
|
42340
42400
|
} catch {
|
|
42341
42401
|
}
|
|
42342
42402
|
}
|
|
42343
|
-
const isExecutable = isFile &&
|
|
42403
|
+
const isExecutable = isFile && path2.includes("/node_modules/.bin/");
|
|
42344
42404
|
return {
|
|
42345
42405
|
isFile,
|
|
42346
42406
|
isDirectory,
|
|
@@ -42353,23 +42413,23 @@ var VirtualFSAdapter = class {
|
|
|
42353
42413
|
/**
|
|
42354
42414
|
* Create a directory
|
|
42355
42415
|
*/
|
|
42356
|
-
async mkdir(
|
|
42357
|
-
this.vfs.mkdirSync(
|
|
42416
|
+
async mkdir(path2, options2) {
|
|
42417
|
+
this.vfs.mkdirSync(path2, options2);
|
|
42358
42418
|
}
|
|
42359
42419
|
/**
|
|
42360
42420
|
* Read directory contents
|
|
42361
42421
|
*/
|
|
42362
|
-
async readdir(
|
|
42363
|
-
return this.vfs.readdirSync(
|
|
42422
|
+
async readdir(path2) {
|
|
42423
|
+
return this.vfs.readdirSync(path2);
|
|
42364
42424
|
}
|
|
42365
42425
|
/**
|
|
42366
42426
|
* Read directory contents with file type information
|
|
42367
42427
|
*/
|
|
42368
|
-
async readdirWithFileTypes(
|
|
42369
|
-
const entries = this.vfs.readdirSync(
|
|
42428
|
+
async readdirWithFileTypes(path2) {
|
|
42429
|
+
const entries = this.vfs.readdirSync(path2);
|
|
42370
42430
|
const result = [];
|
|
42371
42431
|
for (const name of entries) {
|
|
42372
|
-
const fullPath =
|
|
42432
|
+
const fullPath = path2 === "/" ? `/${name}` : `${path2}/${name}`;
|
|
42373
42433
|
try {
|
|
42374
42434
|
const stats = this.vfs.statSync(fullPath);
|
|
42375
42435
|
result.push({
|
|
@@ -42386,32 +42446,32 @@ var VirtualFSAdapter = class {
|
|
|
42386
42446
|
/**
|
|
42387
42447
|
* Remove a file or directory
|
|
42388
42448
|
*/
|
|
42389
|
-
async rm(
|
|
42390
|
-
const exists = this.vfs.existsSync(
|
|
42449
|
+
async rm(path2, options2) {
|
|
42450
|
+
const exists = this.vfs.existsSync(path2);
|
|
42391
42451
|
if (!exists) {
|
|
42392
42452
|
if (options2?.force) {
|
|
42393
42453
|
return;
|
|
42394
42454
|
}
|
|
42395
|
-
throw createNodeError("ENOENT", "rm",
|
|
42455
|
+
throw createNodeError("ENOENT", "rm", path2);
|
|
42396
42456
|
}
|
|
42397
|
-
const stats = this.vfs.statSync(
|
|
42457
|
+
const stats = this.vfs.statSync(path2);
|
|
42398
42458
|
if (stats.isFile()) {
|
|
42399
|
-
this.vfs.unlinkSync(
|
|
42459
|
+
this.vfs.unlinkSync(path2);
|
|
42400
42460
|
} else if (stats.isDirectory()) {
|
|
42401
42461
|
if (options2?.recursive) {
|
|
42402
|
-
await this.rmRecursive(
|
|
42462
|
+
await this.rmRecursive(path2);
|
|
42403
42463
|
} else {
|
|
42404
|
-
this.vfs.rmdirSync(
|
|
42464
|
+
this.vfs.rmdirSync(path2);
|
|
42405
42465
|
}
|
|
42406
42466
|
}
|
|
42407
42467
|
}
|
|
42408
42468
|
/**
|
|
42409
42469
|
* Recursively remove a directory and its contents
|
|
42410
42470
|
*/
|
|
42411
|
-
async rmRecursive(
|
|
42412
|
-
const entries = this.vfs.readdirSync(
|
|
42471
|
+
async rmRecursive(path2) {
|
|
42472
|
+
const entries = this.vfs.readdirSync(path2);
|
|
42413
42473
|
for (const entry of entries) {
|
|
42414
|
-
const fullPath =
|
|
42474
|
+
const fullPath = path2 === "/" ? `/${entry}` : `${path2}/${entry}`;
|
|
42415
42475
|
const stats = this.vfs.statSync(fullPath);
|
|
42416
42476
|
if (stats.isDirectory()) {
|
|
42417
42477
|
await this.rmRecursive(fullPath);
|
|
@@ -42419,7 +42479,7 @@ var VirtualFSAdapter = class {
|
|
|
42419
42479
|
this.vfs.unlinkSync(fullPath);
|
|
42420
42480
|
}
|
|
42421
42481
|
}
|
|
42422
|
-
this.vfs.rmdirSync(
|
|
42482
|
+
this.vfs.rmdirSync(path2);
|
|
42423
42483
|
}
|
|
42424
42484
|
/**
|
|
42425
42485
|
* Copy a file or directory
|
|
@@ -42465,21 +42525,21 @@ var VirtualFSAdapter = class {
|
|
|
42465
42525
|
/**
|
|
42466
42526
|
* Resolve a relative path against a base path
|
|
42467
42527
|
*/
|
|
42468
|
-
resolvePath(base,
|
|
42469
|
-
if (
|
|
42470
|
-
return this.normalizePath(
|
|
42528
|
+
resolvePath(base, path2) {
|
|
42529
|
+
if (path2.startsWith("/")) {
|
|
42530
|
+
return this.normalizePath(path2);
|
|
42471
42531
|
}
|
|
42472
|
-
const combined = base.endsWith("/") ? `${base}${
|
|
42532
|
+
const combined = base.endsWith("/") ? `${base}${path2}` : `${base}/${path2}`;
|
|
42473
42533
|
return this.normalizePath(combined);
|
|
42474
42534
|
}
|
|
42475
42535
|
/**
|
|
42476
42536
|
* Normalize a path (resolve . and .. segments)
|
|
42477
42537
|
*/
|
|
42478
|
-
normalizePath(
|
|
42479
|
-
if (!
|
|
42480
|
-
|
|
42538
|
+
normalizePath(path2) {
|
|
42539
|
+
if (!path2.startsWith("/")) {
|
|
42540
|
+
path2 = "/" + path2;
|
|
42481
42541
|
}
|
|
42482
|
-
const parts =
|
|
42542
|
+
const parts = path2.split("/").filter(Boolean);
|
|
42483
42543
|
const resolved = [];
|
|
42484
42544
|
for (const part of parts) {
|
|
42485
42545
|
if (part === "..") {
|
|
@@ -42548,25 +42608,25 @@ var VirtualFSAdapter = class {
|
|
|
42548
42608
|
* Get file/directory information without following symlinks
|
|
42549
42609
|
* Since VFS doesn't support symlinks, this is the same as stat
|
|
42550
42610
|
*/
|
|
42551
|
-
async lstat(
|
|
42552
|
-
return this.stat(
|
|
42611
|
+
async lstat(path2) {
|
|
42612
|
+
return this.stat(path2);
|
|
42553
42613
|
}
|
|
42554
42614
|
/**
|
|
42555
42615
|
* Resolve all symlinks in a path
|
|
42556
42616
|
* Since VFS doesn't support symlinks, just normalize and return
|
|
42557
42617
|
*/
|
|
42558
|
-
async realpath(
|
|
42559
|
-
if (!this.vfs.existsSync(
|
|
42560
|
-
throw createNodeError("ENOENT", "realpath",
|
|
42618
|
+
async realpath(path2) {
|
|
42619
|
+
if (!this.vfs.existsSync(path2)) {
|
|
42620
|
+
throw createNodeError("ENOENT", "realpath", path2);
|
|
42561
42621
|
}
|
|
42562
|
-
return this.normalizePath(
|
|
42622
|
+
return this.normalizePath(path2);
|
|
42563
42623
|
}
|
|
42564
42624
|
/**
|
|
42565
42625
|
* Set access and modification times (no-op - VFS doesn't track times)
|
|
42566
42626
|
*/
|
|
42567
|
-
async utimes(
|
|
42568
|
-
if (!this.vfs.existsSync(
|
|
42569
|
-
throw createNodeError("ENOENT", "utimes",
|
|
42627
|
+
async utimes(path2, _atime, _mtime) {
|
|
42628
|
+
if (!this.vfs.existsSync(path2)) {
|
|
42629
|
+
throw createNodeError("ENOENT", "utimes", path2);
|
|
42570
42630
|
}
|
|
42571
42631
|
}
|
|
42572
42632
|
};
|
|
@@ -43335,29 +43395,29 @@ var FSWatcher = class extends EventEmitter {
|
|
|
43335
43395
|
this.vfs = globalVFS;
|
|
43336
43396
|
this.options = options2;
|
|
43337
43397
|
}
|
|
43338
|
-
shouldIgnore(
|
|
43398
|
+
shouldIgnore(path2) {
|
|
43339
43399
|
const { ignored } = this.options;
|
|
43340
43400
|
if (!ignored) return false;
|
|
43341
43401
|
const ignoreList = Array.isArray(ignored) ? ignored : [ignored];
|
|
43342
43402
|
for (const pattern of ignoreList) {
|
|
43343
43403
|
if (typeof pattern === "string") {
|
|
43344
|
-
if (
|
|
43404
|
+
if (path2 === pattern || path2.startsWith(pattern + "/")) return true;
|
|
43345
43405
|
} else if (pattern instanceof RegExp) {
|
|
43346
|
-
if (pattern.test(
|
|
43406
|
+
if (pattern.test(path2)) return true;
|
|
43347
43407
|
} else if (typeof pattern === "function") {
|
|
43348
|
-
if (pattern(
|
|
43408
|
+
if (pattern(path2)) return true;
|
|
43349
43409
|
}
|
|
43350
43410
|
}
|
|
43351
43411
|
return false;
|
|
43352
43412
|
}
|
|
43353
|
-
normalizePath(
|
|
43354
|
-
if (this.options.cwd && !
|
|
43355
|
-
|
|
43413
|
+
normalizePath(path2) {
|
|
43414
|
+
if (this.options.cwd && !path2.startsWith("/")) {
|
|
43415
|
+
path2 = this.options.cwd + "/" + path2;
|
|
43356
43416
|
}
|
|
43357
|
-
if (!
|
|
43358
|
-
|
|
43417
|
+
if (!path2.startsWith("/")) {
|
|
43418
|
+
path2 = "/" + path2;
|
|
43359
43419
|
}
|
|
43360
|
-
return
|
|
43420
|
+
return path2;
|
|
43361
43421
|
}
|
|
43362
43422
|
add(paths) {
|
|
43363
43423
|
if (this.closed) return this;
|
|
@@ -43420,15 +43480,15 @@ var FSWatcher = class extends EventEmitter {
|
|
|
43420
43480
|
} catch {
|
|
43421
43481
|
}
|
|
43422
43482
|
}
|
|
43423
|
-
watchPath(
|
|
43424
|
-
if (this.watched.has(
|
|
43425
|
-
const watcher = this.vfs.watch(
|
|
43483
|
+
watchPath(path2, watchFor) {
|
|
43484
|
+
if (this.watched.has(path2)) return;
|
|
43485
|
+
const watcher = this.vfs.watch(path2, { recursive: true }, (eventType, filename2) => {
|
|
43426
43486
|
if (this.closed) return;
|
|
43427
43487
|
let fullPath;
|
|
43428
43488
|
if (filename2) {
|
|
43429
|
-
fullPath =
|
|
43489
|
+
fullPath = path2 === "/" ? "/" + filename2 : path2 + "/" + filename2;
|
|
43430
43490
|
} else {
|
|
43431
|
-
fullPath =
|
|
43491
|
+
fullPath = path2;
|
|
43432
43492
|
}
|
|
43433
43493
|
const eventKey = `${eventType}:${fullPath}`;
|
|
43434
43494
|
if (!this._eventCounts) this._eventCounts = /* @__PURE__ */ new Map();
|
|
@@ -43472,7 +43532,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
43472
43532
|
}
|
|
43473
43533
|
}
|
|
43474
43534
|
});
|
|
43475
|
-
this.watched.set(
|
|
43535
|
+
this.watched.set(path2, watcher);
|
|
43476
43536
|
}
|
|
43477
43537
|
watchDirRecursive(dirPath, depth = 0) {
|
|
43478
43538
|
if (this.options.depth !== void 0 && depth > this.options.depth) return;
|
|
@@ -43516,13 +43576,13 @@ var FSWatcher = class extends EventEmitter {
|
|
|
43516
43576
|
}
|
|
43517
43577
|
getWatched() {
|
|
43518
43578
|
const result = {};
|
|
43519
|
-
for (const
|
|
43520
|
-
const dir =
|
|
43521
|
-
const
|
|
43579
|
+
for (const path2 of this.watched.keys()) {
|
|
43580
|
+
const dir = path2.substring(0, path2.lastIndexOf("/")) || "/";
|
|
43581
|
+
const basename2 = path2.substring(path2.lastIndexOf("/") + 1);
|
|
43522
43582
|
if (!result[dir]) {
|
|
43523
43583
|
result[dir] = [];
|
|
43524
43584
|
}
|
|
43525
|
-
result[dir].push(
|
|
43585
|
+
result[dir].push(basename2);
|
|
43526
43586
|
}
|
|
43527
43587
|
return result;
|
|
43528
43588
|
}
|
|
@@ -43916,13 +43976,13 @@ var constants5 = {
|
|
|
43916
43976
|
kFSEventStreamEventFlagItemIsDir: 131072,
|
|
43917
43977
|
kFSEventStreamEventFlagItemIsSymlink: 262144
|
|
43918
43978
|
};
|
|
43919
|
-
function watch2(
|
|
43979
|
+
function watch2(path2, handler) {
|
|
43920
43980
|
return () => Promise.resolve();
|
|
43921
43981
|
}
|
|
43922
|
-
function getInfo(
|
|
43982
|
+
function getInfo(path2, flags) {
|
|
43923
43983
|
return {
|
|
43924
43984
|
event: "unknown",
|
|
43925
|
-
path:
|
|
43985
|
+
path: path2,
|
|
43926
43986
|
type: "file",
|
|
43927
43987
|
changes: { inode: false, finder: false, access: false, xattrs: false },
|
|
43928
43988
|
flags
|
|
@@ -44589,8 +44649,8 @@ async function transformToCommonJS(code2, options2) {
|
|
|
44589
44649
|
});
|
|
44590
44650
|
return result.code;
|
|
44591
44651
|
}
|
|
44592
|
-
function remapVFSPath(
|
|
44593
|
-
return
|
|
44652
|
+
function remapVFSPath(path2) {
|
|
44653
|
+
return path2;
|
|
44594
44654
|
}
|
|
44595
44655
|
function findVFSFile(vfs2, originalPath, extensions) {
|
|
44596
44656
|
for (const ext2 of extensions) {
|
|
@@ -44748,16 +44808,16 @@ async function build(options2) {
|
|
|
44748
44808
|
}
|
|
44749
44809
|
if (ep2.startsWith("./")) {
|
|
44750
44810
|
const base = absWorkingDir.endsWith("/") ? absWorkingDir.slice(0, -1) : absWorkingDir;
|
|
44751
|
-
const
|
|
44752
|
-
const resolved = base + "/" +
|
|
44811
|
+
const relative3 = ep2.slice(2);
|
|
44812
|
+
const resolved = base + "/" + relative3;
|
|
44753
44813
|
return resolved;
|
|
44754
44814
|
}
|
|
44755
44815
|
if (ep2.startsWith("../")) {
|
|
44756
44816
|
const base = absWorkingDir.endsWith("/") ? absWorkingDir.slice(0, -1) : absWorkingDir;
|
|
44757
44817
|
const parts = base.split("/").filter(Boolean);
|
|
44758
44818
|
parts.pop();
|
|
44759
|
-
const
|
|
44760
|
-
const resolved = "/" + parts.join("/") + "/" +
|
|
44819
|
+
const relative3 = ep2.slice(3);
|
|
44820
|
+
const resolved = "/" + parts.join("/") + "/" + relative3;
|
|
44761
44821
|
return resolved;
|
|
44762
44822
|
}
|
|
44763
44823
|
return ep2;
|
|
@@ -53659,7 +53719,7 @@ var ServerBridge = class _ServerBridge extends EventEmitter {
|
|
|
53659
53719
|
throw new Error("Not a virtual server request");
|
|
53660
53720
|
}
|
|
53661
53721
|
const port = parseInt(match3[1], 10);
|
|
53662
|
-
const
|
|
53722
|
+
const path2 = match3[2] || "/";
|
|
53663
53723
|
const headers = {};
|
|
53664
53724
|
request3.headers.forEach((value, key) => {
|
|
53665
53725
|
headers[key] = value;
|
|
@@ -53671,7 +53731,7 @@ var ServerBridge = class _ServerBridge extends EventEmitter {
|
|
|
53671
53731
|
const response = await this.handleRequest(
|
|
53672
53732
|
port,
|
|
53673
53733
|
request3.method,
|
|
53674
|
-
|
|
53734
|
+
path2 + url2.search,
|
|
53675
53735
|
headers,
|
|
53676
53736
|
body
|
|
53677
53737
|
);
|
|
@@ -53797,20 +53857,20 @@ var DevServer = class extends EventEmitter {
|
|
|
53797
53857
|
* Resolve a URL path to a filesystem path
|
|
53798
53858
|
*/
|
|
53799
53859
|
resolvePath(urlPath) {
|
|
53800
|
-
let
|
|
53801
|
-
if (!
|
|
53802
|
-
|
|
53860
|
+
let path2 = urlPath.split("?")[0].split("#")[0];
|
|
53861
|
+
if (!path2.startsWith("/")) {
|
|
53862
|
+
path2 = "/" + path2;
|
|
53803
53863
|
}
|
|
53804
53864
|
if (this.root !== "/") {
|
|
53805
|
-
|
|
53865
|
+
path2 = this.root + path2;
|
|
53806
53866
|
}
|
|
53807
|
-
return
|
|
53867
|
+
return path2;
|
|
53808
53868
|
}
|
|
53809
53869
|
/**
|
|
53810
53870
|
* Create a 404 Not Found response
|
|
53811
53871
|
*/
|
|
53812
|
-
notFound(
|
|
53813
|
-
const body = `Not found: ${
|
|
53872
|
+
notFound(path2) {
|
|
53873
|
+
const body = `Not found: ${path2}`;
|
|
53814
53874
|
return {
|
|
53815
53875
|
statusCode: 404,
|
|
53816
53876
|
statusMessage: "Not Found",
|
|
@@ -53855,16 +53915,16 @@ var DevServer = class extends EventEmitter {
|
|
|
53855
53915
|
/**
|
|
53856
53916
|
* Get MIME type for a file path
|
|
53857
53917
|
*/
|
|
53858
|
-
getMimeType(
|
|
53859
|
-
const ext2 =
|
|
53918
|
+
getMimeType(path2) {
|
|
53919
|
+
const ext2 = path2.split(".").pop()?.toLowerCase() || "";
|
|
53860
53920
|
return MIME_TYPES[ext2] || "application/octet-stream";
|
|
53861
53921
|
}
|
|
53862
53922
|
/**
|
|
53863
53923
|
* Check if a path exists in the virtual filesystem
|
|
53864
53924
|
*/
|
|
53865
|
-
exists(
|
|
53925
|
+
exists(path2) {
|
|
53866
53926
|
try {
|
|
53867
|
-
this.vfs.statSync(
|
|
53927
|
+
this.vfs.statSync(path2);
|
|
53868
53928
|
return true;
|
|
53869
53929
|
} catch {
|
|
53870
53930
|
return false;
|
|
@@ -53873,9 +53933,9 @@ var DevServer = class extends EventEmitter {
|
|
|
53873
53933
|
/**
|
|
53874
53934
|
* Check if a path is a directory
|
|
53875
53935
|
*/
|
|
53876
|
-
isDirectory(
|
|
53936
|
+
isDirectory(path2) {
|
|
53877
53937
|
try {
|
|
53878
|
-
return this.vfs.statSync(
|
|
53938
|
+
return this.vfs.statSync(path2).isDirectory();
|
|
53879
53939
|
} catch {
|
|
53880
53940
|
return false;
|
|
53881
53941
|
}
|
|
@@ -54199,13 +54259,13 @@ var ViteDevServer = class extends DevServer {
|
|
|
54199
54259
|
/**
|
|
54200
54260
|
* Handle file change event
|
|
54201
54261
|
*/
|
|
54202
|
-
handleFileChange(
|
|
54203
|
-
const isCSS =
|
|
54204
|
-
const isJS = /\.(jsx?|tsx?)$/.test(
|
|
54262
|
+
handleFileChange(path2) {
|
|
54263
|
+
const isCSS = path2.endsWith(".css");
|
|
54264
|
+
const isJS = /\.(jsx?|tsx?)$/.test(path2);
|
|
54205
54265
|
const updateType = isCSS || isJS ? "update" : "full-reload";
|
|
54206
54266
|
const update = {
|
|
54207
54267
|
type: updateType,
|
|
54208
|
-
path:
|
|
54268
|
+
path: path2,
|
|
54209
54269
|
timestamp: Date.now()
|
|
54210
54270
|
};
|
|
54211
54271
|
this.emitHMRUpdate(update);
|
|
@@ -54230,8 +54290,8 @@ var ViteDevServer = class extends DevServer {
|
|
|
54230
54290
|
/**
|
|
54231
54291
|
* Check if a file needs transformation
|
|
54232
54292
|
*/
|
|
54233
|
-
needsTransform(
|
|
54234
|
-
return /\.(jsx|tsx|ts)$/.test(
|
|
54293
|
+
needsTransform(path2) {
|
|
54294
|
+
return /\.(jsx|tsx|ts)$/.test(path2);
|
|
54235
54295
|
}
|
|
54236
54296
|
/**
|
|
54237
54297
|
* Transform and serve a JSX/TS file
|
|
@@ -54483,7 +54543,7 @@ function wrapCjsAsEsm(code2, virtualPrefix = "", requestPath = "") {
|
|
|
54483
54543
|
if (!/\b(require\s*\(|module\.exports|exports\.)/.test(stripped)) {
|
|
54484
54544
|
return code2;
|
|
54485
54545
|
}
|
|
54486
|
-
const requestDir = requestPath ?
|
|
54546
|
+
const requestDir = requestPath ? posixPath.dirname(requestPath) : "";
|
|
54487
54547
|
const commentFree = code2.replace(
|
|
54488
54548
|
/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`|\/\*[\s\S]*?\*\/|\/\/[^\n]*)/g,
|
|
54489
54549
|
(m) => {
|
|
@@ -54504,7 +54564,7 @@ function wrapCjsAsEsm(code2, virtualPrefix = "", requestPath = "") {
|
|
|
54504
54564
|
const varName = `__cjs_req_${counter++}__`;
|
|
54505
54565
|
let resolvedSpec;
|
|
54506
54566
|
if (specifier.startsWith(".")) {
|
|
54507
|
-
resolvedSpec = `${virtualPrefix}${
|
|
54567
|
+
resolvedSpec = `${virtualPrefix}${posixPath.resolve(requestDir, specifier)}`;
|
|
54508
54568
|
} else {
|
|
54509
54569
|
resolvedSpec = `${virtualPrefix}/node_modules/${specifier}`;
|
|
54510
54570
|
}
|
|
@@ -54594,7 +54654,7 @@ async function ensureEsbuildWasm() {
|
|
|
54594
54654
|
await window.__esbuildInitPromise;
|
|
54595
54655
|
}
|
|
54596
54656
|
function normalizePath(inputPath) {
|
|
54597
|
-
return
|
|
54657
|
+
return posixPath.normalize(inputPath.trim() || "/") || "/";
|
|
54598
54658
|
}
|
|
54599
54659
|
function isInternalAlmostNodePath(targetPath) {
|
|
54600
54660
|
const normalizedPath = normalizePath(targetPath);
|
|
@@ -54654,7 +54714,7 @@ function removeVirtualPath(vfs2, targetPath) {
|
|
|
54654
54714
|
return;
|
|
54655
54715
|
}
|
|
54656
54716
|
for (const childName of vfs2.readdirSync(normalizedPath)) {
|
|
54657
|
-
removeVirtualPath(vfs2,
|
|
54717
|
+
removeVirtualPath(vfs2, posixPath.join(normalizedPath, childName));
|
|
54658
54718
|
}
|
|
54659
54719
|
vfs2.rmdirSync(normalizedPath);
|
|
54660
54720
|
}
|
|
@@ -54964,8 +55024,8 @@ var AlmostNodeSession = class {
|
|
|
54964
55024
|
return result;
|
|
54965
55025
|
}
|
|
54966
55026
|
async serveExistingVirtualStaticFile(root2, requestUrl, bufferCtor) {
|
|
54967
|
-
const basePath = normalizePath(
|
|
54968
|
-
const hasExtension = /\.[a-zA-Z0-9]+$/.test(
|
|
55027
|
+
const basePath = normalizePath(posixPath.join(root2, getRequestPathname(requestUrl)));
|
|
55028
|
+
const hasExtension = /\.[a-zA-Z0-9]+$/.test(posixPath.basename(basePath));
|
|
54969
55029
|
let candidates;
|
|
54970
55030
|
if (hasExtension) {
|
|
54971
55031
|
candidates = [basePath];
|
|
@@ -54977,7 +55037,7 @@ var AlmostNodeSession = class {
|
|
|
54977
55037
|
const raw = this.vfs.readFileSync(pkgPath, "utf8");
|
|
54978
55038
|
const pkg = this.parseCachedPackageJson(pkgPath, raw);
|
|
54979
55039
|
const entry = pkg ? typeof pkg.module === "string" && pkg.module || typeof pkg.main === "string" && pkg.main : null;
|
|
54980
|
-
if (entry) candidates.push(normalizePath(
|
|
55040
|
+
if (entry) candidates.push(normalizePath(posixPath.join(basePath, entry)));
|
|
54981
55041
|
}
|
|
54982
55042
|
} catch {
|
|
54983
55043
|
}
|
|
@@ -54986,7 +55046,7 @@ var AlmostNodeSession = class {
|
|
|
54986
55046
|
const raw = await this.fs.readFile(pkgPath, "utf-8");
|
|
54987
55047
|
const pkg = this.parseCachedPackageJson(pkgPath, raw);
|
|
54988
55048
|
const entry = pkg ? typeof pkg.module === "string" && pkg.module || typeof pkg.main === "string" && pkg.main : null;
|
|
54989
|
-
if (entry) candidates.push(normalizePath(
|
|
55049
|
+
if (entry) candidates.push(normalizePath(posixPath.join(basePath, entry)));
|
|
54990
55050
|
}
|
|
54991
55051
|
} catch {
|
|
54992
55052
|
}
|
|
@@ -55024,7 +55084,7 @@ var AlmostNodeSession = class {
|
|
|
55024
55084
|
}
|
|
55025
55085
|
const content = await this.fs.readFileBuffer(targetPath);
|
|
55026
55086
|
this._vfs.withoutMirror(() => {
|
|
55027
|
-
this._vfs.mkdirSync(
|
|
55087
|
+
this._vfs.mkdirSync(posixPath.dirname(targetPath), { recursive: true });
|
|
55028
55088
|
this._vfs.writeFileSync(targetPath, content);
|
|
55029
55089
|
});
|
|
55030
55090
|
const body = bufferCtor.from(content);
|
|
@@ -55070,7 +55130,7 @@ var AlmostNodeSession = class {
|
|
|
55070
55130
|
}
|
|
55071
55131
|
}
|
|
55072
55132
|
for (const packageName of candidatePackageNames) {
|
|
55073
|
-
const pkgJsonPath = normalizePath(
|
|
55133
|
+
const pkgJsonPath = normalizePath(posixPath.join(cwd, "node_modules", packageName, "package.json"));
|
|
55074
55134
|
if (!await this.fs.exists(pkgJsonPath)) {
|
|
55075
55135
|
continue;
|
|
55076
55136
|
}
|
|
@@ -55080,16 +55140,16 @@ var AlmostNodeSession = class {
|
|
|
55080
55140
|
if (!pkgJson) {
|
|
55081
55141
|
continue;
|
|
55082
55142
|
}
|
|
55083
|
-
const pkgDir = normalizePath(
|
|
55143
|
+
const pkgDir = normalizePath(posixPath.join(cwd, "node_modules", packageName));
|
|
55084
55144
|
if (typeof pkgJson.bin === "string") {
|
|
55085
55145
|
const inferredBinName = typeof pkgJson.name === "string" ? pkgJson.name.split("/").pop() ?? pkgJson.name : packageName.split("/").pop() ?? packageName;
|
|
55086
55146
|
if (binName === inferredBinName) {
|
|
55087
|
-
return normalizePath(
|
|
55147
|
+
return normalizePath(posixPath.join(pkgDir, pkgJson.bin));
|
|
55088
55148
|
}
|
|
55089
55149
|
}
|
|
55090
55150
|
if (typeof pkgJson.bin === "object" && pkgJson.bin !== null && binName in pkgJson.bin) {
|
|
55091
55151
|
const namedBins = pkgJson.bin;
|
|
55092
|
-
return normalizePath(
|
|
55152
|
+
return normalizePath(posixPath.join(pkgDir, namedBins[binName]));
|
|
55093
55153
|
}
|
|
55094
55154
|
} catch {
|
|
55095
55155
|
}
|
|
@@ -55176,7 +55236,7 @@ var AlmostNodeSession = class {
|
|
|
55176
55236
|
}
|
|
55177
55237
|
const content = await this.fs.readFileBuffer(normalizedPath);
|
|
55178
55238
|
this._vfs.withoutMirror(() => {
|
|
55179
|
-
this._vfs.mkdirSync(
|
|
55239
|
+
this._vfs.mkdirSync(posixPath.dirname(normalizedPath), { recursive: true });
|
|
55180
55240
|
this._vfs.writeFileSync(normalizedPath, content);
|
|
55181
55241
|
});
|
|
55182
55242
|
} catch {
|
|
@@ -55239,7 +55299,7 @@ var AlmostNodeSession = class {
|
|
|
55239
55299
|
});
|
|
55240
55300
|
this._vfs.withoutMirror(() => {
|
|
55241
55301
|
for (const [filePath, content] of contents) {
|
|
55242
|
-
this._vfs.mkdirSync(
|
|
55302
|
+
this._vfs.mkdirSync(posixPath.dirname(filePath), { recursive: true });
|
|
55243
55303
|
this._vfs.writeFileSync(filePath, content);
|
|
55244
55304
|
}
|
|
55245
55305
|
});
|
|
@@ -55260,7 +55320,7 @@ var AlmostNodeSession = class {
|
|
|
55260
55320
|
}
|
|
55261
55321
|
const dependencyPaths = [];
|
|
55262
55322
|
for (const packageName of getPackageJsonDependencyNames(packageJsonResult.pkgJson)) {
|
|
55263
|
-
const packageRoot = normalizePath(
|
|
55323
|
+
const packageRoot = normalizePath(posixPath.join(cwd, "node_modules", packageName));
|
|
55264
55324
|
if (!await this.fs.exists(packageRoot)) {
|
|
55265
55325
|
continue;
|
|
55266
55326
|
}
|
|
@@ -55294,7 +55354,7 @@ var AlmostNodeSession = class {
|
|
|
55294
55354
|
return;
|
|
55295
55355
|
}
|
|
55296
55356
|
await this.withSuppressedObservableMirroring(async () => {
|
|
55297
|
-
await ensureObservableDirectory(this.fs,
|
|
55357
|
+
await ensureObservableDirectory(this.fs, posixPath.dirname(normalizedPath));
|
|
55298
55358
|
await this.fs.writeFile(normalizedPath, data2);
|
|
55299
55359
|
});
|
|
55300
55360
|
})());
|
|
@@ -55329,7 +55389,7 @@ var AlmostNodeSession = class {
|
|
|
55329
55389
|
return;
|
|
55330
55390
|
}
|
|
55331
55391
|
await this.withSuppressedObservableMirroring(async () => {
|
|
55332
|
-
await ensureObservableDirectory(this.fs,
|
|
55392
|
+
await ensureObservableDirectory(this.fs, posixPath.dirname(normalizedNextPath));
|
|
55333
55393
|
await this.fs.mv(normalizedPreviousPath, normalizedNextPath);
|
|
55334
55394
|
});
|
|
55335
55395
|
})());
|
|
@@ -55350,7 +55410,7 @@ var AlmostNodeSession = class {
|
|
|
55350
55410
|
await this.initializePromise;
|
|
55351
55411
|
}
|
|
55352
55412
|
async readPackageJson(cwd) {
|
|
55353
|
-
const packageJsonPath = normalizePath(
|
|
55413
|
+
const packageJsonPath = normalizePath(posixPath.join(cwd, "package.json"));
|
|
55354
55414
|
if (!this.vfs.existsSync(packageJsonPath)) {
|
|
55355
55415
|
await this.copyObservablePathIntoVirtualFs(packageJsonPath, { force: true });
|
|
55356
55416
|
}
|
|
@@ -55462,7 +55522,7 @@ var AlmostNodeSession = class {
|
|
|
55462
55522
|
...baseEnv,
|
|
55463
55523
|
npm_lifecycle_event: scriptName,
|
|
55464
55524
|
PATH: Array.from(/* @__PURE__ */ new Set([
|
|
55465
|
-
normalizePath(
|
|
55525
|
+
normalizePath(posixPath.join(cwd, "node_modules/.bin")),
|
|
55466
55526
|
"/node_modules/.bin",
|
|
55467
55527
|
...(baseEnv.PATH?.trim() || DEFAULT_PATH).split(":").filter(Boolean)
|
|
55468
55528
|
])).join(":")
|
|
@@ -55664,7 +55724,7 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
55664
55724
|
message: `Unsupported node flag in just-bash: ${firstArg}`
|
|
55665
55725
|
};
|
|
55666
55726
|
}
|
|
55667
|
-
const scriptPath =
|
|
55727
|
+
const scriptPath = posixPath.isAbsolute(firstArg) ? normalizePath(firstArg) : normalizePath(posixPath.resolve(cwd, firstArg));
|
|
55668
55728
|
return {
|
|
55669
55729
|
kind: "run-file",
|
|
55670
55730
|
scriptPath,
|
|
@@ -55863,7 +55923,7 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
55863
55923
|
if (!targetPath.startsWith(`${cwdPrefix}node_modules/`)) {
|
|
55864
55924
|
return true;
|
|
55865
55925
|
}
|
|
55866
|
-
const baseName =
|
|
55926
|
+
const baseName = posixPath.basename(targetPath).toLowerCase();
|
|
55867
55927
|
if (baseName === "package.json") {
|
|
55868
55928
|
return true;
|
|
55869
55929
|
}
|
|
@@ -55881,7 +55941,7 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
55881
55941
|
});
|
|
55882
55942
|
this._vfs.withoutMirror(() => {
|
|
55883
55943
|
for (const [filePath, content] of contents) {
|
|
55884
|
-
this._vfs.mkdirSync(
|
|
55944
|
+
this._vfs.mkdirSync(posixPath.dirname(filePath), { recursive: true });
|
|
55885
55945
|
this._vfs.writeFileSync(filePath, content);
|
|
55886
55946
|
}
|
|
55887
55947
|
});
|
|
@@ -56002,17 +56062,17 @@ var DEFAULT_BASH_SHELL_ENV = {
|
|
|
56002
56062
|
var DEFAULT_BASH_COMMAND_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
56003
56063
|
var DEFAULT_BASH_OUTPUT_LIMIT = 1e4;
|
|
56004
56064
|
function normalizeBashPath(input) {
|
|
56005
|
-
const
|
|
56065
|
+
const posixPath2 = input.trim().replace(/\\/g, "/") || "/";
|
|
56006
56066
|
const segments = [];
|
|
56007
|
-
const
|
|
56008
|
-
for (const segment of
|
|
56067
|
+
const isAbsolute2 = posixPath2.startsWith("/");
|
|
56068
|
+
for (const segment of posixPath2.split("/")) {
|
|
56009
56069
|
if (segment === "..") {
|
|
56010
56070
|
segments.pop();
|
|
56011
56071
|
} else if (segment !== "." && segment !== "") {
|
|
56012
56072
|
segments.push(segment);
|
|
56013
56073
|
}
|
|
56014
56074
|
}
|
|
56015
|
-
return (
|
|
56075
|
+
return (isAbsolute2 ? "/" : "") + segments.join("/") || "/";
|
|
56016
56076
|
}
|
|
56017
56077
|
function truncateBashOutput(output, limitBytes = DEFAULT_BASH_OUTPUT_LIMIT) {
|
|
56018
56078
|
if (!output || output.length <= limitBytes) {
|
|
@@ -56039,7 +56099,8 @@ function createBrowserBashSession(options2 = {}) {
|
|
|
56039
56099
|
fs,
|
|
56040
56100
|
customCommands: [
|
|
56041
56101
|
Dx("node", async (args, ctx) => almostNodeSession.executeNode(args, ctx)),
|
|
56042
|
-
Dx("npm", async (args, ctx) => almostNodeSession.executeNpm(args, ctx))
|
|
56102
|
+
Dx("npm", async (args, ctx) => almostNodeSession.executeNpm(args, ctx)),
|
|
56103
|
+
...options2.customCommands ?? []
|
|
56043
56104
|
]
|
|
56044
56105
|
});
|
|
56045
56106
|
almostNodeSession.setBinCommandRegistrar((name, handler) => {
|