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.cjs
CHANGED
|
@@ -4758,32 +4758,32 @@ var init_pako_esm = __esm({
|
|
|
4758
4758
|
// node_modules/almostnode/src/shims/path.ts
|
|
4759
4759
|
var path_exports = {};
|
|
4760
4760
|
__export(path_exports, {
|
|
4761
|
-
basename: () =>
|
|
4761
|
+
basename: () => basename2,
|
|
4762
4762
|
default: () => path_default,
|
|
4763
4763
|
delimiter: () => delimiter,
|
|
4764
|
-
dirname: () =>
|
|
4764
|
+
dirname: () => dirname3,
|
|
4765
4765
|
extname: () => extname,
|
|
4766
4766
|
format: () => format,
|
|
4767
|
-
isAbsolute: () =>
|
|
4768
|
-
join: () =>
|
|
4769
|
-
normalize: () =>
|
|
4767
|
+
isAbsolute: () => isAbsolute2,
|
|
4768
|
+
join: () => join3,
|
|
4769
|
+
normalize: () => normalize2,
|
|
4770
4770
|
parse: () => parse,
|
|
4771
4771
|
posix: () => posix,
|
|
4772
|
-
relative: () =>
|
|
4773
|
-
resolve: () =>
|
|
4772
|
+
relative: () => relative2,
|
|
4773
|
+
resolve: () => resolve2,
|
|
4774
4774
|
sep: () => sep2,
|
|
4775
4775
|
win32: () => win32
|
|
4776
4776
|
});
|
|
4777
|
-
function
|
|
4778
|
-
if (!
|
|
4779
|
-
const
|
|
4780
|
-
const parts =
|
|
4777
|
+
function normalize2(path2) {
|
|
4778
|
+
if (!path2) return ".";
|
|
4779
|
+
const isAbsolute3 = path2.startsWith("/");
|
|
4780
|
+
const parts = path2.split("/").filter(Boolean);
|
|
4781
4781
|
const resolved = [];
|
|
4782
4782
|
for (const part of parts) {
|
|
4783
4783
|
if (part === "..") {
|
|
4784
4784
|
if (resolved.length > 0 && resolved[resolved.length - 1] !== "..") {
|
|
4785
4785
|
resolved.pop();
|
|
4786
|
-
} else if (!
|
|
4786
|
+
} else if (!isAbsolute3) {
|
|
4787
4787
|
resolved.push("..");
|
|
4788
4788
|
}
|
|
4789
4789
|
} else if (part !== ".") {
|
|
@@ -4791,57 +4791,57 @@ function normalize(path4) {
|
|
|
4791
4791
|
}
|
|
4792
4792
|
}
|
|
4793
4793
|
let result = resolved.join("/");
|
|
4794
|
-
if (
|
|
4794
|
+
if (isAbsolute3) {
|
|
4795
4795
|
result = "/" + result;
|
|
4796
4796
|
}
|
|
4797
4797
|
return result || ".";
|
|
4798
4798
|
}
|
|
4799
|
-
function
|
|
4799
|
+
function join3(...paths) {
|
|
4800
4800
|
if (paths.length === 0) return ".";
|
|
4801
|
-
return
|
|
4801
|
+
return normalize2(paths.filter(Boolean).join("/"));
|
|
4802
4802
|
}
|
|
4803
|
-
function
|
|
4803
|
+
function resolve2(...paths) {
|
|
4804
4804
|
let resolvedPath2 = "";
|
|
4805
4805
|
for (let i = paths.length - 1; i >= 0 && !resolvedPath2.startsWith("/"); i--) {
|
|
4806
|
-
const
|
|
4807
|
-
if (!
|
|
4808
|
-
resolvedPath2 =
|
|
4806
|
+
const path2 = paths[i];
|
|
4807
|
+
if (!path2) continue;
|
|
4808
|
+
resolvedPath2 = path2 + (resolvedPath2 ? "/" + resolvedPath2 : "");
|
|
4809
4809
|
}
|
|
4810
4810
|
if (!resolvedPath2.startsWith("/")) {
|
|
4811
4811
|
const cwd = typeof globalThis !== "undefined" && globalThis.process && typeof globalThis.process.cwd === "function" ? globalThis.process.cwd() : "/";
|
|
4812
4812
|
resolvedPath2 = cwd + (resolvedPath2 ? "/" + resolvedPath2 : "");
|
|
4813
4813
|
}
|
|
4814
|
-
return
|
|
4814
|
+
return normalize2(resolvedPath2);
|
|
4815
4815
|
}
|
|
4816
|
-
function
|
|
4817
|
-
return
|
|
4816
|
+
function isAbsolute2(path2) {
|
|
4817
|
+
return path2.startsWith("/");
|
|
4818
4818
|
}
|
|
4819
|
-
function
|
|
4820
|
-
if (!
|
|
4821
|
-
const normalized =
|
|
4819
|
+
function dirname3(path2) {
|
|
4820
|
+
if (!path2) return ".";
|
|
4821
|
+
const normalized = normalize2(path2);
|
|
4822
4822
|
const lastSlash = normalized.lastIndexOf("/");
|
|
4823
4823
|
if (lastSlash === -1) return ".";
|
|
4824
4824
|
if (lastSlash === 0) return "/";
|
|
4825
4825
|
return normalized.slice(0, lastSlash);
|
|
4826
4826
|
}
|
|
4827
|
-
function
|
|
4828
|
-
if (!
|
|
4829
|
-
const normalized =
|
|
4827
|
+
function basename2(path2, ext2) {
|
|
4828
|
+
if (!path2) return "";
|
|
4829
|
+
const normalized = normalize2(path2);
|
|
4830
4830
|
let base = normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
4831
4831
|
if (ext2 && base.endsWith(ext2)) {
|
|
4832
4832
|
base = base.slice(0, -ext2.length);
|
|
4833
4833
|
}
|
|
4834
4834
|
return base;
|
|
4835
4835
|
}
|
|
4836
|
-
function extname(
|
|
4837
|
-
const base =
|
|
4836
|
+
function extname(path2) {
|
|
4837
|
+
const base = basename2(path2);
|
|
4838
4838
|
const dotIndex = base.lastIndexOf(".");
|
|
4839
4839
|
if (dotIndex <= 0) return "";
|
|
4840
4840
|
return base.slice(dotIndex);
|
|
4841
4841
|
}
|
|
4842
|
-
function
|
|
4843
|
-
from =
|
|
4844
|
-
to2 =
|
|
4842
|
+
function relative2(from, to2) {
|
|
4843
|
+
from = resolve2(from);
|
|
4844
|
+
to2 = resolve2(to2);
|
|
4845
4845
|
if (from === to2) return "";
|
|
4846
4846
|
const fromParts = from.split("/").filter(Boolean);
|
|
4847
4847
|
const toParts = to2.split("/").filter(Boolean);
|
|
@@ -4855,11 +4855,11 @@ function relative(from, to2) {
|
|
|
4855
4855
|
const result = [...Array(upCount).fill(".."), ...remainingPath];
|
|
4856
4856
|
return result.join("/") || ".";
|
|
4857
4857
|
}
|
|
4858
|
-
function parse(
|
|
4859
|
-
const normalized =
|
|
4860
|
-
const isAbs =
|
|
4861
|
-
const dir =
|
|
4862
|
-
const base =
|
|
4858
|
+
function parse(path2) {
|
|
4859
|
+
const normalized = normalize2(path2);
|
|
4860
|
+
const isAbs = isAbsolute2(normalized);
|
|
4861
|
+
const dir = dirname3(normalized);
|
|
4862
|
+
const base = basename2(normalized);
|
|
4863
4863
|
const ext2 = extname(normalized);
|
|
4864
4864
|
const name = base.slice(0, base.length - ext2.length);
|
|
4865
4865
|
return {
|
|
@@ -4885,42 +4885,42 @@ var init_path = __esm({
|
|
|
4885
4885
|
posix = {
|
|
4886
4886
|
sep: sep2,
|
|
4887
4887
|
delimiter,
|
|
4888
|
-
normalize,
|
|
4889
|
-
join:
|
|
4890
|
-
resolve,
|
|
4891
|
-
isAbsolute,
|
|
4892
|
-
dirname:
|
|
4893
|
-
basename,
|
|
4888
|
+
normalize: normalize2,
|
|
4889
|
+
join: join3,
|
|
4890
|
+
resolve: resolve2,
|
|
4891
|
+
isAbsolute: isAbsolute2,
|
|
4892
|
+
dirname: dirname3,
|
|
4893
|
+
basename: basename2,
|
|
4894
4894
|
extname,
|
|
4895
|
-
relative,
|
|
4895
|
+
relative: relative2,
|
|
4896
4896
|
parse,
|
|
4897
4897
|
format
|
|
4898
4898
|
};
|
|
4899
4899
|
win32 = {
|
|
4900
4900
|
sep: "\\",
|
|
4901
4901
|
delimiter: ";",
|
|
4902
|
-
normalize,
|
|
4903
|
-
join:
|
|
4904
|
-
resolve,
|
|
4905
|
-
isAbsolute,
|
|
4906
|
-
dirname:
|
|
4907
|
-
basename,
|
|
4902
|
+
normalize: normalize2,
|
|
4903
|
+
join: join3,
|
|
4904
|
+
resolve: resolve2,
|
|
4905
|
+
isAbsolute: isAbsolute2,
|
|
4906
|
+
dirname: dirname3,
|
|
4907
|
+
basename: basename2,
|
|
4908
4908
|
extname,
|
|
4909
|
-
relative,
|
|
4909
|
+
relative: relative2,
|
|
4910
4910
|
parse,
|
|
4911
4911
|
format
|
|
4912
4912
|
};
|
|
4913
4913
|
path_default = {
|
|
4914
4914
|
sep: sep2,
|
|
4915
4915
|
delimiter,
|
|
4916
|
-
normalize,
|
|
4917
|
-
join:
|
|
4918
|
-
resolve,
|
|
4919
|
-
isAbsolute,
|
|
4920
|
-
dirname:
|
|
4921
|
-
basename,
|
|
4916
|
+
normalize: normalize2,
|
|
4917
|
+
join: join3,
|
|
4918
|
+
resolve: resolve2,
|
|
4919
|
+
isAbsolute: isAbsolute2,
|
|
4920
|
+
dirname: dirname3,
|
|
4921
|
+
basename: basename2,
|
|
4922
4922
|
extname,
|
|
4923
|
-
relative,
|
|
4923
|
+
relative: relative2,
|
|
4924
4924
|
parse,
|
|
4925
4925
|
format,
|
|
4926
4926
|
posix,
|
|
@@ -5017,11 +5017,11 @@ function extractTarball(tarballData, vfs2, destPath, options2 = {}) {
|
|
|
5017
5017
|
if (filter2 && !filter2(entryPath)) {
|
|
5018
5018
|
continue;
|
|
5019
5019
|
}
|
|
5020
|
-
const fullPath =
|
|
5020
|
+
const fullPath = join3(destPath, entryPath);
|
|
5021
5021
|
if (entry.type === "directory") {
|
|
5022
5022
|
vfs2.mkdirSync(fullPath, { recursive: true });
|
|
5023
5023
|
} else if (entry.type === "file" && entry.content) {
|
|
5024
|
-
const parentDir =
|
|
5024
|
+
const parentDir = dirname3(fullPath);
|
|
5025
5025
|
vfs2.mkdirSync(parentDir, { recursive: true });
|
|
5026
5026
|
vfs2.writeFileSync(fullPath, entry.content);
|
|
5027
5027
|
extractedFiles.push(fullPath);
|
|
@@ -5414,7 +5414,7 @@ var init_npm = __esm({
|
|
|
5414
5414
|
*/
|
|
5415
5415
|
async installFromPackageJson(options2 = {}) {
|
|
5416
5416
|
const { onProgress } = options2;
|
|
5417
|
-
const pkgJsonPath =
|
|
5417
|
+
const pkgJsonPath = join3(this.cwd, "package.json");
|
|
5418
5418
|
if (!this.vfs.existsSync(pkgJsonPath)) {
|
|
5419
5419
|
throw new Error("No package.json found");
|
|
5420
5420
|
}
|
|
@@ -5436,12 +5436,12 @@ var init_npm = __esm({
|
|
|
5436
5436
|
async installResolved(resolved, options2) {
|
|
5437
5437
|
const { onProgress } = options2;
|
|
5438
5438
|
const added = [];
|
|
5439
|
-
const nodeModulesPath =
|
|
5439
|
+
const nodeModulesPath = join3(this.cwd, "node_modules");
|
|
5440
5440
|
this.vfs.mkdirSync(nodeModulesPath, { recursive: true });
|
|
5441
5441
|
const toInstall = [];
|
|
5442
5442
|
for (const [name, pkg] of resolved) {
|
|
5443
|
-
const pkgPath =
|
|
5444
|
-
const existingPkgJson =
|
|
5443
|
+
const pkgPath = join3(nodeModulesPath, name);
|
|
5444
|
+
const existingPkgJson = join3(pkgPath, "package.json");
|
|
5445
5445
|
if (this.vfs.existsSync(existingPkgJson)) {
|
|
5446
5446
|
try {
|
|
5447
5447
|
const existing = JSON.parse(
|
|
@@ -5483,16 +5483,16 @@ var init_npm = __esm({
|
|
|
5483
5483
|
}
|
|
5484
5484
|
}
|
|
5485
5485
|
try {
|
|
5486
|
-
const pkgJsonPath =
|
|
5486
|
+
const pkgJsonPath = join3(pkgPath, "package.json");
|
|
5487
5487
|
if (this.vfs.existsSync(pkgJsonPath)) {
|
|
5488
5488
|
const pkgJson = JSON.parse(this.vfs.readFileSync(pkgJsonPath, "utf8"));
|
|
5489
5489
|
const binEntries = normalizeBin(name, pkgJson.bin);
|
|
5490
|
-
const binDir =
|
|
5490
|
+
const binDir = join3(nodeModulesPath, ".bin");
|
|
5491
5491
|
for (const [cmdName, entryPath] of Object.entries(binEntries)) {
|
|
5492
5492
|
this.vfs.mkdirSync(binDir, { recursive: true });
|
|
5493
|
-
const targetPath =
|
|
5493
|
+
const targetPath = join3(pkgPath, entryPath);
|
|
5494
5494
|
this.vfs.writeFileSync(
|
|
5495
|
-
|
|
5495
|
+
join3(binDir, cmdName),
|
|
5496
5496
|
`node "${targetPath}" "$@"
|
|
5497
5497
|
`
|
|
5498
5498
|
);
|
|
@@ -5518,14 +5518,14 @@ var init_npm = __esm({
|
|
|
5518
5518
|
resolved: pkg.tarballUrl
|
|
5519
5519
|
};
|
|
5520
5520
|
}
|
|
5521
|
-
const lockfilePath =
|
|
5521
|
+
const lockfilePath = join3(this.cwd, "node_modules", ".package-lock.json");
|
|
5522
5522
|
this.vfs.writeFileSync(lockfilePath, JSON.stringify(lockfile, null, 2));
|
|
5523
5523
|
}
|
|
5524
5524
|
/**
|
|
5525
5525
|
* Update package.json with new dependency
|
|
5526
5526
|
*/
|
|
5527
5527
|
async updatePackageJson(packageName, version4, isDev) {
|
|
5528
|
-
const pkgJsonPath =
|
|
5528
|
+
const pkgJsonPath = join3(this.cwd, "package.json");
|
|
5529
5529
|
let pkgJson = {};
|
|
5530
5530
|
if (this.vfs.existsSync(pkgJsonPath)) {
|
|
5531
5531
|
pkgJson = JSON.parse(this.vfs.readFileSync(pkgJsonPath, "utf8"));
|
|
@@ -5541,7 +5541,7 @@ var init_npm = __esm({
|
|
|
5541
5541
|
* List installed packages
|
|
5542
5542
|
*/
|
|
5543
5543
|
list() {
|
|
5544
|
-
const nodeModulesPath =
|
|
5544
|
+
const nodeModulesPath = join3(this.cwd, "node_modules");
|
|
5545
5545
|
if (!this.vfs.existsSync(nodeModulesPath)) {
|
|
5546
5546
|
return {};
|
|
5547
5547
|
}
|
|
@@ -5550,17 +5550,17 @@ var init_npm = __esm({
|
|
|
5550
5550
|
for (const entry of entries) {
|
|
5551
5551
|
if (entry.startsWith(".")) continue;
|
|
5552
5552
|
if (entry.startsWith("@")) {
|
|
5553
|
-
const scopePath =
|
|
5553
|
+
const scopePath = join3(nodeModulesPath, entry);
|
|
5554
5554
|
const scopedPkgs = this.vfs.readdirSync(scopePath);
|
|
5555
5555
|
for (const scopedPkg of scopedPkgs) {
|
|
5556
|
-
const pkgJsonPath =
|
|
5556
|
+
const pkgJsonPath = join3(scopePath, scopedPkg, "package.json");
|
|
5557
5557
|
if (this.vfs.existsSync(pkgJsonPath)) {
|
|
5558
5558
|
const pkgJson = JSON.parse(this.vfs.readFileSync(pkgJsonPath, "utf8"));
|
|
5559
5559
|
packages[`${entry}/${scopedPkg}`] = pkgJson.version;
|
|
5560
5560
|
}
|
|
5561
5561
|
}
|
|
5562
5562
|
} else {
|
|
5563
|
-
const pkgJsonPath =
|
|
5563
|
+
const pkgJsonPath = join3(nodeModulesPath, entry, "package.json");
|
|
5564
5564
|
if (this.vfs.existsSync(pkgJsonPath)) {
|
|
5565
5565
|
const pkgJson = JSON.parse(this.vfs.readFileSync(pkgJsonPath, "utf8"));
|
|
5566
5566
|
packages[entry] = pkgJson.version;
|
|
@@ -7940,16 +7940,16 @@ var Diff = class {
|
|
|
7940
7940
|
}
|
|
7941
7941
|
}
|
|
7942
7942
|
}
|
|
7943
|
-
addToPath(
|
|
7944
|
-
const last =
|
|
7943
|
+
addToPath(path2, added, removed, oldPosInc, options2) {
|
|
7944
|
+
const last = path2.lastComponent;
|
|
7945
7945
|
if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
7946
7946
|
return {
|
|
7947
|
-
oldPos:
|
|
7947
|
+
oldPos: path2.oldPos + oldPosInc,
|
|
7948
7948
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
7949
7949
|
};
|
|
7950
7950
|
} else {
|
|
7951
7951
|
return {
|
|
7952
|
-
oldPos:
|
|
7952
|
+
oldPos: path2.oldPos + oldPosInc,
|
|
7953
7953
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
7954
7954
|
};
|
|
7955
7955
|
}
|
|
@@ -42271,8 +42271,71 @@ function G7(e10) {
|
|
|
42271
42271
|
}
|
|
42272
42272
|
}
|
|
42273
42273
|
|
|
42274
|
+
// src/posix-path.ts
|
|
42275
|
+
function normalize(p) {
|
|
42276
|
+
if (p === "") return ".";
|
|
42277
|
+
const isAbsolute3 = p.charCodeAt(0) === 47;
|
|
42278
|
+
const trailingSlash = p.charCodeAt(p.length - 1) === 47;
|
|
42279
|
+
const segments = [];
|
|
42280
|
+
for (const seg of p.split("/")) {
|
|
42281
|
+
if (seg === ".." && segments.length > 0 && segments[segments.length - 1] !== "..") {
|
|
42282
|
+
segments.pop();
|
|
42283
|
+
} else if (seg !== "." && seg !== "") {
|
|
42284
|
+
segments.push(seg);
|
|
42285
|
+
}
|
|
42286
|
+
}
|
|
42287
|
+
let result = segments.join("/");
|
|
42288
|
+
if (isAbsolute3) result = "/" + result;
|
|
42289
|
+
if (trailingSlash && result.length > 1) result += "/";
|
|
42290
|
+
return result || (isAbsolute3 ? "/" : ".");
|
|
42291
|
+
}
|
|
42292
|
+
function join2(...parts) {
|
|
42293
|
+
return normalize(parts.filter(Boolean).join("/"));
|
|
42294
|
+
}
|
|
42295
|
+
function resolve(...parts) {
|
|
42296
|
+
let resolved = "";
|
|
42297
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
42298
|
+
const p = parts[i];
|
|
42299
|
+
if (!p) continue;
|
|
42300
|
+
resolved = resolved ? p + "/" + resolved : p;
|
|
42301
|
+
if (p.charCodeAt(0) === 47) break;
|
|
42302
|
+
}
|
|
42303
|
+
return normalize(resolved || "/");
|
|
42304
|
+
}
|
|
42305
|
+
function dirname2(p) {
|
|
42306
|
+
if (p === "" || p === "/") return p || ".";
|
|
42307
|
+
const i = p.lastIndexOf("/");
|
|
42308
|
+
if (i === -1) return ".";
|
|
42309
|
+
if (i === 0) return "/";
|
|
42310
|
+
return p.slice(0, i);
|
|
42311
|
+
}
|
|
42312
|
+
function basename(p, ext2) {
|
|
42313
|
+
let base = p.slice(p.lastIndexOf("/") + 1);
|
|
42314
|
+
if (ext2 && base.endsWith(ext2)) {
|
|
42315
|
+
base = base.slice(0, -ext2.length);
|
|
42316
|
+
}
|
|
42317
|
+
return base;
|
|
42318
|
+
}
|
|
42319
|
+
function relative(from, to2) {
|
|
42320
|
+
from = resolve(from);
|
|
42321
|
+
to2 = resolve(to2);
|
|
42322
|
+
if (from === to2) return "";
|
|
42323
|
+
const fromParts = from.split("/").filter(Boolean);
|
|
42324
|
+
const toParts = to2.split("/").filter(Boolean);
|
|
42325
|
+
let common2 = 0;
|
|
42326
|
+
while (common2 < fromParts.length && common2 < toParts.length && fromParts[common2] === toParts[common2]) {
|
|
42327
|
+
common2++;
|
|
42328
|
+
}
|
|
42329
|
+
const ups = fromParts.length - common2;
|
|
42330
|
+
const remaining = toParts.slice(common2);
|
|
42331
|
+
return [...Array(ups).fill(".."), ...remaining].join("/");
|
|
42332
|
+
}
|
|
42333
|
+
function isAbsolute(p) {
|
|
42334
|
+
return p.length > 0 && p.charCodeAt(0) === 47;
|
|
42335
|
+
}
|
|
42336
|
+
var posixPath = { normalize, join: join2, resolve, dirname: dirname2, basename, relative, isAbsolute };
|
|
42337
|
+
|
|
42274
42338
|
// src/observable-in-memory-fs.ts
|
|
42275
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
42276
42339
|
function isObservableInMemoryFsLike(value) {
|
|
42277
42340
|
if (!value || typeof value !== "object") {
|
|
42278
42341
|
return false;
|
|
@@ -42299,18 +42362,18 @@ function normalizeEntryType(stat) {
|
|
|
42299
42362
|
}
|
|
42300
42363
|
return "file";
|
|
42301
42364
|
}
|
|
42302
|
-
async function readPathState(fs,
|
|
42303
|
-
const exists = await fs.exists(
|
|
42365
|
+
async function readPathState(fs, path2) {
|
|
42366
|
+
const exists = await fs.exists(path2);
|
|
42304
42367
|
if (!exists) {
|
|
42305
42368
|
return { exists: false };
|
|
42306
42369
|
}
|
|
42307
|
-
if (isObservableInMemoryFsLike(fs) && fs.isPathLazy(
|
|
42370
|
+
if (isObservableInMemoryFsLike(fs) && fs.isPathLazy(path2)) {
|
|
42308
42371
|
return {
|
|
42309
42372
|
exists: true,
|
|
42310
42373
|
entryType: "file"
|
|
42311
42374
|
};
|
|
42312
42375
|
}
|
|
42313
|
-
const stat = await fs.lstat(
|
|
42376
|
+
const stat = await fs.lstat(path2);
|
|
42314
42377
|
return {
|
|
42315
42378
|
exists: true,
|
|
42316
42379
|
entryType: normalizeEntryType(stat)
|
|
@@ -42323,7 +42386,7 @@ function mapUnlinkEvent(entryType) {
|
|
|
42323
42386
|
return entryType === "directory" ? "unlinkDir" : "unlink";
|
|
42324
42387
|
}
|
|
42325
42388
|
function normalizeFsPathForLogScope(fsPath) {
|
|
42326
|
-
const normalized =
|
|
42389
|
+
const normalized = posixPath.normalize(fsPath);
|
|
42327
42390
|
return normalized === "." ? "/" : normalized;
|
|
42328
42391
|
}
|
|
42329
42392
|
function createWorkspacePathFilter(workspaceRoot) {
|
|
@@ -42333,7 +42396,7 @@ function createWorkspacePathFilter(workspaceRoot) {
|
|
|
42333
42396
|
if (normalizedPath !== normalizedWorkspaceRoot && !normalizedPath.startsWith(`${normalizedWorkspaceRoot}/`)) {
|
|
42334
42397
|
return false;
|
|
42335
42398
|
}
|
|
42336
|
-
const relativePath =
|
|
42399
|
+
const relativePath = posixPath.relative(normalizedWorkspaceRoot, normalizedPath);
|
|
42337
42400
|
if (!relativePath || relativePath === ".") {
|
|
42338
42401
|
return true;
|
|
42339
42402
|
}
|
|
@@ -42447,124 +42510,124 @@ var ObservableInMemoryFs = class extends Ir {
|
|
|
42447
42510
|
this.suppressSyncEventCount -= 1;
|
|
42448
42511
|
}
|
|
42449
42512
|
}
|
|
42450
|
-
writeFileSync(
|
|
42451
|
-
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this,
|
|
42452
|
-
super.writeFileSync(
|
|
42453
|
-
this.clearLazyPath(
|
|
42513
|
+
writeFileSync(path2, content, options2, metadata) {
|
|
42514
|
+
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this, path2);
|
|
42515
|
+
super.writeFileSync(path2, content, options2, metadata);
|
|
42516
|
+
this.clearLazyPath(path2);
|
|
42454
42517
|
if (!previous) {
|
|
42455
42518
|
return;
|
|
42456
42519
|
}
|
|
42457
|
-
this.queueChangeEmission(previous.then((state) => this.emitWriteEvent(
|
|
42520
|
+
this.queueChangeEmission(previous.then((state) => this.emitWriteEvent(path2, state)));
|
|
42458
42521
|
}
|
|
42459
|
-
writeFileLazy(
|
|
42460
|
-
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this,
|
|
42461
|
-
super.writeFileLazy(
|
|
42462
|
-
this.lazyPaths.add(normalizeFsPathForLogScope(
|
|
42522
|
+
writeFileLazy(path2, lazy, metadata) {
|
|
42523
|
+
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this, path2);
|
|
42524
|
+
super.writeFileLazy(path2, lazy, metadata);
|
|
42525
|
+
this.lazyPaths.add(normalizeFsPathForLogScope(path2));
|
|
42463
42526
|
if (!previous) {
|
|
42464
42527
|
return;
|
|
42465
42528
|
}
|
|
42466
|
-
this.queueChangeEmission(previous.then((state) => this.emitWriteEvent(
|
|
42529
|
+
this.queueChangeEmission(previous.then((state) => this.emitWriteEvent(path2, state)));
|
|
42467
42530
|
}
|
|
42468
|
-
async emitWriteEvent(
|
|
42469
|
-
const current2 = await readPathState(this,
|
|
42531
|
+
async emitWriteEvent(path2, previous) {
|
|
42532
|
+
const current2 = await readPathState(this, path2);
|
|
42470
42533
|
if (!current2.exists || !current2.entryType) {
|
|
42471
42534
|
return;
|
|
42472
42535
|
}
|
|
42473
42536
|
if (!previous.exists) {
|
|
42474
42537
|
this.emit({
|
|
42475
42538
|
event: mapAddEvent(current2.entryType),
|
|
42476
|
-
path:
|
|
42539
|
+
path: path2,
|
|
42477
42540
|
entryType: current2.entryType
|
|
42478
42541
|
});
|
|
42479
42542
|
return;
|
|
42480
42543
|
}
|
|
42481
42544
|
this.emit({
|
|
42482
42545
|
event: "change",
|
|
42483
|
-
path:
|
|
42546
|
+
path: path2,
|
|
42484
42547
|
entryType: current2.entryType
|
|
42485
42548
|
});
|
|
42486
42549
|
}
|
|
42487
|
-
async emitMkdirEvent(
|
|
42488
|
-
const current2 = await readPathState(this,
|
|
42550
|
+
async emitMkdirEvent(path2, previous) {
|
|
42551
|
+
const current2 = await readPathState(this, path2);
|
|
42489
42552
|
if (!current2.exists || current2.entryType !== "directory" || previous.exists) {
|
|
42490
42553
|
return;
|
|
42491
42554
|
}
|
|
42492
42555
|
this.emit({
|
|
42493
42556
|
event: "addDir",
|
|
42494
|
-
path:
|
|
42557
|
+
path: path2,
|
|
42495
42558
|
entryType: "directory"
|
|
42496
42559
|
});
|
|
42497
42560
|
}
|
|
42498
|
-
emitRemovalEvent(
|
|
42561
|
+
emitRemovalEvent(path2, previous, options2) {
|
|
42499
42562
|
if (!previous.exists || !previous.entryType) {
|
|
42500
42563
|
return;
|
|
42501
42564
|
}
|
|
42502
42565
|
this.emit({
|
|
42503
42566
|
event: mapUnlinkEvent(previous.entryType),
|
|
42504
|
-
path:
|
|
42567
|
+
path: path2,
|
|
42505
42568
|
entryType: previous.entryType
|
|
42506
42569
|
}, options2);
|
|
42507
42570
|
}
|
|
42508
|
-
mkdirSync(
|
|
42509
|
-
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this,
|
|
42510
|
-
super.mkdirSync(
|
|
42571
|
+
mkdirSync(path2, options2) {
|
|
42572
|
+
const previous = this.areSyncEventsSuppressed() || !this.shouldEmitChanges() ? null : readPathState(this, path2);
|
|
42573
|
+
super.mkdirSync(path2, options2);
|
|
42511
42574
|
if (!previous) {
|
|
42512
42575
|
return;
|
|
42513
42576
|
}
|
|
42514
|
-
this.queueChangeEmission(previous.then((state) => this.emitMkdirEvent(
|
|
42577
|
+
this.queueChangeEmission(previous.then((state) => this.emitMkdirEvent(path2, state)));
|
|
42515
42578
|
}
|
|
42516
|
-
async readFileBuffer(
|
|
42517
|
-
const content = await super.readFileBuffer(
|
|
42518
|
-
this.clearLazyPath(
|
|
42579
|
+
async readFileBuffer(path2) {
|
|
42580
|
+
const content = await super.readFileBuffer(path2);
|
|
42581
|
+
this.clearLazyPath(path2);
|
|
42519
42582
|
return content;
|
|
42520
42583
|
}
|
|
42521
|
-
async stat(
|
|
42522
|
-
const stat = await super.stat(
|
|
42523
|
-
this.clearLazyPath(
|
|
42584
|
+
async stat(path2) {
|
|
42585
|
+
const stat = await super.stat(path2);
|
|
42586
|
+
this.clearLazyPath(path2);
|
|
42524
42587
|
return stat;
|
|
42525
42588
|
}
|
|
42526
|
-
async lstat(
|
|
42527
|
-
const stat = await super.lstat(
|
|
42528
|
-
this.clearLazyPath(
|
|
42589
|
+
async lstat(path2) {
|
|
42590
|
+
const stat = await super.lstat(path2);
|
|
42591
|
+
this.clearLazyPath(path2);
|
|
42529
42592
|
return stat;
|
|
42530
42593
|
}
|
|
42531
|
-
async writeFile(
|
|
42594
|
+
async writeFile(path2, content, options2) {
|
|
42532
42595
|
if (!this.shouldEmitChanges()) {
|
|
42533
|
-
await super.writeFile(
|
|
42596
|
+
await super.writeFile(path2, content, options2);
|
|
42534
42597
|
return;
|
|
42535
42598
|
}
|
|
42536
|
-
const previous = await readPathState(this,
|
|
42537
|
-
await this.runWithSuppressedSyncEvents(() => super.writeFile(
|
|
42538
|
-
await this.emitWriteEvent(
|
|
42599
|
+
const previous = await readPathState(this, path2);
|
|
42600
|
+
await this.runWithSuppressedSyncEvents(() => super.writeFile(path2, content, options2));
|
|
42601
|
+
await this.emitWriteEvent(path2, previous);
|
|
42539
42602
|
}
|
|
42540
|
-
async appendFile(
|
|
42603
|
+
async appendFile(path2, content, options2) {
|
|
42541
42604
|
if (!this.shouldEmitChanges()) {
|
|
42542
|
-
await super.appendFile(
|
|
42605
|
+
await super.appendFile(path2, content, options2);
|
|
42543
42606
|
return;
|
|
42544
42607
|
}
|
|
42545
|
-
const previous = await readPathState(this,
|
|
42546
|
-
await this.runWithSuppressedSyncEvents(() => super.appendFile(
|
|
42547
|
-
await this.emitWriteEvent(
|
|
42608
|
+
const previous = await readPathState(this, path2);
|
|
42609
|
+
await this.runWithSuppressedSyncEvents(() => super.appendFile(path2, content, options2));
|
|
42610
|
+
await this.emitWriteEvent(path2, previous);
|
|
42548
42611
|
}
|
|
42549
|
-
async mkdir(
|
|
42612
|
+
async mkdir(path2, options2) {
|
|
42550
42613
|
if (!this.shouldEmitChanges()) {
|
|
42551
|
-
await super.mkdir(
|
|
42614
|
+
await super.mkdir(path2, options2);
|
|
42552
42615
|
return;
|
|
42553
42616
|
}
|
|
42554
|
-
const previous = await readPathState(this,
|
|
42555
|
-
await this.runWithSuppressedSyncEvents(() => super.mkdir(
|
|
42556
|
-
await this.emitMkdirEvent(
|
|
42617
|
+
const previous = await readPathState(this, path2);
|
|
42618
|
+
await this.runWithSuppressedSyncEvents(() => super.mkdir(path2, options2));
|
|
42619
|
+
await this.emitMkdirEvent(path2, previous);
|
|
42557
42620
|
}
|
|
42558
|
-
async rm(
|
|
42621
|
+
async rm(path2, options2) {
|
|
42559
42622
|
if (!this.shouldEmitChanges()) {
|
|
42560
|
-
await super.rm(
|
|
42561
|
-
this.clearLazyPathsUnder(
|
|
42623
|
+
await super.rm(path2, options2);
|
|
42624
|
+
this.clearLazyPathsUnder(path2);
|
|
42562
42625
|
return;
|
|
42563
42626
|
}
|
|
42564
|
-
const previous = await readPathState(this,
|
|
42565
|
-
await super.rm(
|
|
42566
|
-
this.clearLazyPathsUnder(
|
|
42567
|
-
this.emitRemovalEvent(
|
|
42627
|
+
const previous = await readPathState(this, path2);
|
|
42628
|
+
await super.rm(path2, options2);
|
|
42629
|
+
this.clearLazyPathsUnder(path2);
|
|
42630
|
+
this.emitRemovalEvent(path2, previous);
|
|
42568
42631
|
}
|
|
42569
42632
|
async cp(src, dest, options2) {
|
|
42570
42633
|
if (!this.shouldEmitChanges()) {
|
|
@@ -42637,19 +42700,19 @@ var ObservableInMemoryFs = class extends Ir {
|
|
|
42637
42700
|
shouldConsoleLog: shouldConsoleLogMove
|
|
42638
42701
|
});
|
|
42639
42702
|
}
|
|
42640
|
-
async chmod(
|
|
42703
|
+
async chmod(path2, mode) {
|
|
42641
42704
|
if (!this.shouldEmitChanges()) {
|
|
42642
|
-
await super.chmod(
|
|
42705
|
+
await super.chmod(path2, mode);
|
|
42643
42706
|
return;
|
|
42644
42707
|
}
|
|
42645
|
-
await super.chmod(
|
|
42646
|
-
const current2 = await readPathState(this,
|
|
42708
|
+
await super.chmod(path2, mode);
|
|
42709
|
+
const current2 = await readPathState(this, path2);
|
|
42647
42710
|
if (!current2.exists || !current2.entryType) {
|
|
42648
42711
|
return;
|
|
42649
42712
|
}
|
|
42650
42713
|
this.emit({
|
|
42651
42714
|
event: "change",
|
|
42652
|
-
path:
|
|
42715
|
+
path: path2,
|
|
42653
42716
|
entryType: current2.entryType
|
|
42654
42717
|
});
|
|
42655
42718
|
}
|
|
@@ -42671,26 +42734,25 @@ var ObservableInMemoryFs = class extends Ir {
|
|
|
42671
42734
|
await super.link(existingPath, newPath);
|
|
42672
42735
|
await this.emitWriteEvent(newPath, previous);
|
|
42673
42736
|
}
|
|
42674
|
-
async utimes(
|
|
42737
|
+
async utimes(path2, atime, mtime) {
|
|
42675
42738
|
if (!this.shouldEmitChanges()) {
|
|
42676
|
-
await super.utimes(
|
|
42739
|
+
await super.utimes(path2, atime, mtime);
|
|
42677
42740
|
return;
|
|
42678
42741
|
}
|
|
42679
|
-
await super.utimes(
|
|
42680
|
-
const current2 = await readPathState(this,
|
|
42742
|
+
await super.utimes(path2, atime, mtime);
|
|
42743
|
+
const current2 = await readPathState(this, path2);
|
|
42681
42744
|
if (!current2.exists || !current2.entryType) {
|
|
42682
42745
|
return;
|
|
42683
42746
|
}
|
|
42684
42747
|
this.emit({
|
|
42685
42748
|
event: "change",
|
|
42686
|
-
path:
|
|
42749
|
+
path: path2,
|
|
42687
42750
|
entryType: current2.entryType
|
|
42688
42751
|
});
|
|
42689
42752
|
}
|
|
42690
42753
|
};
|
|
42691
42754
|
|
|
42692
42755
|
// src/almostnode-session.ts
|
|
42693
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
42694
42756
|
init_npm();
|
|
42695
42757
|
|
|
42696
42758
|
// node_modules/almostnode/src/utils/hash.ts
|
|
@@ -42736,7 +42798,7 @@ function uint8ToBinaryString(bytes) {
|
|
|
42736
42798
|
}
|
|
42737
42799
|
|
|
42738
42800
|
// node_modules/almostnode/src/virtual-fs.ts
|
|
42739
|
-
function createNodeError(code2, syscall,
|
|
42801
|
+
function createNodeError(code2, syscall, path2, message) {
|
|
42740
42802
|
const errno = {
|
|
42741
42803
|
ENOENT: -2,
|
|
42742
42804
|
ENOTDIR: -20,
|
|
@@ -42752,12 +42814,12 @@ function createNodeError(code2, syscall, path4, message) {
|
|
|
42752
42814
|
ENOTEMPTY: "directory not empty"
|
|
42753
42815
|
};
|
|
42754
42816
|
const err2 = new Error(
|
|
42755
|
-
message || `${code2}: ${messages2[code2]}, ${syscall} '${
|
|
42817
|
+
message || `${code2}: ${messages2[code2]}, ${syscall} '${path2}'`
|
|
42756
42818
|
);
|
|
42757
42819
|
err2.code = code2;
|
|
42758
42820
|
err2.errno = errno[code2];
|
|
42759
42821
|
err2.syscall = syscall;
|
|
42760
|
-
err2.path =
|
|
42822
|
+
err2.path = path2;
|
|
42761
42823
|
return err2;
|
|
42762
42824
|
}
|
|
42763
42825
|
var VirtualFS = class _VirtualFS {
|
|
@@ -42807,18 +42869,18 @@ var VirtualFS = class _VirtualFS {
|
|
|
42807
42869
|
this.serializeNode("/", this.root, files);
|
|
42808
42870
|
return { files };
|
|
42809
42871
|
}
|
|
42810
|
-
serializeNode(
|
|
42872
|
+
serializeNode(path2, node, files) {
|
|
42811
42873
|
if (node.type === "file") {
|
|
42812
42874
|
let content = "";
|
|
42813
42875
|
if (node.content && node.content.length > 0) {
|
|
42814
42876
|
content = uint8ToBase64(node.content);
|
|
42815
42877
|
}
|
|
42816
|
-
files.push({ path:
|
|
42878
|
+
files.push({ path: path2, type: "file", content });
|
|
42817
42879
|
} else if (node.type === "directory") {
|
|
42818
|
-
files.push({ path:
|
|
42880
|
+
files.push({ path: path2, type: "directory" });
|
|
42819
42881
|
if (node.children) {
|
|
42820
42882
|
for (const [name, child] of node.children) {
|
|
42821
|
-
const childPath =
|
|
42883
|
+
const childPath = path2 === "/" ? `/${name}` : `${path2}/${name}`;
|
|
42822
42884
|
this.serializeNode(childPath, child, files);
|
|
42823
42885
|
}
|
|
42824
42886
|
}
|
|
@@ -42853,17 +42915,17 @@ var VirtualFS = class _VirtualFS {
|
|
|
42853
42915
|
/**
|
|
42854
42916
|
* Internal write that optionally emits events
|
|
42855
42917
|
*/
|
|
42856
|
-
writeFileSyncInternal(
|
|
42857
|
-
const normalized = this.normalizePath(
|
|
42918
|
+
writeFileSyncInternal(path2, data2, emitEvent) {
|
|
42919
|
+
const normalized = this.normalizePath(path2);
|
|
42858
42920
|
const parentPath = this.getParentPath(normalized);
|
|
42859
|
-
const
|
|
42860
|
-
if (!
|
|
42861
|
-
throw new Error(`EISDIR: illegal operation on a directory, '${
|
|
42921
|
+
const basename3 = this.getBasename(normalized);
|
|
42922
|
+
if (!basename3) {
|
|
42923
|
+
throw new Error(`EISDIR: illegal operation on a directory, '${path2}'`);
|
|
42862
42924
|
}
|
|
42863
42925
|
const parent = this.ensureDirectory(parentPath);
|
|
42864
|
-
const existed = parent.children.has(
|
|
42926
|
+
const existed = parent.children.has(basename3);
|
|
42865
42927
|
const content = typeof data2 === "string" ? this.encoder.encode(data2) : data2;
|
|
42866
|
-
parent.children.set(
|
|
42928
|
+
parent.children.set(basename3, {
|
|
42867
42929
|
type: "file",
|
|
42868
42930
|
content,
|
|
42869
42931
|
mtime: Date.now()
|
|
@@ -42876,11 +42938,11 @@ var VirtualFS = class _VirtualFS {
|
|
|
42876
42938
|
/**
|
|
42877
42939
|
* Normalize path - resolve . and .. segments, ensure leading /
|
|
42878
42940
|
*/
|
|
42879
|
-
normalizePath(
|
|
42880
|
-
if (!
|
|
42881
|
-
|
|
42941
|
+
normalizePath(path2) {
|
|
42942
|
+
if (!path2.startsWith("/")) {
|
|
42943
|
+
path2 = "/" + path2;
|
|
42882
42944
|
}
|
|
42883
|
-
const parts =
|
|
42945
|
+
const parts = path2.split("/").filter(Boolean);
|
|
42884
42946
|
const resolved = [];
|
|
42885
42947
|
for (const part of parts) {
|
|
42886
42948
|
if (part === "..") {
|
|
@@ -42894,30 +42956,30 @@ var VirtualFS = class _VirtualFS {
|
|
|
42894
42956
|
/**
|
|
42895
42957
|
* Get path segments from normalized path
|
|
42896
42958
|
*/
|
|
42897
|
-
getPathSegments(
|
|
42898
|
-
return this.normalizePath(
|
|
42959
|
+
getPathSegments(path2) {
|
|
42960
|
+
return this.normalizePath(path2).split("/").filter(Boolean);
|
|
42899
42961
|
}
|
|
42900
42962
|
/**
|
|
42901
42963
|
* Get parent directory path
|
|
42902
42964
|
*/
|
|
42903
|
-
getParentPath(
|
|
42904
|
-
const normalized = this.normalizePath(
|
|
42965
|
+
getParentPath(path2) {
|
|
42966
|
+
const normalized = this.normalizePath(path2);
|
|
42905
42967
|
const lastSlash = normalized.lastIndexOf("/");
|
|
42906
42968
|
return lastSlash <= 0 ? "/" : normalized.slice(0, lastSlash);
|
|
42907
42969
|
}
|
|
42908
42970
|
/**
|
|
42909
42971
|
* Get basename from path
|
|
42910
42972
|
*/
|
|
42911
|
-
getBasename(
|
|
42912
|
-
const normalized = this.normalizePath(
|
|
42973
|
+
getBasename(path2) {
|
|
42974
|
+
const normalized = this.normalizePath(path2);
|
|
42913
42975
|
const lastSlash = normalized.lastIndexOf("/");
|
|
42914
42976
|
return normalized.slice(lastSlash + 1);
|
|
42915
42977
|
}
|
|
42916
42978
|
/**
|
|
42917
42979
|
* Get node at path, returns undefined if not found
|
|
42918
42980
|
*/
|
|
42919
|
-
getNode(
|
|
42920
|
-
const segments = this.getPathSegments(
|
|
42981
|
+
getNode(path2) {
|
|
42982
|
+
const segments = this.getPathSegments(path2);
|
|
42921
42983
|
let current2 = this.root;
|
|
42922
42984
|
for (const segment of segments) {
|
|
42923
42985
|
if (current2.type !== "directory" || !current2.children) {
|
|
@@ -42934,8 +42996,8 @@ var VirtualFS = class _VirtualFS {
|
|
|
42934
42996
|
/**
|
|
42935
42997
|
* Get or create directory at path (for mkdir -p behavior)
|
|
42936
42998
|
*/
|
|
42937
|
-
ensureDirectory(
|
|
42938
|
-
const segments = this.getPathSegments(
|
|
42999
|
+
ensureDirectory(path2) {
|
|
43000
|
+
const segments = this.getPathSegments(path2);
|
|
42939
43001
|
let current2 = this.root;
|
|
42940
43002
|
for (const segment of segments) {
|
|
42941
43003
|
if (!current2.children) {
|
|
@@ -42946,7 +43008,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
42946
43008
|
child = { type: "directory", children: /* @__PURE__ */ new Map(), mtime: Date.now() };
|
|
42947
43009
|
current2.children.set(segment, child);
|
|
42948
43010
|
} else if (child.type !== "directory") {
|
|
42949
|
-
throw new Error(`ENOTDIR: not a directory, '${
|
|
43011
|
+
throw new Error(`ENOTDIR: not a directory, '${path2}'`);
|
|
42950
43012
|
}
|
|
42951
43013
|
current2 = child;
|
|
42952
43014
|
}
|
|
@@ -42955,16 +43017,16 @@ var VirtualFS = class _VirtualFS {
|
|
|
42955
43017
|
/**
|
|
42956
43018
|
* Check if path exists
|
|
42957
43019
|
*/
|
|
42958
|
-
existsSync(
|
|
42959
|
-
return this.getNode(
|
|
43020
|
+
existsSync(path2) {
|
|
43021
|
+
return this.getNode(path2) !== void 0;
|
|
42960
43022
|
}
|
|
42961
43023
|
/**
|
|
42962
43024
|
* Get stats for path
|
|
42963
43025
|
*/
|
|
42964
|
-
statSync(
|
|
42965
|
-
const node = this.getNode(
|
|
43026
|
+
statSync(path2) {
|
|
43027
|
+
const node = this.getNode(path2);
|
|
42966
43028
|
if (!node) {
|
|
42967
|
-
throw createNodeError("ENOENT", "stat",
|
|
43029
|
+
throw createNodeError("ENOENT", "stat", path2);
|
|
42968
43030
|
}
|
|
42969
43031
|
const size = node.type === "file" ? node.content?.length || 0 : 0;
|
|
42970
43032
|
const mtime = node.mtime;
|
|
@@ -42999,16 +43061,16 @@ var VirtualFS = class _VirtualFS {
|
|
|
42999
43061
|
/**
|
|
43000
43062
|
* lstatSync - same as statSync for our virtual FS (no symlinks)
|
|
43001
43063
|
*/
|
|
43002
|
-
lstatSync(
|
|
43003
|
-
return this.statSync(
|
|
43064
|
+
lstatSync(path2) {
|
|
43065
|
+
return this.statSync(path2);
|
|
43004
43066
|
}
|
|
43005
|
-
readFileSync(
|
|
43006
|
-
const node = this.getNode(
|
|
43067
|
+
readFileSync(path2, encoding) {
|
|
43068
|
+
const node = this.getNode(path2);
|
|
43007
43069
|
if (!node) {
|
|
43008
|
-
throw createNodeError("ENOENT", "open",
|
|
43070
|
+
throw createNodeError("ENOENT", "open", path2);
|
|
43009
43071
|
}
|
|
43010
43072
|
if (node.type !== "file") {
|
|
43011
|
-
throw createNodeError("EISDIR", "read",
|
|
43073
|
+
throw createNodeError("EISDIR", "read", path2);
|
|
43012
43074
|
}
|
|
43013
43075
|
const content = node.content || new Uint8Array(0);
|
|
43014
43076
|
if (encoding === "utf8" || encoding === "utf-8") {
|
|
@@ -43019,21 +43081,21 @@ var VirtualFS = class _VirtualFS {
|
|
|
43019
43081
|
/**
|
|
43020
43082
|
* Write data to file, creating parent directories as needed
|
|
43021
43083
|
*/
|
|
43022
|
-
writeFileSync(
|
|
43023
|
-
this.writeFileSyncInternal(
|
|
43084
|
+
writeFileSync(path2, data2) {
|
|
43085
|
+
this.writeFileSyncInternal(path2, data2, true);
|
|
43024
43086
|
}
|
|
43025
43087
|
/**
|
|
43026
43088
|
* Create directory, optionally with recursive parent creation
|
|
43027
43089
|
*/
|
|
43028
|
-
mkdirSync(
|
|
43029
|
-
const normalized = this.normalizePath(
|
|
43090
|
+
mkdirSync(path2, options2) {
|
|
43091
|
+
const normalized = this.normalizePath(path2);
|
|
43030
43092
|
if (options2?.recursive) {
|
|
43031
43093
|
this.ensureDirectory(normalized);
|
|
43032
43094
|
return;
|
|
43033
43095
|
}
|
|
43034
43096
|
const parentPath = this.getParentPath(normalized);
|
|
43035
|
-
const
|
|
43036
|
-
if (!
|
|
43097
|
+
const basename3 = this.getBasename(normalized);
|
|
43098
|
+
if (!basename3) {
|
|
43037
43099
|
return;
|
|
43038
43100
|
}
|
|
43039
43101
|
const parent = this.getNode(parentPath);
|
|
@@ -43043,10 +43105,10 @@ var VirtualFS = class _VirtualFS {
|
|
|
43043
43105
|
if (parent.type !== "directory") {
|
|
43044
43106
|
throw createNodeError("ENOTDIR", "mkdir", parentPath);
|
|
43045
43107
|
}
|
|
43046
|
-
if (parent.children.has(
|
|
43047
|
-
throw createNodeError("EEXIST", "mkdir",
|
|
43108
|
+
if (parent.children.has(basename3)) {
|
|
43109
|
+
throw createNodeError("EEXIST", "mkdir", path2);
|
|
43048
43110
|
}
|
|
43049
|
-
parent.children.set(
|
|
43111
|
+
parent.children.set(basename3, {
|
|
43050
43112
|
type: "directory",
|
|
43051
43113
|
children: /* @__PURE__ */ new Map(),
|
|
43052
43114
|
mtime: Date.now()
|
|
@@ -43055,63 +43117,63 @@ var VirtualFS = class _VirtualFS {
|
|
|
43055
43117
|
/**
|
|
43056
43118
|
* Read directory contents
|
|
43057
43119
|
*/
|
|
43058
|
-
readdirSync(
|
|
43059
|
-
const node = this.getNode(
|
|
43120
|
+
readdirSync(path2) {
|
|
43121
|
+
const node = this.getNode(path2);
|
|
43060
43122
|
if (!node) {
|
|
43061
|
-
throw createNodeError("ENOENT", "scandir",
|
|
43123
|
+
throw createNodeError("ENOENT", "scandir", path2);
|
|
43062
43124
|
}
|
|
43063
43125
|
if (node.type !== "directory") {
|
|
43064
|
-
throw createNodeError("ENOTDIR", "scandir",
|
|
43126
|
+
throw createNodeError("ENOTDIR", "scandir", path2);
|
|
43065
43127
|
}
|
|
43066
43128
|
return Array.from(node.children.keys());
|
|
43067
43129
|
}
|
|
43068
43130
|
/**
|
|
43069
43131
|
* Remove file
|
|
43070
43132
|
*/
|
|
43071
|
-
unlinkSync(
|
|
43072
|
-
const normalized = this.normalizePath(
|
|
43133
|
+
unlinkSync(path2) {
|
|
43134
|
+
const normalized = this.normalizePath(path2);
|
|
43073
43135
|
const parentPath = this.getParentPath(normalized);
|
|
43074
|
-
const
|
|
43136
|
+
const basename3 = this.getBasename(normalized);
|
|
43075
43137
|
const parent = this.getNode(parentPath);
|
|
43076
43138
|
if (!parent || parent.type !== "directory") {
|
|
43077
|
-
throw createNodeError("ENOENT", "unlink",
|
|
43139
|
+
throw createNodeError("ENOENT", "unlink", path2);
|
|
43078
43140
|
}
|
|
43079
|
-
const node = parent.children.get(
|
|
43141
|
+
const node = parent.children.get(basename3);
|
|
43080
43142
|
if (!node) {
|
|
43081
|
-
throw createNodeError("ENOENT", "unlink",
|
|
43143
|
+
throw createNodeError("ENOENT", "unlink", path2);
|
|
43082
43144
|
}
|
|
43083
43145
|
if (node.type !== "file") {
|
|
43084
|
-
throw createNodeError("EISDIR", "unlink",
|
|
43146
|
+
throw createNodeError("EISDIR", "unlink", path2);
|
|
43085
43147
|
}
|
|
43086
|
-
parent.children.delete(
|
|
43148
|
+
parent.children.delete(basename3);
|
|
43087
43149
|
this.notifyWatchers(normalized, "rename");
|
|
43088
43150
|
this.emit("delete", normalized);
|
|
43089
43151
|
}
|
|
43090
43152
|
/**
|
|
43091
43153
|
* Remove directory (must be empty)
|
|
43092
43154
|
*/
|
|
43093
|
-
rmdirSync(
|
|
43094
|
-
const normalized = this.normalizePath(
|
|
43155
|
+
rmdirSync(path2) {
|
|
43156
|
+
const normalized = this.normalizePath(path2);
|
|
43095
43157
|
const parentPath = this.getParentPath(normalized);
|
|
43096
|
-
const
|
|
43097
|
-
if (!
|
|
43098
|
-
throw new Error(`EPERM: operation not permitted, '${
|
|
43158
|
+
const basename3 = this.getBasename(normalized);
|
|
43159
|
+
if (!basename3) {
|
|
43160
|
+
throw new Error(`EPERM: operation not permitted, '${path2}'`);
|
|
43099
43161
|
}
|
|
43100
43162
|
const parent = this.getNode(parentPath);
|
|
43101
43163
|
if (!parent || parent.type !== "directory") {
|
|
43102
|
-
throw createNodeError("ENOENT", "rmdir",
|
|
43164
|
+
throw createNodeError("ENOENT", "rmdir", path2);
|
|
43103
43165
|
}
|
|
43104
|
-
const node = parent.children.get(
|
|
43166
|
+
const node = parent.children.get(basename3);
|
|
43105
43167
|
if (!node) {
|
|
43106
|
-
throw createNodeError("ENOENT", "rmdir",
|
|
43168
|
+
throw createNodeError("ENOENT", "rmdir", path2);
|
|
43107
43169
|
}
|
|
43108
43170
|
if (node.type !== "directory") {
|
|
43109
|
-
throw createNodeError("ENOTDIR", "rmdir",
|
|
43171
|
+
throw createNodeError("ENOTDIR", "rmdir", path2);
|
|
43110
43172
|
}
|
|
43111
43173
|
if (node.children.size > 0) {
|
|
43112
|
-
throw createNodeError("ENOTEMPTY", "rmdir",
|
|
43174
|
+
throw createNodeError("ENOTEMPTY", "rmdir", path2);
|
|
43113
43175
|
}
|
|
43114
|
-
parent.children.delete(
|
|
43176
|
+
parent.children.delete(basename3);
|
|
43115
43177
|
}
|
|
43116
43178
|
/**
|
|
43117
43179
|
* Rename/move file or directory
|
|
@@ -43140,11 +43202,11 @@ var VirtualFS = class _VirtualFS {
|
|
|
43140
43202
|
/**
|
|
43141
43203
|
* Read file with optional options parameter
|
|
43142
43204
|
*/
|
|
43143
|
-
readFile(
|
|
43205
|
+
readFile(path2, optionsOrCallback, callback) {
|
|
43144
43206
|
const actualCallback = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
43145
43207
|
const options2 = typeof optionsOrCallback === "object" ? optionsOrCallback : void 0;
|
|
43146
43208
|
try {
|
|
43147
|
-
const data2 = options2?.encoding ? this.readFileSync(
|
|
43209
|
+
const data2 = options2?.encoding ? this.readFileSync(path2, options2.encoding) : this.readFileSync(path2);
|
|
43148
43210
|
if (actualCallback) {
|
|
43149
43211
|
setTimeout(() => actualCallback(null, data2), 0);
|
|
43150
43212
|
}
|
|
@@ -43157,9 +43219,9 @@ var VirtualFS = class _VirtualFS {
|
|
|
43157
43219
|
/**
|
|
43158
43220
|
* Async stat
|
|
43159
43221
|
*/
|
|
43160
|
-
stat(
|
|
43222
|
+
stat(path2, callback) {
|
|
43161
43223
|
try {
|
|
43162
|
-
const stats = this.statSync(
|
|
43224
|
+
const stats = this.statSync(path2);
|
|
43163
43225
|
setTimeout(() => callback(null, stats), 0);
|
|
43164
43226
|
} catch (err2) {
|
|
43165
43227
|
setTimeout(() => callback(err2), 0);
|
|
@@ -43168,16 +43230,16 @@ var VirtualFS = class _VirtualFS {
|
|
|
43168
43230
|
/**
|
|
43169
43231
|
* Async lstat
|
|
43170
43232
|
*/
|
|
43171
|
-
lstat(
|
|
43172
|
-
this.stat(
|
|
43233
|
+
lstat(path2, callback) {
|
|
43234
|
+
this.stat(path2, callback);
|
|
43173
43235
|
}
|
|
43174
43236
|
/**
|
|
43175
43237
|
* Async readdir
|
|
43176
43238
|
*/
|
|
43177
|
-
readdir(
|
|
43239
|
+
readdir(path2, optionsOrCallback, callback) {
|
|
43178
43240
|
const actualCallback = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
43179
43241
|
try {
|
|
43180
|
-
const files = this.readdirSync(
|
|
43242
|
+
const files = this.readdirSync(path2);
|
|
43181
43243
|
if (actualCallback) {
|
|
43182
43244
|
setTimeout(() => actualCallback(null, files), 0);
|
|
43183
43245
|
}
|
|
@@ -43190,9 +43252,9 @@ var VirtualFS = class _VirtualFS {
|
|
|
43190
43252
|
/**
|
|
43191
43253
|
* Async realpath
|
|
43192
43254
|
*/
|
|
43193
|
-
realpath(
|
|
43255
|
+
realpath(path2, callback) {
|
|
43194
43256
|
try {
|
|
43195
|
-
const resolved = this.realpathSync(
|
|
43257
|
+
const resolved = this.realpathSync(path2);
|
|
43196
43258
|
setTimeout(() => callback(null, resolved), 0);
|
|
43197
43259
|
} catch (err2) {
|
|
43198
43260
|
setTimeout(() => callback(err2), 0);
|
|
@@ -43201,10 +43263,10 @@ var VirtualFS = class _VirtualFS {
|
|
|
43201
43263
|
/**
|
|
43202
43264
|
* Sync realpath - in our VFS, just normalize the path
|
|
43203
43265
|
*/
|
|
43204
|
-
realpathSync(
|
|
43205
|
-
const normalized = this.normalizePath(
|
|
43266
|
+
realpathSync(path2) {
|
|
43267
|
+
const normalized = this.normalizePath(path2);
|
|
43206
43268
|
if (!this.existsSync(normalized)) {
|
|
43207
|
-
throw createNodeError("ENOENT", "realpath",
|
|
43269
|
+
throw createNodeError("ENOENT", "realpath", path2);
|
|
43208
43270
|
}
|
|
43209
43271
|
return normalized;
|
|
43210
43272
|
}
|
|
@@ -43252,15 +43314,15 @@ var VirtualFS = class _VirtualFS {
|
|
|
43252
43314
|
/**
|
|
43253
43315
|
* Notify watchers of file changes
|
|
43254
43316
|
*/
|
|
43255
|
-
notifyWatchers(
|
|
43256
|
-
const normalized = this.normalizePath(
|
|
43257
|
-
const
|
|
43317
|
+
notifyWatchers(path2, eventType) {
|
|
43318
|
+
const normalized = this.normalizePath(path2);
|
|
43319
|
+
const basename3 = this.getBasename(normalized);
|
|
43258
43320
|
const directWatchers = this.watchers.get(normalized);
|
|
43259
43321
|
if (directWatchers) {
|
|
43260
43322
|
for (const entry of directWatchers) {
|
|
43261
43323
|
if (!entry.closed) {
|
|
43262
43324
|
try {
|
|
43263
|
-
entry.listener(eventType,
|
|
43325
|
+
entry.listener(eventType, basename3);
|
|
43264
43326
|
} catch (err2) {
|
|
43265
43327
|
console.error("Error in file watcher:", err2);
|
|
43266
43328
|
}
|
|
@@ -43268,7 +43330,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
43268
43330
|
}
|
|
43269
43331
|
}
|
|
43270
43332
|
let currentPath = this.getParentPath(normalized);
|
|
43271
|
-
let relativePath =
|
|
43333
|
+
let relativePath = basename3;
|
|
43272
43334
|
while (currentPath) {
|
|
43273
43335
|
const parentWatchers = this.watchers.get(currentPath);
|
|
43274
43336
|
if (parentWatchers) {
|
|
@@ -43293,18 +43355,18 @@ var VirtualFS = class _VirtualFS {
|
|
|
43293
43355
|
/**
|
|
43294
43356
|
* Access check - in our VFS, always succeeds if file exists
|
|
43295
43357
|
*/
|
|
43296
|
-
accessSync(
|
|
43297
|
-
if (!this.existsSync(
|
|
43298
|
-
throw createNodeError("ENOENT", "access",
|
|
43358
|
+
accessSync(path2, mode) {
|
|
43359
|
+
if (!this.existsSync(path2)) {
|
|
43360
|
+
throw createNodeError("ENOENT", "access", path2);
|
|
43299
43361
|
}
|
|
43300
43362
|
}
|
|
43301
43363
|
/**
|
|
43302
43364
|
* Async access
|
|
43303
43365
|
*/
|
|
43304
|
-
access(
|
|
43366
|
+
access(path2, modeOrCallback, callback) {
|
|
43305
43367
|
const actualCallback = typeof modeOrCallback === "function" ? modeOrCallback : callback;
|
|
43306
43368
|
try {
|
|
43307
|
-
this.accessSync(
|
|
43369
|
+
this.accessSync(path2);
|
|
43308
43370
|
if (actualCallback) setTimeout(() => actualCallback(null), 0);
|
|
43309
43371
|
} catch (err2) {
|
|
43310
43372
|
if (actualCallback) setTimeout(() => actualCallback(err2), 0);
|
|
@@ -43320,7 +43382,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
43320
43382
|
/**
|
|
43321
43383
|
* Create read stream - simplified implementation
|
|
43322
43384
|
*/
|
|
43323
|
-
createReadStream(
|
|
43385
|
+
createReadStream(path2) {
|
|
43324
43386
|
const self = this;
|
|
43325
43387
|
const listeners = {};
|
|
43326
43388
|
const stream = {
|
|
@@ -43335,7 +43397,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
43335
43397
|
};
|
|
43336
43398
|
setTimeout(() => {
|
|
43337
43399
|
try {
|
|
43338
|
-
const data2 = self.readFileSync(
|
|
43400
|
+
const data2 = self.readFileSync(path2);
|
|
43339
43401
|
listeners["data"]?.forEach((cb2) => cb2(data2));
|
|
43340
43402
|
listeners["end"]?.forEach((cb2) => cb2());
|
|
43341
43403
|
} catch (err2) {
|
|
@@ -43347,7 +43409,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
43347
43409
|
/**
|
|
43348
43410
|
* Create write stream - simplified implementation
|
|
43349
43411
|
*/
|
|
43350
|
-
createWriteStream(
|
|
43412
|
+
createWriteStream(path2) {
|
|
43351
43413
|
const self = this;
|
|
43352
43414
|
const chunks = [];
|
|
43353
43415
|
const listeners = {};
|
|
@@ -43370,7 +43432,7 @@ var VirtualFS = class _VirtualFS {
|
|
|
43370
43432
|
combined.set(chunk, offset2);
|
|
43371
43433
|
offset2 += chunk.length;
|
|
43372
43434
|
}
|
|
43373
|
-
self.writeFileSync(
|
|
43435
|
+
self.writeFileSync(path2, combined);
|
|
43374
43436
|
listeners["finish"]?.forEach((cb2) => cb2());
|
|
43375
43437
|
listeners["close"]?.forEach((cb2) => cb2());
|
|
43376
43438
|
},
|
|
@@ -43438,27 +43500,27 @@ function createBuffer(data2) {
|
|
|
43438
43500
|
return buffer;
|
|
43439
43501
|
}
|
|
43440
43502
|
function toPath(pathLike, getCwd) {
|
|
43441
|
-
let
|
|
43503
|
+
let path2;
|
|
43442
43504
|
if (typeof pathLike === "string") {
|
|
43443
|
-
|
|
43505
|
+
path2 = pathLike;
|
|
43444
43506
|
} else if (pathLike instanceof URL) {
|
|
43445
43507
|
if (pathLike.protocol === "file:") {
|
|
43446
|
-
|
|
43508
|
+
path2 = decodeURIComponent(pathLike.pathname);
|
|
43447
43509
|
} else {
|
|
43448
43510
|
throw new Error(`Unsupported URL protocol: ${pathLike.protocol}`);
|
|
43449
43511
|
}
|
|
43450
43512
|
} else if (Buffer.isBuffer(pathLike)) {
|
|
43451
|
-
|
|
43513
|
+
path2 = pathLike.toString("utf8");
|
|
43452
43514
|
} else if (pathLike && typeof pathLike === "object" && "toString" in pathLike) {
|
|
43453
|
-
|
|
43515
|
+
path2 = String(pathLike);
|
|
43454
43516
|
} else {
|
|
43455
43517
|
throw new TypeError(`Path must be a string, URL, or Buffer. Received: ${typeof pathLike}`);
|
|
43456
43518
|
}
|
|
43457
|
-
if (!
|
|
43519
|
+
if (!path2.startsWith("/") && getCwd) {
|
|
43458
43520
|
const cwd = getCwd();
|
|
43459
|
-
|
|
43521
|
+
path2 = cwd.endsWith("/") ? cwd + path2 : cwd + "/" + path2;
|
|
43460
43522
|
}
|
|
43461
|
-
return
|
|
43523
|
+
return path2;
|
|
43462
43524
|
}
|
|
43463
43525
|
var fdMap = /* @__PURE__ */ new Map();
|
|
43464
43526
|
var nextFd = 3;
|
|
@@ -43467,7 +43529,7 @@ var callTracker = {
|
|
|
43467
43529
|
readdirSync: /* @__PURE__ */ new Map(),
|
|
43468
43530
|
lastReset: Date.now()
|
|
43469
43531
|
};
|
|
43470
|
-
function trackCall(method,
|
|
43532
|
+
function trackCall(method, path2) {
|
|
43471
43533
|
const now = Date.now();
|
|
43472
43534
|
if (now - callTracker.lastReset > 500) {
|
|
43473
43535
|
callTracker.statSync.clear();
|
|
@@ -43475,15 +43537,15 @@ function trackCall(method, path4) {
|
|
|
43475
43537
|
callTracker.lastReset = now;
|
|
43476
43538
|
}
|
|
43477
43539
|
const map = callTracker[method];
|
|
43478
|
-
const count = (map.get(
|
|
43479
|
-
map.set(
|
|
43480
|
-
if (count === 10 &&
|
|
43481
|
-
console.warn(`[fs] ${method} called ${count}x on ${
|
|
43540
|
+
const count = (map.get(path2) || 0) + 1;
|
|
43541
|
+
map.set(path2, count);
|
|
43542
|
+
if (count === 10 && path2.includes("_generated")) {
|
|
43543
|
+
console.warn(`[fs] ${method} called ${count}x on ${path2}`);
|
|
43482
43544
|
const err2 = new Error();
|
|
43483
43545
|
console.log(`[fs] Stack at ${count} calls:`, err2.stack?.split("\n").slice(1, 10).join("\n"));
|
|
43484
43546
|
}
|
|
43485
43547
|
if (count === 50) {
|
|
43486
|
-
console.warn(`[fs] Potential infinite loop: ${method} called ${count}+ times on ${
|
|
43548
|
+
console.warn(`[fs] Potential infinite loop: ${method} called ${count}+ times on ${path2}`);
|
|
43487
43549
|
}
|
|
43488
43550
|
}
|
|
43489
43551
|
function createFsShim(vfs2, getCwd) {
|
|
@@ -43498,7 +43560,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43498
43560
|
readFile(pathLike, encodingOrOptions) {
|
|
43499
43561
|
return new Promise((resolve5, reject) => {
|
|
43500
43562
|
try {
|
|
43501
|
-
const
|
|
43563
|
+
const path2 = resolvePath(pathLike);
|
|
43502
43564
|
let encoding;
|
|
43503
43565
|
if (typeof encodingOrOptions === "string") {
|
|
43504
43566
|
encoding = encodingOrOptions;
|
|
@@ -43506,9 +43568,9 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43506
43568
|
encoding = encodingOrOptions.encoding;
|
|
43507
43569
|
}
|
|
43508
43570
|
if (encoding === "utf8" || encoding === "utf-8") {
|
|
43509
|
-
resolve5(vfs2.readFileSync(
|
|
43571
|
+
resolve5(vfs2.readFileSync(path2, "utf8"));
|
|
43510
43572
|
} else {
|
|
43511
|
-
resolve5(createBuffer(vfs2.readFileSync(
|
|
43573
|
+
resolve5(createBuffer(vfs2.readFileSync(path2)));
|
|
43512
43574
|
}
|
|
43513
43575
|
} catch (err2) {
|
|
43514
43576
|
reject(err2);
|
|
@@ -43528,8 +43590,8 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43528
43590
|
stat(pathLike) {
|
|
43529
43591
|
return new Promise((resolve5, reject) => {
|
|
43530
43592
|
try {
|
|
43531
|
-
const
|
|
43532
|
-
resolve5(vfs2.statSync(
|
|
43593
|
+
const path2 = typeof pathLike === "string" ? pathLike : resolvePath(pathLike);
|
|
43594
|
+
resolve5(vfs2.statSync(path2));
|
|
43533
43595
|
} catch (err2) {
|
|
43534
43596
|
reject(err2);
|
|
43535
43597
|
}
|
|
@@ -43541,12 +43603,12 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43541
43603
|
readdir(pathLike, options2) {
|
|
43542
43604
|
return new Promise((resolve5, reject) => {
|
|
43543
43605
|
try {
|
|
43544
|
-
const
|
|
43545
|
-
const entries = vfs2.readdirSync(
|
|
43606
|
+
const path2 = resolvePath(pathLike);
|
|
43607
|
+
const entries = vfs2.readdirSync(path2);
|
|
43546
43608
|
const opts = typeof options2 === "string" ? {} : options2;
|
|
43547
43609
|
if (opts?.withFileTypes) {
|
|
43548
43610
|
const dirents = entries.map((name) => {
|
|
43549
|
-
const entryPath =
|
|
43611
|
+
const entryPath = path2.endsWith("/") ? path2 + name : path2 + "/" + name;
|
|
43550
43612
|
let isDir = false;
|
|
43551
43613
|
let isFile = false;
|
|
43552
43614
|
try {
|
|
@@ -43587,10 +43649,10 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43587
43649
|
}
|
|
43588
43650
|
});
|
|
43589
43651
|
},
|
|
43590
|
-
rmdir(
|
|
43652
|
+
rmdir(path2) {
|
|
43591
43653
|
return new Promise((resolve5, reject) => {
|
|
43592
43654
|
try {
|
|
43593
|
-
vfs2.rmdirSync(
|
|
43655
|
+
vfs2.rmdirSync(path2);
|
|
43594
43656
|
resolve5();
|
|
43595
43657
|
} catch (err2) {
|
|
43596
43658
|
reject(err2);
|
|
@@ -43607,20 +43669,20 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43607
43669
|
}
|
|
43608
43670
|
});
|
|
43609
43671
|
},
|
|
43610
|
-
access(
|
|
43672
|
+
access(path2, mode) {
|
|
43611
43673
|
return new Promise((resolve5, reject) => {
|
|
43612
43674
|
try {
|
|
43613
|
-
vfs2.accessSync(
|
|
43675
|
+
vfs2.accessSync(path2, mode);
|
|
43614
43676
|
resolve5();
|
|
43615
43677
|
} catch (err2) {
|
|
43616
43678
|
reject(err2);
|
|
43617
43679
|
}
|
|
43618
43680
|
});
|
|
43619
43681
|
},
|
|
43620
|
-
realpath(
|
|
43682
|
+
realpath(path2) {
|
|
43621
43683
|
return new Promise((resolve5, reject) => {
|
|
43622
43684
|
try {
|
|
43623
|
-
resolve5(vfs2.realpathSync(
|
|
43685
|
+
resolve5(vfs2.realpathSync(path2));
|
|
43624
43686
|
} catch (err2) {
|
|
43625
43687
|
reject(err2);
|
|
43626
43688
|
}
|
|
@@ -43639,7 +43701,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43639
43701
|
};
|
|
43640
43702
|
return {
|
|
43641
43703
|
readFileSync(pathLike, encodingOrOptions) {
|
|
43642
|
-
const
|
|
43704
|
+
const path2 = resolvePath(pathLike);
|
|
43643
43705
|
let encoding;
|
|
43644
43706
|
if (typeof encodingOrOptions === "string") {
|
|
43645
43707
|
encoding = encodingOrOptions;
|
|
@@ -43647,9 +43709,9 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43647
43709
|
encoding = encodingOrOptions.encoding;
|
|
43648
43710
|
}
|
|
43649
43711
|
if (encoding === "utf8" || encoding === "utf-8") {
|
|
43650
|
-
return vfs2.readFileSync(
|
|
43712
|
+
return vfs2.readFileSync(path2, "utf8");
|
|
43651
43713
|
}
|
|
43652
|
-
const data2 = vfs2.readFileSync(
|
|
43714
|
+
const data2 = vfs2.readFileSync(path2);
|
|
43653
43715
|
return createBuffer(data2);
|
|
43654
43716
|
},
|
|
43655
43717
|
writeFileSync(pathLike, data2) {
|
|
@@ -43667,24 +43729,24 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43667
43729
|
entry.position = bytes.length;
|
|
43668
43730
|
return;
|
|
43669
43731
|
}
|
|
43670
|
-
const
|
|
43671
|
-
vfs2.writeFileSync(
|
|
43732
|
+
const path2 = resolvePath(pathLike);
|
|
43733
|
+
vfs2.writeFileSync(path2, data2);
|
|
43672
43734
|
},
|
|
43673
43735
|
existsSync(pathLike) {
|
|
43674
43736
|
return vfs2.existsSync(resolvePath(pathLike));
|
|
43675
43737
|
},
|
|
43676
43738
|
mkdirSync(pathLike, options2) {
|
|
43677
|
-
const
|
|
43678
|
-
vfs2.mkdirSync(
|
|
43739
|
+
const path2 = resolvePath(pathLike);
|
|
43740
|
+
vfs2.mkdirSync(path2, options2);
|
|
43679
43741
|
},
|
|
43680
43742
|
readdirSync(pathLike, options2) {
|
|
43681
|
-
const
|
|
43682
|
-
trackCall("readdirSync",
|
|
43683
|
-
const entries = vfs2.readdirSync(
|
|
43743
|
+
const path2 = resolvePath(pathLike);
|
|
43744
|
+
trackCall("readdirSync", path2);
|
|
43745
|
+
const entries = vfs2.readdirSync(path2);
|
|
43684
43746
|
const opts = typeof options2 === "string" ? { encoding: options2 } : options2;
|
|
43685
43747
|
if (opts?.withFileTypes) {
|
|
43686
43748
|
const dirents = entries.map((name) => {
|
|
43687
|
-
const entryPath =
|
|
43749
|
+
const entryPath = path2.endsWith("/") ? path2 + name : path2 + "/" + name;
|
|
43688
43750
|
let isDir = false;
|
|
43689
43751
|
let isFile = false;
|
|
43690
43752
|
try {
|
|
@@ -43696,24 +43758,24 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43696
43758
|
}
|
|
43697
43759
|
return new Dirent(name, isDir, isFile);
|
|
43698
43760
|
});
|
|
43699
|
-
if (
|
|
43700
|
-
console.log(`[fs] readdirSync(${
|
|
43761
|
+
if (path2.includes("_generated")) {
|
|
43762
|
+
console.log(`[fs] readdirSync(${path2}, withFileTypes) -> [${dirents.map((d) => d.name).join(", ")}]`);
|
|
43701
43763
|
}
|
|
43702
43764
|
return dirents;
|
|
43703
43765
|
}
|
|
43704
|
-
if (
|
|
43705
|
-
console.log(`[fs] readdirSync(${
|
|
43766
|
+
if (path2.includes("_generated")) {
|
|
43767
|
+
console.log(`[fs] readdirSync(${path2}) -> [${entries.join(", ")}]`);
|
|
43706
43768
|
}
|
|
43707
43769
|
return entries;
|
|
43708
43770
|
},
|
|
43709
43771
|
statSync(pathLike) {
|
|
43710
43772
|
const origPath = typeof pathLike === "string" ? pathLike : String(pathLike);
|
|
43711
|
-
const
|
|
43712
|
-
trackCall("statSync",
|
|
43713
|
-
const result = vfs2.statSync(
|
|
43714
|
-
if (
|
|
43715
|
-
const wasRemapped = origPath !==
|
|
43716
|
-
console.log(`[fs] statSync(${origPath}${wasRemapped ? " -> " +
|
|
43773
|
+
const path2 = resolvePath(pathLike);
|
|
43774
|
+
trackCall("statSync", path2);
|
|
43775
|
+
const result = vfs2.statSync(path2);
|
|
43776
|
+
if (path2.includes("_generated")) {
|
|
43777
|
+
const wasRemapped = origPath !== path2;
|
|
43778
|
+
console.log(`[fs] statSync(${origPath}${wasRemapped ? " -> " + path2 : ""}) -> isDir: ${result.isDirectory()}`);
|
|
43717
43779
|
}
|
|
43718
43780
|
return result;
|
|
43719
43781
|
},
|
|
@@ -43731,25 +43793,25 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43731
43793
|
return vfs2.statSync(entry.path);
|
|
43732
43794
|
},
|
|
43733
43795
|
openSync(pathLike, flags, _mode) {
|
|
43734
|
-
const
|
|
43796
|
+
const path2 = resolvePath(pathLike);
|
|
43735
43797
|
const flagStr = typeof flags === "number" ? "r" : flags;
|
|
43736
|
-
const exists = vfs2.existsSync(
|
|
43798
|
+
const exists = vfs2.existsSync(path2);
|
|
43737
43799
|
const isWriteMode = flagStr.includes("w") || flagStr.includes("a");
|
|
43738
43800
|
const isReadMode = flagStr.includes("r") && !flagStr.includes("+");
|
|
43739
43801
|
if (!exists && isReadMode) {
|
|
43740
|
-
const err2 = new Error(`ENOENT: no such file or directory, open '${
|
|
43802
|
+
const err2 = new Error(`ENOENT: no such file or directory, open '${path2}'`);
|
|
43741
43803
|
err2.code = "ENOENT";
|
|
43742
43804
|
err2.errno = -2;
|
|
43743
|
-
err2.path =
|
|
43805
|
+
err2.path = path2;
|
|
43744
43806
|
throw err2;
|
|
43745
43807
|
}
|
|
43746
43808
|
let content;
|
|
43747
43809
|
if (exists && !flagStr.includes("w")) {
|
|
43748
|
-
content = vfs2.readFileSync(
|
|
43810
|
+
content = vfs2.readFileSync(path2);
|
|
43749
43811
|
} else {
|
|
43750
43812
|
content = new Uint8Array(0);
|
|
43751
43813
|
if (isWriteMode) {
|
|
43752
|
-
const parentPath =
|
|
43814
|
+
const parentPath = path2.substring(0, path2.lastIndexOf("/")) || "/";
|
|
43753
43815
|
if (!vfs2.existsSync(parentPath)) {
|
|
43754
43816
|
vfs2.mkdirSync(parentPath, { recursive: true });
|
|
43755
43817
|
}
|
|
@@ -43757,7 +43819,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43757
43819
|
}
|
|
43758
43820
|
const fd2 = nextFd++;
|
|
43759
43821
|
fdMap.set(fd2, {
|
|
43760
|
-
path:
|
|
43822
|
+
path: path2,
|
|
43761
43823
|
position: flagStr.includes("a") ? content.length : 0,
|
|
43762
43824
|
flags: flagStr,
|
|
43763
43825
|
content: new Uint8Array(content)
|
|
@@ -43856,33 +43918,33 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43856
43918
|
return resolvedPath2;
|
|
43857
43919
|
},
|
|
43858
43920
|
rmSync(pathLike, options2) {
|
|
43859
|
-
const
|
|
43860
|
-
if (!vfs2.existsSync(
|
|
43921
|
+
const path2 = resolvePath(pathLike);
|
|
43922
|
+
if (!vfs2.existsSync(path2)) {
|
|
43861
43923
|
if (options2?.force) return;
|
|
43862
|
-
throw createNodeError("ENOENT", "rm",
|
|
43924
|
+
throw createNodeError("ENOENT", "rm", path2);
|
|
43863
43925
|
}
|
|
43864
|
-
const stats = vfs2.statSync(
|
|
43926
|
+
const stats = vfs2.statSync(path2);
|
|
43865
43927
|
if (stats.isDirectory()) {
|
|
43866
43928
|
if (options2?.recursive) {
|
|
43867
|
-
const entries = vfs2.readdirSync(
|
|
43929
|
+
const entries = vfs2.readdirSync(path2);
|
|
43868
43930
|
for (const entry of entries) {
|
|
43869
|
-
const entryPath =
|
|
43931
|
+
const entryPath = path2.endsWith("/") ? path2 + entry : path2 + "/" + entry;
|
|
43870
43932
|
this.rmSync(entryPath, options2);
|
|
43871
43933
|
}
|
|
43872
|
-
vfs2.rmdirSync(
|
|
43934
|
+
vfs2.rmdirSync(path2);
|
|
43873
43935
|
} else {
|
|
43874
|
-
throw createNodeError("EISDIR", "rm",
|
|
43936
|
+
throw createNodeError("EISDIR", "rm", path2);
|
|
43875
43937
|
}
|
|
43876
43938
|
} else {
|
|
43877
|
-
vfs2.unlinkSync(
|
|
43939
|
+
vfs2.unlinkSync(path2);
|
|
43878
43940
|
}
|
|
43879
43941
|
},
|
|
43880
43942
|
unlinkSync(pathLike) {
|
|
43881
|
-
const
|
|
43882
|
-
if (
|
|
43883
|
-
console.log(`[fs] unlinkSync(${
|
|
43943
|
+
const path2 = resolvePath(pathLike);
|
|
43944
|
+
if (path2.includes("_generated")) {
|
|
43945
|
+
console.log(`[fs] unlinkSync(${path2})`);
|
|
43884
43946
|
}
|
|
43885
|
-
vfs2.unlinkSync(
|
|
43947
|
+
vfs2.unlinkSync(path2);
|
|
43886
43948
|
},
|
|
43887
43949
|
rmdirSync(pathLike) {
|
|
43888
43950
|
vfs2.rmdirSync(resolvePath(pathLike));
|
|
@@ -43913,8 +43975,8 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43913
43975
|
return vfs2.watch(resolvePath(pathLike), optionsOrListener, listener);
|
|
43914
43976
|
},
|
|
43915
43977
|
readFile(pathLike, optionsOrCallback, callback) {
|
|
43916
|
-
const
|
|
43917
|
-
vfs2.readFile(
|
|
43978
|
+
const path2 = resolvePath(pathLike);
|
|
43979
|
+
vfs2.readFile(path2, optionsOrCallback, callback);
|
|
43918
43980
|
},
|
|
43919
43981
|
stat(pathLike, callback) {
|
|
43920
43982
|
vfs2.stat(resolvePath(pathLike), callback);
|
|
@@ -43925,12 +43987,12 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43925
43987
|
readdir(pathLike, optionsOrCallback, callback) {
|
|
43926
43988
|
const cb2 = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
43927
43989
|
const opts = typeof optionsOrCallback === "function" ? void 0 : optionsOrCallback;
|
|
43928
|
-
const
|
|
43990
|
+
const path2 = resolvePath(pathLike);
|
|
43929
43991
|
try {
|
|
43930
|
-
const entries = vfs2.readdirSync(
|
|
43992
|
+
const entries = vfs2.readdirSync(path2);
|
|
43931
43993
|
if (opts?.withFileTypes) {
|
|
43932
43994
|
const dirents = entries.map((name) => {
|
|
43933
|
-
const entryPath =
|
|
43995
|
+
const entryPath = path2.endsWith("/") ? path2 + name : path2 + "/" + name;
|
|
43934
43996
|
let isDir = false;
|
|
43935
43997
|
let isFile = false;
|
|
43936
43998
|
try {
|
|
@@ -46509,8 +46571,8 @@ var ClientRequest = class extends Writable {
|
|
|
46509
46571
|
}
|
|
46510
46572
|
}
|
|
46511
46573
|
if (!hostname2) hostname2 = "localhost";
|
|
46512
|
-
const
|
|
46513
|
-
const url2 = `${protocol}//${hostname2}${port}${
|
|
46574
|
+
const path2 = this._options.path || "/";
|
|
46575
|
+
const url2 = `${protocol}//${hostname2}${port}${path2}`;
|
|
46514
46576
|
if (this.headers["upgrade"]?.toLowerCase() === "websocket") {
|
|
46515
46577
|
this._handleWebSocketUpgrade(url2);
|
|
46516
46578
|
return;
|
|
@@ -46956,7 +47018,7 @@ __export(url_exports, {
|
|
|
46956
47018
|
format: () => format2,
|
|
46957
47019
|
parse: () => parse2,
|
|
46958
47020
|
pathToFileURL: () => pathToFileURL,
|
|
46959
|
-
resolve: () =>
|
|
47021
|
+
resolve: () => resolve3
|
|
46960
47022
|
});
|
|
46961
47023
|
function parse2(urlString, parseQueryString = false, slashesDenoteHost = false) {
|
|
46962
47024
|
try {
|
|
@@ -47048,7 +47110,7 @@ function format2(urlObject) {
|
|
|
47048
47110
|
}
|
|
47049
47111
|
return result;
|
|
47050
47112
|
}
|
|
47051
|
-
function
|
|
47113
|
+
function resolve3(from, to2) {
|
|
47052
47114
|
try {
|
|
47053
47115
|
return new URL2(to2, from).href;
|
|
47054
47116
|
} catch {
|
|
@@ -47064,14 +47126,14 @@ function fileURLToPath(url2) {
|
|
|
47064
47126
|
}
|
|
47065
47127
|
return decodeURIComponent(urlObj.pathname);
|
|
47066
47128
|
}
|
|
47067
|
-
function pathToFileURL(
|
|
47068
|
-
const encoded = encodeURIComponent(
|
|
47129
|
+
function pathToFileURL(path2) {
|
|
47130
|
+
const encoded = encodeURIComponent(path2).replace(/%2F/g, "/");
|
|
47069
47131
|
return new globalThis.URL("file://" + encoded);
|
|
47070
47132
|
}
|
|
47071
47133
|
var url_default = {
|
|
47072
47134
|
parse: parse2,
|
|
47073
47135
|
format: format2,
|
|
47074
|
-
resolve:
|
|
47136
|
+
resolve: resolve3,
|
|
47075
47137
|
URL: URL2,
|
|
47076
47138
|
URLSearchParams,
|
|
47077
47139
|
fileURLToPath,
|
|
@@ -47916,8 +47978,8 @@ __export(dns_exports, {
|
|
|
47916
47978
|
getServers: () => getServers,
|
|
47917
47979
|
lookup: () => lookup,
|
|
47918
47980
|
promises: () => promises2,
|
|
47919
|
-
resolve: () =>
|
|
47920
|
-
resolve4: () =>
|
|
47981
|
+
resolve: () => resolve4,
|
|
47982
|
+
resolve4: () => resolve42,
|
|
47921
47983
|
resolve6: () => resolve6,
|
|
47922
47984
|
reverse: () => reverse,
|
|
47923
47985
|
setDefaultResultOrder: () => setDefaultResultOrder,
|
|
@@ -47942,13 +48004,13 @@ function lookup(hostname2, optionsOrCallback, callback) {
|
|
|
47942
48004
|
}
|
|
47943
48005
|
});
|
|
47944
48006
|
}
|
|
47945
|
-
function
|
|
48007
|
+
function resolve4(hostname2, callback) {
|
|
47946
48008
|
setImmediate(() => {
|
|
47947
48009
|
callback(null, ["0.0.0.0"]);
|
|
47948
48010
|
});
|
|
47949
48011
|
}
|
|
47950
|
-
function
|
|
47951
|
-
|
|
48012
|
+
function resolve42(hostname2, callback) {
|
|
48013
|
+
resolve4(hostname2, callback);
|
|
47952
48014
|
}
|
|
47953
48015
|
function resolve6(hostname2, callback) {
|
|
47954
48016
|
setImmediate(() => {
|
|
@@ -47988,7 +48050,7 @@ var promises2 = {
|
|
|
47988
48050
|
},
|
|
47989
48051
|
resolve: (hostname2) => {
|
|
47990
48052
|
return new Promise((promiseResolve, promiseReject) => {
|
|
47991
|
-
|
|
48053
|
+
resolve4(hostname2, (err2, addresses) => {
|
|
47992
48054
|
if (err2) promiseReject(err2);
|
|
47993
48055
|
else promiseResolve(addresses || []);
|
|
47994
48056
|
});
|
|
@@ -48014,8 +48076,8 @@ var V4MAPPED = 0;
|
|
|
48014
48076
|
var ALL = 0;
|
|
48015
48077
|
var dns_default = {
|
|
48016
48078
|
lookup,
|
|
48017
|
-
resolve:
|
|
48018
|
-
resolve4,
|
|
48079
|
+
resolve: resolve4,
|
|
48080
|
+
resolve4: resolve42,
|
|
48019
48081
|
resolve6,
|
|
48020
48082
|
reverse,
|
|
48021
48083
|
setServers,
|
|
@@ -48095,63 +48157,63 @@ var VirtualFSAdapter = class {
|
|
|
48095
48157
|
/**
|
|
48096
48158
|
* Read the contents of a file as a string
|
|
48097
48159
|
*/
|
|
48098
|
-
async readFile(
|
|
48160
|
+
async readFile(path2, options2) {
|
|
48099
48161
|
const encoding = typeof options2 === "string" ? options2 : options2?.encoding;
|
|
48100
48162
|
if (!encoding || encoding === "utf8" || encoding === "utf-8") {
|
|
48101
|
-
return this.vfs.readFileSync(
|
|
48163
|
+
return this.vfs.readFileSync(path2, "utf8");
|
|
48102
48164
|
}
|
|
48103
48165
|
if (encoding === "binary" || encoding === "latin1") {
|
|
48104
|
-
const buffer = this.vfs.readFileSync(
|
|
48166
|
+
const buffer = this.vfs.readFileSync(path2);
|
|
48105
48167
|
return uint8ToBinaryString(buffer);
|
|
48106
48168
|
}
|
|
48107
|
-
return this.vfs.readFileSync(
|
|
48169
|
+
return this.vfs.readFileSync(path2, "utf8");
|
|
48108
48170
|
}
|
|
48109
48171
|
/**
|
|
48110
48172
|
* Read the contents of a file as a Uint8Array (binary)
|
|
48111
48173
|
*/
|
|
48112
|
-
async readFileBuffer(
|
|
48113
|
-
return this.vfs.readFileSync(
|
|
48174
|
+
async readFileBuffer(path2) {
|
|
48175
|
+
return this.vfs.readFileSync(path2);
|
|
48114
48176
|
}
|
|
48115
48177
|
/**
|
|
48116
48178
|
* Write content to a file, creating it if it doesn't exist
|
|
48117
48179
|
*/
|
|
48118
|
-
async writeFile(
|
|
48119
|
-
this.vfs.writeFileSync(
|
|
48180
|
+
async writeFile(path2, content, _options2) {
|
|
48181
|
+
this.vfs.writeFileSync(path2, content);
|
|
48120
48182
|
}
|
|
48121
48183
|
/**
|
|
48122
48184
|
* Append content to a file, creating it if it doesn't exist
|
|
48123
48185
|
*/
|
|
48124
|
-
async appendFile(
|
|
48186
|
+
async appendFile(path2, content, _options2) {
|
|
48125
48187
|
let existing = "";
|
|
48126
48188
|
try {
|
|
48127
|
-
existing = this.vfs.readFileSync(
|
|
48189
|
+
existing = this.vfs.readFileSync(path2, "utf8");
|
|
48128
48190
|
} catch {
|
|
48129
48191
|
}
|
|
48130
48192
|
const newContent = typeof content === "string" ? content : _decoder3.decode(content);
|
|
48131
|
-
this.vfs.writeFileSync(
|
|
48193
|
+
this.vfs.writeFileSync(path2, existing + newContent);
|
|
48132
48194
|
}
|
|
48133
48195
|
/**
|
|
48134
48196
|
* Check if a path exists
|
|
48135
48197
|
*/
|
|
48136
|
-
async exists(
|
|
48137
|
-
return this.vfs.existsSync(
|
|
48198
|
+
async exists(path2) {
|
|
48199
|
+
return this.vfs.existsSync(path2);
|
|
48138
48200
|
}
|
|
48139
48201
|
/**
|
|
48140
48202
|
* Get file/directory information
|
|
48141
48203
|
*/
|
|
48142
|
-
async stat(
|
|
48143
|
-
const stats = this.vfs.statSync(
|
|
48204
|
+
async stat(path2) {
|
|
48205
|
+
const stats = this.vfs.statSync(path2);
|
|
48144
48206
|
const isFile = stats.isFile();
|
|
48145
48207
|
const isDirectory = stats.isDirectory();
|
|
48146
48208
|
let size = 0;
|
|
48147
48209
|
if (isFile) {
|
|
48148
48210
|
try {
|
|
48149
|
-
const content = this.vfs.readFileSync(
|
|
48211
|
+
const content = this.vfs.readFileSync(path2);
|
|
48150
48212
|
size = content.length;
|
|
48151
48213
|
} catch {
|
|
48152
48214
|
}
|
|
48153
48215
|
}
|
|
48154
|
-
const isExecutable = isFile &&
|
|
48216
|
+
const isExecutable = isFile && path2.includes("/node_modules/.bin/");
|
|
48155
48217
|
return {
|
|
48156
48218
|
isFile,
|
|
48157
48219
|
isDirectory,
|
|
@@ -48164,23 +48226,23 @@ var VirtualFSAdapter = class {
|
|
|
48164
48226
|
/**
|
|
48165
48227
|
* Create a directory
|
|
48166
48228
|
*/
|
|
48167
|
-
async mkdir(
|
|
48168
|
-
this.vfs.mkdirSync(
|
|
48229
|
+
async mkdir(path2, options2) {
|
|
48230
|
+
this.vfs.mkdirSync(path2, options2);
|
|
48169
48231
|
}
|
|
48170
48232
|
/**
|
|
48171
48233
|
* Read directory contents
|
|
48172
48234
|
*/
|
|
48173
|
-
async readdir(
|
|
48174
|
-
return this.vfs.readdirSync(
|
|
48235
|
+
async readdir(path2) {
|
|
48236
|
+
return this.vfs.readdirSync(path2);
|
|
48175
48237
|
}
|
|
48176
48238
|
/**
|
|
48177
48239
|
* Read directory contents with file type information
|
|
48178
48240
|
*/
|
|
48179
|
-
async readdirWithFileTypes(
|
|
48180
|
-
const entries = this.vfs.readdirSync(
|
|
48241
|
+
async readdirWithFileTypes(path2) {
|
|
48242
|
+
const entries = this.vfs.readdirSync(path2);
|
|
48181
48243
|
const result = [];
|
|
48182
48244
|
for (const name of entries) {
|
|
48183
|
-
const fullPath =
|
|
48245
|
+
const fullPath = path2 === "/" ? `/${name}` : `${path2}/${name}`;
|
|
48184
48246
|
try {
|
|
48185
48247
|
const stats = this.vfs.statSync(fullPath);
|
|
48186
48248
|
result.push({
|
|
@@ -48197,32 +48259,32 @@ var VirtualFSAdapter = class {
|
|
|
48197
48259
|
/**
|
|
48198
48260
|
* Remove a file or directory
|
|
48199
48261
|
*/
|
|
48200
|
-
async rm(
|
|
48201
|
-
const exists = this.vfs.existsSync(
|
|
48262
|
+
async rm(path2, options2) {
|
|
48263
|
+
const exists = this.vfs.existsSync(path2);
|
|
48202
48264
|
if (!exists) {
|
|
48203
48265
|
if (options2?.force) {
|
|
48204
48266
|
return;
|
|
48205
48267
|
}
|
|
48206
|
-
throw createNodeError("ENOENT", "rm",
|
|
48268
|
+
throw createNodeError("ENOENT", "rm", path2);
|
|
48207
48269
|
}
|
|
48208
|
-
const stats = this.vfs.statSync(
|
|
48270
|
+
const stats = this.vfs.statSync(path2);
|
|
48209
48271
|
if (stats.isFile()) {
|
|
48210
|
-
this.vfs.unlinkSync(
|
|
48272
|
+
this.vfs.unlinkSync(path2);
|
|
48211
48273
|
} else if (stats.isDirectory()) {
|
|
48212
48274
|
if (options2?.recursive) {
|
|
48213
|
-
await this.rmRecursive(
|
|
48275
|
+
await this.rmRecursive(path2);
|
|
48214
48276
|
} else {
|
|
48215
|
-
this.vfs.rmdirSync(
|
|
48277
|
+
this.vfs.rmdirSync(path2);
|
|
48216
48278
|
}
|
|
48217
48279
|
}
|
|
48218
48280
|
}
|
|
48219
48281
|
/**
|
|
48220
48282
|
* Recursively remove a directory and its contents
|
|
48221
48283
|
*/
|
|
48222
|
-
async rmRecursive(
|
|
48223
|
-
const entries = this.vfs.readdirSync(
|
|
48284
|
+
async rmRecursive(path2) {
|
|
48285
|
+
const entries = this.vfs.readdirSync(path2);
|
|
48224
48286
|
for (const entry of entries) {
|
|
48225
|
-
const fullPath =
|
|
48287
|
+
const fullPath = path2 === "/" ? `/${entry}` : `${path2}/${entry}`;
|
|
48226
48288
|
const stats = this.vfs.statSync(fullPath);
|
|
48227
48289
|
if (stats.isDirectory()) {
|
|
48228
48290
|
await this.rmRecursive(fullPath);
|
|
@@ -48230,7 +48292,7 @@ var VirtualFSAdapter = class {
|
|
|
48230
48292
|
this.vfs.unlinkSync(fullPath);
|
|
48231
48293
|
}
|
|
48232
48294
|
}
|
|
48233
|
-
this.vfs.rmdirSync(
|
|
48295
|
+
this.vfs.rmdirSync(path2);
|
|
48234
48296
|
}
|
|
48235
48297
|
/**
|
|
48236
48298
|
* Copy a file or directory
|
|
@@ -48276,21 +48338,21 @@ var VirtualFSAdapter = class {
|
|
|
48276
48338
|
/**
|
|
48277
48339
|
* Resolve a relative path against a base path
|
|
48278
48340
|
*/
|
|
48279
|
-
resolvePath(base,
|
|
48280
|
-
if (
|
|
48281
|
-
return this.normalizePath(
|
|
48341
|
+
resolvePath(base, path2) {
|
|
48342
|
+
if (path2.startsWith("/")) {
|
|
48343
|
+
return this.normalizePath(path2);
|
|
48282
48344
|
}
|
|
48283
|
-
const combined = base.endsWith("/") ? `${base}${
|
|
48345
|
+
const combined = base.endsWith("/") ? `${base}${path2}` : `${base}/${path2}`;
|
|
48284
48346
|
return this.normalizePath(combined);
|
|
48285
48347
|
}
|
|
48286
48348
|
/**
|
|
48287
48349
|
* Normalize a path (resolve . and .. segments)
|
|
48288
48350
|
*/
|
|
48289
|
-
normalizePath(
|
|
48290
|
-
if (!
|
|
48291
|
-
|
|
48351
|
+
normalizePath(path2) {
|
|
48352
|
+
if (!path2.startsWith("/")) {
|
|
48353
|
+
path2 = "/" + path2;
|
|
48292
48354
|
}
|
|
48293
|
-
const parts =
|
|
48355
|
+
const parts = path2.split("/").filter(Boolean);
|
|
48294
48356
|
const resolved = [];
|
|
48295
48357
|
for (const part of parts) {
|
|
48296
48358
|
if (part === "..") {
|
|
@@ -48359,25 +48421,25 @@ var VirtualFSAdapter = class {
|
|
|
48359
48421
|
* Get file/directory information without following symlinks
|
|
48360
48422
|
* Since VFS doesn't support symlinks, this is the same as stat
|
|
48361
48423
|
*/
|
|
48362
|
-
async lstat(
|
|
48363
|
-
return this.stat(
|
|
48424
|
+
async lstat(path2) {
|
|
48425
|
+
return this.stat(path2);
|
|
48364
48426
|
}
|
|
48365
48427
|
/**
|
|
48366
48428
|
* Resolve all symlinks in a path
|
|
48367
48429
|
* Since VFS doesn't support symlinks, just normalize and return
|
|
48368
48430
|
*/
|
|
48369
|
-
async realpath(
|
|
48370
|
-
if (!this.vfs.existsSync(
|
|
48371
|
-
throw createNodeError("ENOENT", "realpath",
|
|
48431
|
+
async realpath(path2) {
|
|
48432
|
+
if (!this.vfs.existsSync(path2)) {
|
|
48433
|
+
throw createNodeError("ENOENT", "realpath", path2);
|
|
48372
48434
|
}
|
|
48373
|
-
return this.normalizePath(
|
|
48435
|
+
return this.normalizePath(path2);
|
|
48374
48436
|
}
|
|
48375
48437
|
/**
|
|
48376
48438
|
* Set access and modification times (no-op - VFS doesn't track times)
|
|
48377
48439
|
*/
|
|
48378
|
-
async utimes(
|
|
48379
|
-
if (!this.vfs.existsSync(
|
|
48380
|
-
throw createNodeError("ENOENT", "utimes",
|
|
48440
|
+
async utimes(path2, _atime, _mtime) {
|
|
48441
|
+
if (!this.vfs.existsSync(path2)) {
|
|
48442
|
+
throw createNodeError("ENOENT", "utimes", path2);
|
|
48381
48443
|
}
|
|
48382
48444
|
}
|
|
48383
48445
|
};
|
|
@@ -49146,29 +49208,29 @@ var FSWatcher = class extends EventEmitter {
|
|
|
49146
49208
|
this.vfs = globalVFS;
|
|
49147
49209
|
this.options = options2;
|
|
49148
49210
|
}
|
|
49149
|
-
shouldIgnore(
|
|
49211
|
+
shouldIgnore(path2) {
|
|
49150
49212
|
const { ignored } = this.options;
|
|
49151
49213
|
if (!ignored) return false;
|
|
49152
49214
|
const ignoreList = Array.isArray(ignored) ? ignored : [ignored];
|
|
49153
49215
|
for (const pattern of ignoreList) {
|
|
49154
49216
|
if (typeof pattern === "string") {
|
|
49155
|
-
if (
|
|
49217
|
+
if (path2 === pattern || path2.startsWith(pattern + "/")) return true;
|
|
49156
49218
|
} else if (pattern instanceof RegExp) {
|
|
49157
|
-
if (pattern.test(
|
|
49219
|
+
if (pattern.test(path2)) return true;
|
|
49158
49220
|
} else if (typeof pattern === "function") {
|
|
49159
|
-
if (pattern(
|
|
49221
|
+
if (pattern(path2)) return true;
|
|
49160
49222
|
}
|
|
49161
49223
|
}
|
|
49162
49224
|
return false;
|
|
49163
49225
|
}
|
|
49164
|
-
normalizePath(
|
|
49165
|
-
if (this.options.cwd && !
|
|
49166
|
-
|
|
49226
|
+
normalizePath(path2) {
|
|
49227
|
+
if (this.options.cwd && !path2.startsWith("/")) {
|
|
49228
|
+
path2 = this.options.cwd + "/" + path2;
|
|
49167
49229
|
}
|
|
49168
|
-
if (!
|
|
49169
|
-
|
|
49230
|
+
if (!path2.startsWith("/")) {
|
|
49231
|
+
path2 = "/" + path2;
|
|
49170
49232
|
}
|
|
49171
|
-
return
|
|
49233
|
+
return path2;
|
|
49172
49234
|
}
|
|
49173
49235
|
add(paths) {
|
|
49174
49236
|
if (this.closed) return this;
|
|
@@ -49231,15 +49293,15 @@ var FSWatcher = class extends EventEmitter {
|
|
|
49231
49293
|
} catch {
|
|
49232
49294
|
}
|
|
49233
49295
|
}
|
|
49234
|
-
watchPath(
|
|
49235
|
-
if (this.watched.has(
|
|
49236
|
-
const watcher = this.vfs.watch(
|
|
49296
|
+
watchPath(path2, watchFor) {
|
|
49297
|
+
if (this.watched.has(path2)) return;
|
|
49298
|
+
const watcher = this.vfs.watch(path2, { recursive: true }, (eventType, filename2) => {
|
|
49237
49299
|
if (this.closed) return;
|
|
49238
49300
|
let fullPath;
|
|
49239
49301
|
if (filename2) {
|
|
49240
|
-
fullPath =
|
|
49302
|
+
fullPath = path2 === "/" ? "/" + filename2 : path2 + "/" + filename2;
|
|
49241
49303
|
} else {
|
|
49242
|
-
fullPath =
|
|
49304
|
+
fullPath = path2;
|
|
49243
49305
|
}
|
|
49244
49306
|
const eventKey = `${eventType}:${fullPath}`;
|
|
49245
49307
|
if (!this._eventCounts) this._eventCounts = /* @__PURE__ */ new Map();
|
|
@@ -49283,7 +49345,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
49283
49345
|
}
|
|
49284
49346
|
}
|
|
49285
49347
|
});
|
|
49286
|
-
this.watched.set(
|
|
49348
|
+
this.watched.set(path2, watcher);
|
|
49287
49349
|
}
|
|
49288
49350
|
watchDirRecursive(dirPath, depth = 0) {
|
|
49289
49351
|
if (this.options.depth !== void 0 && depth > this.options.depth) return;
|
|
@@ -49327,13 +49389,13 @@ var FSWatcher = class extends EventEmitter {
|
|
|
49327
49389
|
}
|
|
49328
49390
|
getWatched() {
|
|
49329
49391
|
const result = {};
|
|
49330
|
-
for (const
|
|
49331
|
-
const dir =
|
|
49332
|
-
const
|
|
49392
|
+
for (const path2 of this.watched.keys()) {
|
|
49393
|
+
const dir = path2.substring(0, path2.lastIndexOf("/")) || "/";
|
|
49394
|
+
const basename3 = path2.substring(path2.lastIndexOf("/") + 1);
|
|
49333
49395
|
if (!result[dir]) {
|
|
49334
49396
|
result[dir] = [];
|
|
49335
49397
|
}
|
|
49336
|
-
result[dir].push(
|
|
49398
|
+
result[dir].push(basename3);
|
|
49337
49399
|
}
|
|
49338
49400
|
return result;
|
|
49339
49401
|
}
|
|
@@ -49727,13 +49789,13 @@ var constants6 = {
|
|
|
49727
49789
|
kFSEventStreamEventFlagItemIsDir: 131072,
|
|
49728
49790
|
kFSEventStreamEventFlagItemIsSymlink: 262144
|
|
49729
49791
|
};
|
|
49730
|
-
function watch2(
|
|
49792
|
+
function watch2(path2, handler) {
|
|
49731
49793
|
return () => Promise.resolve();
|
|
49732
49794
|
}
|
|
49733
|
-
function getInfo(
|
|
49795
|
+
function getInfo(path2, flags) {
|
|
49734
49796
|
return {
|
|
49735
49797
|
event: "unknown",
|
|
49736
|
-
path:
|
|
49798
|
+
path: path2,
|
|
49737
49799
|
type: "file",
|
|
49738
49800
|
changes: { inode: false, finder: false, access: false, xattrs: false },
|
|
49739
49801
|
flags
|
|
@@ -50401,8 +50463,8 @@ async function transformToCommonJS(code2, options2) {
|
|
|
50401
50463
|
});
|
|
50402
50464
|
return result.code;
|
|
50403
50465
|
}
|
|
50404
|
-
function remapVFSPath(
|
|
50405
|
-
return
|
|
50466
|
+
function remapVFSPath(path2) {
|
|
50467
|
+
return path2;
|
|
50406
50468
|
}
|
|
50407
50469
|
function findVFSFile(vfs2, originalPath, extensions) {
|
|
50408
50470
|
for (const ext2 of extensions) {
|
|
@@ -50560,16 +50622,16 @@ async function build(options2) {
|
|
|
50560
50622
|
}
|
|
50561
50623
|
if (ep2.startsWith("./")) {
|
|
50562
50624
|
const base = absWorkingDir.endsWith("/") ? absWorkingDir.slice(0, -1) : absWorkingDir;
|
|
50563
|
-
const
|
|
50564
|
-
const resolved = base + "/" +
|
|
50625
|
+
const relative3 = ep2.slice(2);
|
|
50626
|
+
const resolved = base + "/" + relative3;
|
|
50565
50627
|
return resolved;
|
|
50566
50628
|
}
|
|
50567
50629
|
if (ep2.startsWith("../")) {
|
|
50568
50630
|
const base = absWorkingDir.endsWith("/") ? absWorkingDir.slice(0, -1) : absWorkingDir;
|
|
50569
50631
|
const parts = base.split("/").filter(Boolean);
|
|
50570
50632
|
parts.pop();
|
|
50571
|
-
const
|
|
50572
|
-
const resolved = "/" + parts.join("/") + "/" +
|
|
50633
|
+
const relative3 = ep2.slice(3);
|
|
50634
|
+
const resolved = "/" + parts.join("/") + "/" + relative3;
|
|
50573
50635
|
return resolved;
|
|
50574
50636
|
}
|
|
50575
50637
|
return ep2;
|
|
@@ -58172,9 +58234,9 @@ function transformEsmToCjsAst2(code2, filename2) {
|
|
|
58172
58234
|
function transformEsmToCjsRegexFallback(code2, filename2) {
|
|
58173
58235
|
let transformed = code2;
|
|
58174
58236
|
transformed = transformed.replace(/\bimport\.meta\.url\b/g, `"file://${filename2}"`);
|
|
58175
|
-
transformed = transformed.replace(/\bimport\.meta\.dirname\b/g, `"${
|
|
58237
|
+
transformed = transformed.replace(/\bimport\.meta\.dirname\b/g, `"${dirname3(filename2)}"`);
|
|
58176
58238
|
transformed = transformed.replace(/\bimport\.meta\.filename\b/g, `"${filename2}"`);
|
|
58177
|
-
transformed = transformed.replace(/\bimport\.meta\b/g, `({ url: "file://${filename2}", dirname: "${
|
|
58239
|
+
transformed = transformed.replace(/\bimport\.meta\b/g, `({ url: "file://${filename2}", dirname: "${dirname3(filename2)}", filename: "${filename2}" })`);
|
|
58178
58240
|
transformed = transformDynamicImportsRegex(transformed);
|
|
58179
58241
|
const hasImport = /\bimport\s+[\w{*'"]/m.test(code2);
|
|
58180
58242
|
const hasExport = /\bexport\s+(?:default|const|let|var|function|class|{|\*)/m.test(code2);
|
|
@@ -58413,19 +58475,19 @@ function createRequire2(vfs, fsShim, process, currentDir, moduleCache, options,
|
|
|
58413
58475
|
if (id2.startsWith("#")) {
|
|
58414
58476
|
let searchDir2 = fromDir;
|
|
58415
58477
|
while (searchDir2 !== "/") {
|
|
58416
|
-
const pkgPath =
|
|
58478
|
+
const pkgPath = join3(searchDir2, "package.json");
|
|
58417
58479
|
const pkg = getParsedPackageJson(pkgPath);
|
|
58418
58480
|
if (pkg?.imports) {
|
|
58419
58481
|
try {
|
|
58420
58482
|
const resolved = f(pkg, id2, { require: true });
|
|
58421
58483
|
if (resolved && resolved.length > 0) {
|
|
58422
|
-
const fullPath =
|
|
58484
|
+
const fullPath = join3(searchDir2, resolved[0]);
|
|
58423
58485
|
if (vfs.existsSync(fullPath)) return fullPath;
|
|
58424
58486
|
}
|
|
58425
58487
|
} catch {
|
|
58426
58488
|
}
|
|
58427
58489
|
}
|
|
58428
|
-
searchDir2 =
|
|
58490
|
+
searchDir2 = dirname3(searchDir2);
|
|
58429
58491
|
}
|
|
58430
58492
|
throw new Error(`Cannot find module '${id2}'`);
|
|
58431
58493
|
}
|
|
@@ -58438,14 +58500,14 @@ function createRequire2(vfs, fsShim, process, currentDir, moduleCache, options,
|
|
|
58438
58500
|
return cached;
|
|
58439
58501
|
}
|
|
58440
58502
|
if (id2.startsWith("./") || id2.startsWith("../") || id2.startsWith("/")) {
|
|
58441
|
-
const resolved = id2.startsWith("/") ? id2 :
|
|
58503
|
+
const resolved = id2.startsWith("/") ? id2 : resolve2(fromDir, id2);
|
|
58442
58504
|
if (vfs.existsSync(resolved)) {
|
|
58443
58505
|
const stats = vfs.statSync(resolved);
|
|
58444
58506
|
if (stats.isFile()) {
|
|
58445
58507
|
resolutionCache.set(cacheKey, resolved);
|
|
58446
58508
|
return resolved;
|
|
58447
58509
|
}
|
|
58448
|
-
const indexPath =
|
|
58510
|
+
const indexPath = join3(resolved, "index.js");
|
|
58449
58511
|
if (vfs.existsSync(indexPath)) {
|
|
58450
58512
|
resolutionCache.set(cacheKey, indexPath);
|
|
58451
58513
|
return indexPath;
|
|
@@ -58468,7 +58530,7 @@ function createRequire2(vfs, fsShim, process, currentDir, moduleCache, options,
|
|
|
58468
58530
|
if (stats.isFile()) {
|
|
58469
58531
|
return basePath;
|
|
58470
58532
|
}
|
|
58471
|
-
const indexPath =
|
|
58533
|
+
const indexPath = join3(basePath, "index.js");
|
|
58472
58534
|
if (vfs.existsSync(indexPath)) {
|
|
58473
58535
|
return indexPath;
|
|
58474
58536
|
}
|
|
@@ -58485,12 +58547,12 @@ function createRequire2(vfs, fsShim, process, currentDir, moduleCache, options,
|
|
|
58485
58547
|
const applyBrowserFieldRemap = (resolvedPath2, pkg, pkgRoot) => {
|
|
58486
58548
|
if (!pkg.browser || typeof pkg.browser !== "object") return resolvedPath2;
|
|
58487
58549
|
const browserMap = pkg.browser;
|
|
58488
|
-
const relPath = "./" +
|
|
58550
|
+
const relPath = "./" + relative2(pkgRoot, resolvedPath2);
|
|
58489
58551
|
const relPathNoExt = relPath.replace(/\.(js|json|cjs|mjs)$/, "");
|
|
58490
58552
|
for (const key of [relPath, relPathNoExt]) {
|
|
58491
58553
|
if (key in browserMap) {
|
|
58492
58554
|
if (browserMap[key] === false) return null;
|
|
58493
|
-
return tryResolveFile(
|
|
58555
|
+
return tryResolveFile(join3(pkgRoot, browserMap[key]));
|
|
58494
58556
|
}
|
|
58495
58557
|
}
|
|
58496
58558
|
return resolvedPath2;
|
|
@@ -58498,8 +58560,8 @@ function createRequire2(vfs, fsShim, process, currentDir, moduleCache, options,
|
|
|
58498
58560
|
const tryResolveFromNodeModules = (nodeModulesDir, moduleId) => {
|
|
58499
58561
|
const parts = moduleId.split("/");
|
|
58500
58562
|
const pkgName = parts[0].startsWith("@") && parts.length > 1 ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
58501
|
-
const pkgRoot =
|
|
58502
|
-
const pkgPath =
|
|
58563
|
+
const pkgRoot = join3(nodeModulesDir, pkgName);
|
|
58564
|
+
const pkgPath = join3(pkgRoot, "package.json");
|
|
58503
58565
|
const pkg = getParsedPackageJson(pkgPath);
|
|
58504
58566
|
if (pkg) {
|
|
58505
58567
|
if (pkg.exports) {
|
|
@@ -58508,7 +58570,7 @@ function createRequire2(vfs, fsShim, process, currentDir, moduleCache, options,
|
|
|
58508
58570
|
const resolved2 = s(pkg, moduleId, conditions);
|
|
58509
58571
|
if (resolved2 && resolved2.length > 0) {
|
|
58510
58572
|
const exportPath = resolved2[0];
|
|
58511
|
-
const fullExportPath =
|
|
58573
|
+
const fullExportPath = join3(pkgRoot, exportPath);
|
|
58512
58574
|
const resolvedFile = tryResolveFile(fullExportPath);
|
|
58513
58575
|
if (resolvedFile) {
|
|
58514
58576
|
if (resolvedFile.endsWith(".cjs")) {
|
|
@@ -58538,25 +58600,25 @@ function createRequire2(vfs, fsShim, process, currentDir, moduleCache, options,
|
|
|
58538
58600
|
if (!main) {
|
|
58539
58601
|
main = pkg.main || "index.js";
|
|
58540
58602
|
}
|
|
58541
|
-
const mainPath =
|
|
58603
|
+
const mainPath = join3(pkgRoot, main);
|
|
58542
58604
|
const resolvedMain = tryResolveFile(mainPath);
|
|
58543
58605
|
if (resolvedMain) return resolvedMain;
|
|
58544
58606
|
}
|
|
58545
58607
|
}
|
|
58546
|
-
const fullPath =
|
|
58608
|
+
const fullPath = join3(nodeModulesDir, moduleId);
|
|
58547
58609
|
const resolved = tryResolveFile(fullPath);
|
|
58548
58610
|
if (resolved) return resolved;
|
|
58549
58611
|
return null;
|
|
58550
58612
|
};
|
|
58551
58613
|
let searchDir = fromDir;
|
|
58552
58614
|
while (searchDir !== "/") {
|
|
58553
|
-
const nodeModulesDir =
|
|
58615
|
+
const nodeModulesDir = join3(searchDir, "node_modules");
|
|
58554
58616
|
const resolved = tryResolveFromNodeModules(nodeModulesDir, id2);
|
|
58555
58617
|
if (resolved) {
|
|
58556
58618
|
resolutionCache.set(cacheKey, resolved);
|
|
58557
58619
|
return resolved;
|
|
58558
58620
|
}
|
|
58559
|
-
searchDir =
|
|
58621
|
+
searchDir = dirname3(searchDir);
|
|
58560
58622
|
}
|
|
58561
58623
|
const rootResolved = tryResolveFromNodeModules("/node_modules", id2);
|
|
58562
58624
|
if (rootResolved) {
|
|
@@ -58590,7 +58652,7 @@ function createRequire2(vfs, fsShim, process, currentDir, moduleCache, options,
|
|
|
58590
58652
|
return module;
|
|
58591
58653
|
}
|
|
58592
58654
|
const rawCode = vfs.readFileSync(resolvedPath, "utf8");
|
|
58593
|
-
const dirname =
|
|
58655
|
+
const dirname = dirname3(resolvedPath);
|
|
58594
58656
|
const codeCacheKey = `${resolvedPath}|${simpleHash(rawCode)}`;
|
|
58595
58657
|
let code = processedCodeCache?.get(codeCacheKey);
|
|
58596
58658
|
if (!code) {
|
|
@@ -58687,7 +58749,7 @@ ${code}
|
|
|
58687
58749
|
fromPath = fromPath.slice(1);
|
|
58688
58750
|
}
|
|
58689
58751
|
}
|
|
58690
|
-
const fromDir =
|
|
58752
|
+
const fromDir = dirname3(fromPath);
|
|
58691
58753
|
const newRequire = createRequire2(
|
|
58692
58754
|
vfs,
|
|
58693
58755
|
fsShim,
|
|
@@ -59004,7 +59066,7 @@ var Runtime = class {
|
|
|
59004
59066
|
* Execute code as a module (synchronous - backward compatible)
|
|
59005
59067
|
*/
|
|
59006
59068
|
execute(code, filename = "/index.js") {
|
|
59007
|
-
const dirname =
|
|
59069
|
+
const dirname = dirname3(filename);
|
|
59008
59070
|
this.vfs.writeFileSync(filename, code);
|
|
59009
59071
|
const require = createRequire2(
|
|
59010
59072
|
this.vfs,
|
|
@@ -59473,7 +59535,7 @@ var ServerBridge = class _ServerBridge extends EventEmitter {
|
|
|
59473
59535
|
throw new Error("Not a virtual server request");
|
|
59474
59536
|
}
|
|
59475
59537
|
const port = parseInt(match3[1], 10);
|
|
59476
|
-
const
|
|
59538
|
+
const path2 = match3[2] || "/";
|
|
59477
59539
|
const headers = {};
|
|
59478
59540
|
request3.headers.forEach((value, key) => {
|
|
59479
59541
|
headers[key] = value;
|
|
@@ -59485,7 +59547,7 @@ var ServerBridge = class _ServerBridge extends EventEmitter {
|
|
|
59485
59547
|
const response = await this.handleRequest(
|
|
59486
59548
|
port,
|
|
59487
59549
|
request3.method,
|
|
59488
|
-
|
|
59550
|
+
path2 + url2.search,
|
|
59489
59551
|
headers,
|
|
59490
59552
|
body
|
|
59491
59553
|
);
|
|
@@ -59611,20 +59673,20 @@ var DevServer = class extends EventEmitter {
|
|
|
59611
59673
|
* Resolve a URL path to a filesystem path
|
|
59612
59674
|
*/
|
|
59613
59675
|
resolvePath(urlPath) {
|
|
59614
|
-
let
|
|
59615
|
-
if (!
|
|
59616
|
-
|
|
59676
|
+
let path2 = urlPath.split("?")[0].split("#")[0];
|
|
59677
|
+
if (!path2.startsWith("/")) {
|
|
59678
|
+
path2 = "/" + path2;
|
|
59617
59679
|
}
|
|
59618
59680
|
if (this.root !== "/") {
|
|
59619
|
-
|
|
59681
|
+
path2 = this.root + path2;
|
|
59620
59682
|
}
|
|
59621
|
-
return
|
|
59683
|
+
return path2;
|
|
59622
59684
|
}
|
|
59623
59685
|
/**
|
|
59624
59686
|
* Create a 404 Not Found response
|
|
59625
59687
|
*/
|
|
59626
|
-
notFound(
|
|
59627
|
-
const body = `Not found: ${
|
|
59688
|
+
notFound(path2) {
|
|
59689
|
+
const body = `Not found: ${path2}`;
|
|
59628
59690
|
return {
|
|
59629
59691
|
statusCode: 404,
|
|
59630
59692
|
statusMessage: "Not Found",
|
|
@@ -59669,16 +59731,16 @@ var DevServer = class extends EventEmitter {
|
|
|
59669
59731
|
/**
|
|
59670
59732
|
* Get MIME type for a file path
|
|
59671
59733
|
*/
|
|
59672
|
-
getMimeType(
|
|
59673
|
-
const ext2 =
|
|
59734
|
+
getMimeType(path2) {
|
|
59735
|
+
const ext2 = path2.split(".").pop()?.toLowerCase() || "";
|
|
59674
59736
|
return MIME_TYPES[ext2] || "application/octet-stream";
|
|
59675
59737
|
}
|
|
59676
59738
|
/**
|
|
59677
59739
|
* Check if a path exists in the virtual filesystem
|
|
59678
59740
|
*/
|
|
59679
|
-
exists(
|
|
59741
|
+
exists(path2) {
|
|
59680
59742
|
try {
|
|
59681
|
-
this.vfs.statSync(
|
|
59743
|
+
this.vfs.statSync(path2);
|
|
59682
59744
|
return true;
|
|
59683
59745
|
} catch {
|
|
59684
59746
|
return false;
|
|
@@ -59687,9 +59749,9 @@ var DevServer = class extends EventEmitter {
|
|
|
59687
59749
|
/**
|
|
59688
59750
|
* Check if a path is a directory
|
|
59689
59751
|
*/
|
|
59690
|
-
isDirectory(
|
|
59752
|
+
isDirectory(path2) {
|
|
59691
59753
|
try {
|
|
59692
|
-
return this.vfs.statSync(
|
|
59754
|
+
return this.vfs.statSync(path2).isDirectory();
|
|
59693
59755
|
} catch {
|
|
59694
59756
|
return false;
|
|
59695
59757
|
}
|
|
@@ -60014,13 +60076,13 @@ var ViteDevServer = class extends DevServer {
|
|
|
60014
60076
|
/**
|
|
60015
60077
|
* Handle file change event
|
|
60016
60078
|
*/
|
|
60017
|
-
handleFileChange(
|
|
60018
|
-
const isCSS =
|
|
60019
|
-
const isJS = /\.(jsx?|tsx?)$/.test(
|
|
60079
|
+
handleFileChange(path2) {
|
|
60080
|
+
const isCSS = path2.endsWith(".css");
|
|
60081
|
+
const isJS = /\.(jsx?|tsx?)$/.test(path2);
|
|
60020
60082
|
const updateType = isCSS || isJS ? "update" : "full-reload";
|
|
60021
60083
|
const update = {
|
|
60022
60084
|
type: updateType,
|
|
60023
|
-
path:
|
|
60085
|
+
path: path2,
|
|
60024
60086
|
timestamp: Date.now()
|
|
60025
60087
|
};
|
|
60026
60088
|
this.emitHMRUpdate(update);
|
|
@@ -60045,8 +60107,8 @@ var ViteDevServer = class extends DevServer {
|
|
|
60045
60107
|
/**
|
|
60046
60108
|
* Check if a file needs transformation
|
|
60047
60109
|
*/
|
|
60048
|
-
needsTransform(
|
|
60049
|
-
return /\.(jsx|tsx|ts)$/.test(
|
|
60110
|
+
needsTransform(path2) {
|
|
60111
|
+
return /\.(jsx|tsx|ts)$/.test(path2);
|
|
60050
60112
|
}
|
|
60051
60113
|
/**
|
|
60052
60114
|
* Transform and serve a JSX/TS file
|
|
@@ -60298,7 +60360,7 @@ function wrapCjsAsEsm(code2, virtualPrefix = "", requestPath = "") {
|
|
|
60298
60360
|
if (!/\b(require\s*\(|module\.exports|exports\.)/.test(stripped)) {
|
|
60299
60361
|
return code2;
|
|
60300
60362
|
}
|
|
60301
|
-
const requestDir = requestPath ?
|
|
60363
|
+
const requestDir = requestPath ? posixPath.dirname(requestPath) : "";
|
|
60302
60364
|
const commentFree = code2.replace(
|
|
60303
60365
|
/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`|\/\*[\s\S]*?\*\/|\/\/[^\n]*)/g,
|
|
60304
60366
|
(m) => {
|
|
@@ -60319,7 +60381,7 @@ function wrapCjsAsEsm(code2, virtualPrefix = "", requestPath = "") {
|
|
|
60319
60381
|
const varName = `__cjs_req_${counter++}__`;
|
|
60320
60382
|
let resolvedSpec;
|
|
60321
60383
|
if (specifier.startsWith(".")) {
|
|
60322
|
-
resolvedSpec = `${virtualPrefix}${
|
|
60384
|
+
resolvedSpec = `${virtualPrefix}${posixPath.resolve(requestDir, specifier)}`;
|
|
60323
60385
|
} else {
|
|
60324
60386
|
resolvedSpec = `${virtualPrefix}/node_modules/${specifier}`;
|
|
60325
60387
|
}
|
|
@@ -60409,7 +60471,7 @@ async function ensureEsbuildWasm() {
|
|
|
60409
60471
|
await window.__esbuildInitPromise;
|
|
60410
60472
|
}
|
|
60411
60473
|
function normalizePath(inputPath) {
|
|
60412
|
-
return
|
|
60474
|
+
return posixPath.normalize(inputPath.trim() || "/") || "/";
|
|
60413
60475
|
}
|
|
60414
60476
|
function isInternalAlmostNodePath(targetPath) {
|
|
60415
60477
|
const normalizedPath = normalizePath(targetPath);
|
|
@@ -60469,7 +60531,7 @@ function removeVirtualPath(vfs2, targetPath) {
|
|
|
60469
60531
|
return;
|
|
60470
60532
|
}
|
|
60471
60533
|
for (const childName of vfs2.readdirSync(normalizedPath)) {
|
|
60472
|
-
removeVirtualPath(vfs2,
|
|
60534
|
+
removeVirtualPath(vfs2, posixPath.join(normalizedPath, childName));
|
|
60473
60535
|
}
|
|
60474
60536
|
vfs2.rmdirSync(normalizedPath);
|
|
60475
60537
|
}
|
|
@@ -60779,8 +60841,8 @@ var AlmostNodeSession = class {
|
|
|
60779
60841
|
return result;
|
|
60780
60842
|
}
|
|
60781
60843
|
async serveExistingVirtualStaticFile(root2, requestUrl, bufferCtor) {
|
|
60782
|
-
const basePath = normalizePath(
|
|
60783
|
-
const hasExtension = /\.[a-zA-Z0-9]+$/.test(
|
|
60844
|
+
const basePath = normalizePath(posixPath.join(root2, getRequestPathname(requestUrl)));
|
|
60845
|
+
const hasExtension = /\.[a-zA-Z0-9]+$/.test(posixPath.basename(basePath));
|
|
60784
60846
|
let candidates;
|
|
60785
60847
|
if (hasExtension) {
|
|
60786
60848
|
candidates = [basePath];
|
|
@@ -60792,7 +60854,7 @@ var AlmostNodeSession = class {
|
|
|
60792
60854
|
const raw = this.vfs.readFileSync(pkgPath, "utf8");
|
|
60793
60855
|
const pkg = this.parseCachedPackageJson(pkgPath, raw);
|
|
60794
60856
|
const entry = pkg ? typeof pkg.module === "string" && pkg.module || typeof pkg.main === "string" && pkg.main : null;
|
|
60795
|
-
if (entry) candidates.push(normalizePath(
|
|
60857
|
+
if (entry) candidates.push(normalizePath(posixPath.join(basePath, entry)));
|
|
60796
60858
|
}
|
|
60797
60859
|
} catch {
|
|
60798
60860
|
}
|
|
@@ -60801,7 +60863,7 @@ var AlmostNodeSession = class {
|
|
|
60801
60863
|
const raw = await this.fs.readFile(pkgPath, "utf-8");
|
|
60802
60864
|
const pkg = this.parseCachedPackageJson(pkgPath, raw);
|
|
60803
60865
|
const entry = pkg ? typeof pkg.module === "string" && pkg.module || typeof pkg.main === "string" && pkg.main : null;
|
|
60804
|
-
if (entry) candidates.push(normalizePath(
|
|
60866
|
+
if (entry) candidates.push(normalizePath(posixPath.join(basePath, entry)));
|
|
60805
60867
|
}
|
|
60806
60868
|
} catch {
|
|
60807
60869
|
}
|
|
@@ -60839,7 +60901,7 @@ var AlmostNodeSession = class {
|
|
|
60839
60901
|
}
|
|
60840
60902
|
const content = await this.fs.readFileBuffer(targetPath);
|
|
60841
60903
|
this._vfs.withoutMirror(() => {
|
|
60842
|
-
this._vfs.mkdirSync(
|
|
60904
|
+
this._vfs.mkdirSync(posixPath.dirname(targetPath), { recursive: true });
|
|
60843
60905
|
this._vfs.writeFileSync(targetPath, content);
|
|
60844
60906
|
});
|
|
60845
60907
|
const body = bufferCtor.from(content);
|
|
@@ -60885,7 +60947,7 @@ var AlmostNodeSession = class {
|
|
|
60885
60947
|
}
|
|
60886
60948
|
}
|
|
60887
60949
|
for (const packageName of candidatePackageNames) {
|
|
60888
|
-
const pkgJsonPath = normalizePath(
|
|
60950
|
+
const pkgJsonPath = normalizePath(posixPath.join(cwd, "node_modules", packageName, "package.json"));
|
|
60889
60951
|
if (!await this.fs.exists(pkgJsonPath)) {
|
|
60890
60952
|
continue;
|
|
60891
60953
|
}
|
|
@@ -60895,16 +60957,16 @@ var AlmostNodeSession = class {
|
|
|
60895
60957
|
if (!pkgJson) {
|
|
60896
60958
|
continue;
|
|
60897
60959
|
}
|
|
60898
|
-
const pkgDir = normalizePath(
|
|
60960
|
+
const pkgDir = normalizePath(posixPath.join(cwd, "node_modules", packageName));
|
|
60899
60961
|
if (typeof pkgJson.bin === "string") {
|
|
60900
60962
|
const inferredBinName = typeof pkgJson.name === "string" ? pkgJson.name.split("/").pop() ?? pkgJson.name : packageName.split("/").pop() ?? packageName;
|
|
60901
60963
|
if (binName === inferredBinName) {
|
|
60902
|
-
return normalizePath(
|
|
60964
|
+
return normalizePath(posixPath.join(pkgDir, pkgJson.bin));
|
|
60903
60965
|
}
|
|
60904
60966
|
}
|
|
60905
60967
|
if (typeof pkgJson.bin === "object" && pkgJson.bin !== null && binName in pkgJson.bin) {
|
|
60906
60968
|
const namedBins = pkgJson.bin;
|
|
60907
|
-
return normalizePath(
|
|
60969
|
+
return normalizePath(posixPath.join(pkgDir, namedBins[binName]));
|
|
60908
60970
|
}
|
|
60909
60971
|
} catch {
|
|
60910
60972
|
}
|
|
@@ -60991,7 +61053,7 @@ var AlmostNodeSession = class {
|
|
|
60991
61053
|
}
|
|
60992
61054
|
const content = await this.fs.readFileBuffer(normalizedPath);
|
|
60993
61055
|
this._vfs.withoutMirror(() => {
|
|
60994
|
-
this._vfs.mkdirSync(
|
|
61056
|
+
this._vfs.mkdirSync(posixPath.dirname(normalizedPath), { recursive: true });
|
|
60995
61057
|
this._vfs.writeFileSync(normalizedPath, content);
|
|
60996
61058
|
});
|
|
60997
61059
|
} catch {
|
|
@@ -61054,7 +61116,7 @@ var AlmostNodeSession = class {
|
|
|
61054
61116
|
});
|
|
61055
61117
|
this._vfs.withoutMirror(() => {
|
|
61056
61118
|
for (const [filePath, content] of contents) {
|
|
61057
|
-
this._vfs.mkdirSync(
|
|
61119
|
+
this._vfs.mkdirSync(posixPath.dirname(filePath), { recursive: true });
|
|
61058
61120
|
this._vfs.writeFileSync(filePath, content);
|
|
61059
61121
|
}
|
|
61060
61122
|
});
|
|
@@ -61075,7 +61137,7 @@ var AlmostNodeSession = class {
|
|
|
61075
61137
|
}
|
|
61076
61138
|
const dependencyPaths = [];
|
|
61077
61139
|
for (const packageName of getPackageJsonDependencyNames(packageJsonResult.pkgJson)) {
|
|
61078
|
-
const packageRoot = normalizePath(
|
|
61140
|
+
const packageRoot = normalizePath(posixPath.join(cwd, "node_modules", packageName));
|
|
61079
61141
|
if (!await this.fs.exists(packageRoot)) {
|
|
61080
61142
|
continue;
|
|
61081
61143
|
}
|
|
@@ -61109,7 +61171,7 @@ var AlmostNodeSession = class {
|
|
|
61109
61171
|
return;
|
|
61110
61172
|
}
|
|
61111
61173
|
await this.withSuppressedObservableMirroring(async () => {
|
|
61112
|
-
await ensureObservableDirectory(this.fs,
|
|
61174
|
+
await ensureObservableDirectory(this.fs, posixPath.dirname(normalizedPath));
|
|
61113
61175
|
await this.fs.writeFile(normalizedPath, data2);
|
|
61114
61176
|
});
|
|
61115
61177
|
})());
|
|
@@ -61144,7 +61206,7 @@ var AlmostNodeSession = class {
|
|
|
61144
61206
|
return;
|
|
61145
61207
|
}
|
|
61146
61208
|
await this.withSuppressedObservableMirroring(async () => {
|
|
61147
|
-
await ensureObservableDirectory(this.fs,
|
|
61209
|
+
await ensureObservableDirectory(this.fs, posixPath.dirname(normalizedNextPath));
|
|
61148
61210
|
await this.fs.mv(normalizedPreviousPath, normalizedNextPath);
|
|
61149
61211
|
});
|
|
61150
61212
|
})());
|
|
@@ -61165,7 +61227,7 @@ var AlmostNodeSession = class {
|
|
|
61165
61227
|
await this.initializePromise;
|
|
61166
61228
|
}
|
|
61167
61229
|
async readPackageJson(cwd) {
|
|
61168
|
-
const packageJsonPath = normalizePath(
|
|
61230
|
+
const packageJsonPath = normalizePath(posixPath.join(cwd, "package.json"));
|
|
61169
61231
|
if (!this.vfs.existsSync(packageJsonPath)) {
|
|
61170
61232
|
await this.copyObservablePathIntoVirtualFs(packageJsonPath, { force: true });
|
|
61171
61233
|
}
|
|
@@ -61277,7 +61339,7 @@ var AlmostNodeSession = class {
|
|
|
61277
61339
|
...baseEnv,
|
|
61278
61340
|
npm_lifecycle_event: scriptName,
|
|
61279
61341
|
PATH: Array.from(/* @__PURE__ */ new Set([
|
|
61280
|
-
normalizePath(
|
|
61342
|
+
normalizePath(posixPath.join(cwd, "node_modules/.bin")),
|
|
61281
61343
|
"/node_modules/.bin",
|
|
61282
61344
|
...(baseEnv.PATH?.trim() || DEFAULT_PATH).split(":").filter(Boolean)
|
|
61283
61345
|
])).join(":")
|
|
@@ -61479,7 +61541,7 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
61479
61541
|
message: `Unsupported node flag in just-bash: ${firstArg}`
|
|
61480
61542
|
};
|
|
61481
61543
|
}
|
|
61482
|
-
const scriptPath =
|
|
61544
|
+
const scriptPath = posixPath.isAbsolute(firstArg) ? normalizePath(firstArg) : normalizePath(posixPath.resolve(cwd, firstArg));
|
|
61483
61545
|
return {
|
|
61484
61546
|
kind: "run-file",
|
|
61485
61547
|
scriptPath,
|
|
@@ -61678,7 +61740,7 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
61678
61740
|
if (!targetPath.startsWith(`${cwdPrefix}node_modules/`)) {
|
|
61679
61741
|
return true;
|
|
61680
61742
|
}
|
|
61681
|
-
const baseName =
|
|
61743
|
+
const baseName = posixPath.basename(targetPath).toLowerCase();
|
|
61682
61744
|
if (baseName === "package.json") {
|
|
61683
61745
|
return true;
|
|
61684
61746
|
}
|
|
@@ -61696,7 +61758,7 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
61696
61758
|
});
|
|
61697
61759
|
this._vfs.withoutMirror(() => {
|
|
61698
61760
|
for (const [filePath, content] of contents) {
|
|
61699
|
-
this._vfs.mkdirSync(
|
|
61761
|
+
this._vfs.mkdirSync(posixPath.dirname(filePath), { recursive: true });
|
|
61700
61762
|
this._vfs.writeFileSync(filePath, content);
|
|
61701
61763
|
}
|
|
61702
61764
|
});
|
|
@@ -61817,17 +61879,17 @@ var DEFAULT_BASH_SHELL_ENV = {
|
|
|
61817
61879
|
var DEFAULT_BASH_COMMAND_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
61818
61880
|
var DEFAULT_BASH_OUTPUT_LIMIT = 1e4;
|
|
61819
61881
|
function normalizeBashPath(input) {
|
|
61820
|
-
const
|
|
61882
|
+
const posixPath2 = input.trim().replace(/\\/g, "/") || "/";
|
|
61821
61883
|
const segments = [];
|
|
61822
|
-
const
|
|
61823
|
-
for (const segment of
|
|
61884
|
+
const isAbsolute3 = posixPath2.startsWith("/");
|
|
61885
|
+
for (const segment of posixPath2.split("/")) {
|
|
61824
61886
|
if (segment === "..") {
|
|
61825
61887
|
segments.pop();
|
|
61826
61888
|
} else if (segment !== "." && segment !== "") {
|
|
61827
61889
|
segments.push(segment);
|
|
61828
61890
|
}
|
|
61829
61891
|
}
|
|
61830
|
-
return (
|
|
61892
|
+
return (isAbsolute3 ? "/" : "") + segments.join("/") || "/";
|
|
61831
61893
|
}
|
|
61832
61894
|
function truncateBashOutput(output, limitBytes = DEFAULT_BASH_OUTPUT_LIMIT) {
|
|
61833
61895
|
if (!output || output.length <= limitBytes) {
|
|
@@ -61854,7 +61916,8 @@ function createBrowserBashSession(options2 = {}) {
|
|
|
61854
61916
|
fs,
|
|
61855
61917
|
customCommands: [
|
|
61856
61918
|
Dx("node", async (args, ctx) => almostNodeSession.executeNode(args, ctx)),
|
|
61857
|
-
Dx("npm", async (args, ctx) => almostNodeSession.executeNpm(args, ctx))
|
|
61919
|
+
Dx("npm", async (args, ctx) => almostNodeSession.executeNpm(args, ctx)),
|
|
61920
|
+
...options2.customCommands ?? []
|
|
61858
61921
|
]
|
|
61859
61922
|
});
|
|
61860
61923
|
almostNodeSession.setBinCommandRegistrar((name, handler) => {
|