poe-code 14.0.94 → 14.0.96
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/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-bash/dist/commands/apply-patch/apply.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/apply-patch/apply.js +5 -2
- package/packages/safe-bash/dist/commands/apply-patch/apply.js.map +1 -1
- package/packages/safe-bash/dist/commands/archive/extract.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/archive/extract.js +5 -2
- package/packages/safe-bash/dist/commands/archive/extract.js.map +1 -1
- package/packages/safe-bash/dist/commands/archive/internal.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/archive/internal.js +6 -2
- package/packages/safe-bash/dist/commands/archive/internal.js.map +1 -1
- package/packages/safe-bash/dist/commands/bytes/compression/files.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/bytes/compression/files.js +10 -6
- package/packages/safe-bash/dist/commands/bytes/compression/files.js.map +1 -1
- package/packages/safe-bash/dist/commands/diff-patch/diff.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/diff-patch/diff.js +4 -3
- package/packages/safe-bash/dist/commands/diff-patch/diff.js.map +1 -1
- package/packages/safe-bash/dist/commands/diff-patch/shared.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/diff-patch/shared.js +5 -3
- package/packages/safe-bash/dist/commands/diff-patch/shared.js.map +1 -1
- package/packages/safe-bash/dist/commands/du/du.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/du/du.js +6 -6
- package/packages/safe-bash/dist/commands/du/du.js.map +1 -1
- package/packages/safe-bash/dist/commands/file/index.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/file/index.js +9 -3
- package/packages/safe-bash/dist/commands/file/index.js.map +1 -1
- package/packages/safe-bash/dist/commands/filesystem-requirements.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/filesystem-requirements.js +1 -0
- package/packages/safe-bash/dist/commands/filesystem-requirements.js.map +1 -1
- package/packages/safe-bash/dist/commands/filesystem.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/filesystem.js +54 -10
- package/packages/safe-bash/dist/commands/filesystem.js.map +1 -1
- package/packages/safe-bash/dist/commands/find.js +1 -1
- package/packages/safe-bash/dist/commands/find.js.map +1 -1
- package/packages/safe-bash/dist/commands/html-to-markdown/input.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/html-to-markdown/input.js +12 -18
- package/packages/safe-bash/dist/commands/html-to-markdown/input.js.map +1 -1
- package/packages/safe-bash/dist/commands/internal.d.ts +1 -1
- package/packages/safe-bash/dist/commands/internal.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/internal.js +3 -2
- package/packages/safe-bash/dist/commands/internal.js.map +1 -1
- package/packages/safe-bash/dist/commands/metadata/internal.d.ts +2 -2
- package/packages/safe-bash/dist/commands/metadata/internal.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/metadata/internal.js +1 -1
- package/packages/safe-bash/dist/commands/metadata/internal.js.map +1 -1
- package/packages/safe-bash/dist/commands/metadata/mktemp.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/metadata/mktemp.js +5 -2
- package/packages/safe-bash/dist/commands/metadata/mktemp.js.map +1 -1
- package/packages/safe-bash/dist/commands/metadata/stat.js +1 -1
- package/packages/safe-bash/dist/commands/metadata/stat.js.map +1 -1
- package/packages/safe-bash/dist/commands/move.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/move.js +3 -2
- package/packages/safe-bash/dist/commands/move.js.map +1 -1
- package/packages/safe-bash/dist/commands/network/body.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/network/body.js +3 -1
- package/packages/safe-bash/dist/commands/network/body.js.map +1 -1
- package/packages/safe-bash/dist/commands/predicates.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/predicates.js +8 -2
- package/packages/safe-bash/dist/commands/predicates.js.map +1 -1
- package/packages/safe-bash/dist/commands/safejs/index.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/safejs/index.js +2 -1
- package/packages/safe-bash/dist/commands/safejs/index.js.map +1 -1
- package/packages/safe-bash/dist/commands/split/io.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/split/io.js +2 -1
- package/packages/safe-bash/dist/commands/split/io.js.map +1 -1
- package/packages/safe-bash/dist/commands/split/split.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/split/split.js +2 -1
- package/packages/safe-bash/dist/commands/split/split.js.map +1 -1
- package/packages/safe-bash/dist/commands/stream-format/shared.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/stream-format/shared.js +7 -4
- package/packages/safe-bash/dist/commands/stream-format/shared.js.map +1 -1
- package/packages/safe-bash/dist/commands/stream-inspection/shared.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/stream-inspection/shared.js +7 -4
- package/packages/safe-bash/dist/commands/stream-inspection/shared.js.map +1 -1
- package/packages/safe-bash/dist/commands/streams.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/streams.js +4 -2
- package/packages/safe-bash/dist/commands/streams.js.map +1 -1
- package/packages/safe-bash/dist/commands/structured/jq.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/structured/jq.js +15 -5
- package/packages/safe-bash/dist/commands/structured/jq.js.map +1 -1
- package/packages/safe-bash/dist/commands/table-text/internal.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/table-text/internal.js +5 -4
- package/packages/safe-bash/dist/commands/table-text/internal.js.map +1 -1
- package/packages/safe-bash/dist/commands/text-programs/awk-runtime.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/text-programs/awk-runtime.js +10 -4
- package/packages/safe-bash/dist/commands/text-programs/awk-runtime.js.map +1 -1
- package/packages/safe-bash/dist/commands/text.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/text.js +3 -2
- package/packages/safe-bash/dist/commands/text.js.map +1 -1
- package/packages/safe-bash/dist/commands/time-env/date.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/time-env/date.js +3 -2
- package/packages/safe-bash/dist/commands/time-env/date.js.map +1 -1
- package/packages/safe-bash/dist/commands/tree/tree.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/tree/tree.js +2 -1
- package/packages/safe-bash/dist/commands/tree/tree.js.map +1 -1
- package/packages/safe-bash/dist/contracts/filesystem.d.ts +1 -1
- package/packages/safe-bash/dist/contracts/filesystem.d.ts.map +1 -1
- package/packages/safe-bash/dist/core.browser.js +259 -119
- package/packages/safe-bash/dist/core.browser.js.map +4 -4
- package/packages/safe-bash/dist/shell/conditional.d.ts.map +1 -1
- package/packages/safe-bash/dist/shell/conditional.js +10 -6
- package/packages/safe-bash/dist/shell/conditional.js.map +1 -1
- package/packages/safe-bash/dist/shell/input.d.ts +1 -1
- package/packages/safe-bash/dist/shell/input.d.ts.map +1 -1
- package/packages/safe-bash/dist/shell/input.js +7 -3
- package/packages/safe-bash/dist/shell/input.js.map +1 -1
- package/packages/safe-bash/dist/shell/runtime.d.ts +2 -1
- package/packages/safe-bash/dist/shell/runtime.d.ts.map +1 -1
- package/packages/safe-bash/dist/shell/runtime.js +37 -28
- package/packages/safe-bash/dist/shell/runtime.js.map +1 -1
- package/packages/safe-bash/dist/shell/shell.d.ts.map +1 -1
- package/packages/safe-bash/dist/shell/shell.js +3 -1
- package/packages/safe-bash/dist/shell/shell.js.map +1 -1
- package/packages/safe-fs/dist/contracts/filesystem.d.ts +6 -2
- package/packages/safe-fs/dist/core.d.ts +1 -0
- package/packages/safe-fs/dist/fs/devices/index.d.ts +33 -0
- package/packages/safe-fs/dist/fs/devices/path.d.ts +5 -0
- package/packages/safe-fs/dist/fs/devices/stream.d.ts +5 -0
- package/packages/safe-fs/dist/fs/memory/index.d.ts +3 -2
- package/packages/safe-fs/dist/fs/mount/index.d.ts +2 -2
- package/packages/safe-fs/dist/fs/overlay/index.d.ts +2 -2
- package/packages/safe-fs/dist/fs/readonly/index.d.ts +2 -2
- package/packages/safe-fs/dist/fs/real/index.d.ts +2 -2
- package/packages/safe-fs/dist/fs/s3/filesystem.d.ts +3 -2
- package/packages/safe-fs/dist/fs/webdav/webdav.d.ts +3 -2
- package/packages/safe-fs/dist/index.d.ts +1 -0
- package/packages/safe-js/dist/browser/chunks/{chunk-I3HSJDAA.js → chunk-QK4IEGRO.js} +610 -4
- package/packages/safe-js/dist/browser/chunks/chunk-QK4IEGRO.js.map +7 -0
- package/packages/safe-js/dist/browser/safe-fs-core.js +5 -1
- package/packages/safe-js/dist/browser/safe-fs.js +5 -1
- package/packages/safe-js/dist/chunks/{chunk-CQZRYT3K.js → chunk-6V4U2JZS.js} +610 -4
- package/packages/safe-js/dist/chunks/chunk-6V4U2JZS.js.map +7 -0
- package/packages/safe-js/dist/chunks/{chunk-PZSJ52ZO.js → chunk-EZRL4ES2.js} +3 -3
- package/packages/safe-js/dist/chunks/{chunk-66PPRTEP.js → chunk-XOQ5CVQM.js} +9 -2
- package/packages/safe-js/dist/chunks/chunk-XOQ5CVQM.js.map +7 -0
- package/packages/safe-js/dist/cli.js +3 -3
- package/packages/safe-js/dist/index.js +3 -3
- package/packages/safe-js/dist/safe-fs-core.js +5 -1
- package/packages/safe-js/dist/safe-fs-core.js.map +1 -1
- package/packages/safe-js/dist/safe-fs-node.js +6 -2
- package/packages/safe-js/dist/safe-fs.js +6 -2
- package/packages/safe-js/dist/browser/chunks/chunk-I3HSJDAA.js.map +0 -7
- package/packages/safe-js/dist/chunks/chunk-66PPRTEP.js.map +0 -7
- package/packages/safe-js/dist/chunks/chunk-CQZRYT3K.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-PZSJ52ZO.js.map → chunk-EZRL4ES2.js.map} +0 -0
|
@@ -807,6 +807,7 @@ var MemoryFileSystem = class _MemoryFileSystem {
|
|
|
807
807
|
removeDirectory: true,
|
|
808
808
|
recursiveRemove: true,
|
|
809
809
|
rename: true,
|
|
810
|
+
atomicRenameNoReplace: true,
|
|
810
811
|
copy: true,
|
|
811
812
|
exclusiveCopy: true,
|
|
812
813
|
readlink: true,
|
|
@@ -1231,6 +1232,7 @@ var MemoryFileSystem = class _MemoryFileSystem {
|
|
|
1231
1232
|
if (this.terminalDot(source) || this.terminalDot(destination)) this.fail("EINVAL", "rename", source, destination);
|
|
1232
1233
|
if (node === this.root || target.node === this.root) this.fail("EBUSY", "rename", source, destination);
|
|
1233
1234
|
if (destination.endsWith("/") && node.type !== "directory") this.fail("ENOTDIR", "rename", source, destination);
|
|
1235
|
+
if (options.noReplace && target.node) this.fail("EEXIST", "rename", source, destination);
|
|
1234
1236
|
if (target.node === node) return;
|
|
1235
1237
|
if (node.type === "directory" && target.path.startsWith(`${origin.path}/`)) this.fail("EINVAL", "rename", source, destination);
|
|
1236
1238
|
this.permission(origin.parent, 3, "rename", source);
|
|
@@ -1521,6 +1523,574 @@ function createMemoryFileSystem(options = {}) {
|
|
|
1521
1523
|
return new MemoryFileSystem(normalizeMemoryFileSystemLimits(options));
|
|
1522
1524
|
}
|
|
1523
1525
|
|
|
1526
|
+
// packages/safe-fs/src/fs/devices/path.ts
|
|
1527
|
+
var nullPath = "/dev/null";
|
|
1528
|
+
var deviceDirectory = "/dev";
|
|
1529
|
+
function lexicalDevicePath(path) {
|
|
1530
|
+
validatePath(path);
|
|
1531
|
+
const parts = [];
|
|
1532
|
+
for (const component of path.split("/")) {
|
|
1533
|
+
if (`/${parts.join("/")}` === nullPath) throw new FsError("ENOTDIR", { path });
|
|
1534
|
+
if (component === "..") parts.pop();
|
|
1535
|
+
else if (component && component !== ".") parts.push(component);
|
|
1536
|
+
}
|
|
1537
|
+
return `/${parts.join("/")}`;
|
|
1538
|
+
}
|
|
1539
|
+
async function resolveDevicePath(filesystem, path, options, followFinal = true) {
|
|
1540
|
+
options.signal?.throwIfAborted();
|
|
1541
|
+
const lexical = lexicalDevicePath(path);
|
|
1542
|
+
const aliases = typeof filesystem.lstat === "function";
|
|
1543
|
+
if (!aliases && lexical !== nullPath && lexical !== deviceDirectory && lexical !== "/") return lexical;
|
|
1544
|
+
const pending = path.split("/");
|
|
1545
|
+
const parts = [];
|
|
1546
|
+
let links = 0;
|
|
1547
|
+
let expanded = path.length;
|
|
1548
|
+
let absolute = path.startsWith("/");
|
|
1549
|
+
let traversalFailure;
|
|
1550
|
+
while (pending.length) {
|
|
1551
|
+
options.signal?.throwIfAborted();
|
|
1552
|
+
if (`/${parts.join("/")}` === nullPath) throw new FsError("ENOTDIR", { path });
|
|
1553
|
+
const component = pending.shift();
|
|
1554
|
+
if (!component || component === ".") continue;
|
|
1555
|
+
if (component === "..") {
|
|
1556
|
+
parts.pop();
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1559
|
+
const candidate = `/${[...parts, component].join("/")}`;
|
|
1560
|
+
if (candidate !== deviceDirectory && candidate !== nullPath && (followFinal && aliases || pending.length)) {
|
|
1561
|
+
const lookup = absolute ? candidate : candidate.slice(1);
|
|
1562
|
+
let stat;
|
|
1563
|
+
try {
|
|
1564
|
+
if (typeof filesystem.lstat !== "function") throw new FsError("ENOTSUP", { path });
|
|
1565
|
+
stat = await filesystem.lstat(lookup, options);
|
|
1566
|
+
} catch (error) {
|
|
1567
|
+
options.signal?.throwIfAborted();
|
|
1568
|
+
if (isFsError(error, "ENOTSUP") && links === 0 && lexical !== nullPath && lexical !== deviceDirectory && lexical !== "/") return lexical;
|
|
1569
|
+
if (!isFsError(error, "ENOENT")) throw error;
|
|
1570
|
+
if (pending.length) traversalFailure ??= error;
|
|
1571
|
+
}
|
|
1572
|
+
options.signal?.throwIfAborted();
|
|
1573
|
+
if (stat?.type === "symlink") {
|
|
1574
|
+
if (typeof filesystem.readlink !== "function") throw new FsError("ENOTSUP", { path });
|
|
1575
|
+
if (++links > 40) throw new FsError("ELOOP", { path });
|
|
1576
|
+
const target = await filesystem.readlink(lookup, options);
|
|
1577
|
+
options.signal?.throwIfAborted();
|
|
1578
|
+
validatePath(target);
|
|
1579
|
+
expanded += target.length;
|
|
1580
|
+
if (expanded > 65536) throw new FsError("ENAMETOOLONG", { path });
|
|
1581
|
+
if (target.startsWith("/")) {
|
|
1582
|
+
parts.length = 0;
|
|
1583
|
+
absolute = true;
|
|
1584
|
+
}
|
|
1585
|
+
pending.unshift(...target.split("/"));
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
if (stat && pending.length && stat.type !== "directory") traversalFailure ??= new FsError("ENOTDIR", { path });
|
|
1589
|
+
}
|
|
1590
|
+
parts.push(component);
|
|
1591
|
+
}
|
|
1592
|
+
const resolved = `/${parts.join("/")}`;
|
|
1593
|
+
if (traversalFailure && (resolved === nullPath || resolved === deviceDirectory || resolved === "/")) throw traversalFailure;
|
|
1594
|
+
return resolved;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// packages/safe-fs/src/fs/devices/stream.ts
|
|
1598
|
+
function deviceReadStream(open) {
|
|
1599
|
+
return { [Symbol.asyncIterator]() {
|
|
1600
|
+
let opened;
|
|
1601
|
+
let closing;
|
|
1602
|
+
const iterator = () => opened ??= open().then((source) => source[Symbol.asyncIterator]());
|
|
1603
|
+
const close = () => closing ??= iterator().then(async (source) => source.return ? source.return() : { done: true, value: void 0 });
|
|
1604
|
+
return {
|
|
1605
|
+
async next() {
|
|
1606
|
+
if (closing) {
|
|
1607
|
+
await closing;
|
|
1608
|
+
return { done: true, value: void 0 };
|
|
1609
|
+
}
|
|
1610
|
+
try {
|
|
1611
|
+
return await (await iterator()).next();
|
|
1612
|
+
} catch (error) {
|
|
1613
|
+
await finishCleanup(close, true);
|
|
1614
|
+
throw error;
|
|
1615
|
+
}
|
|
1616
|
+
},
|
|
1617
|
+
return: close
|
|
1618
|
+
};
|
|
1619
|
+
} };
|
|
1620
|
+
}
|
|
1621
|
+
async function drainDeviceFile(handle, signal) {
|
|
1622
|
+
let failed = false;
|
|
1623
|
+
let position = 0;
|
|
1624
|
+
try {
|
|
1625
|
+
await drainDeviceInput({ [Symbol.asyncIterator]: () => ({ async next() {
|
|
1626
|
+
const value = await handle.read(position, 65536, signal ? { signal } : {});
|
|
1627
|
+
if (!(value instanceof Uint8Array) || value.byteLength > 65536) throw new TypeError("Retained reads must return bounded Uint8Array chunks");
|
|
1628
|
+
position += value.byteLength;
|
|
1629
|
+
if (!Number.isSafeInteger(position)) throw new RangeError("Retained read position exceeds safe integer range");
|
|
1630
|
+
return { done: value.byteLength === 0, value };
|
|
1631
|
+
} }) }, signal);
|
|
1632
|
+
} catch (error) {
|
|
1633
|
+
failed = true;
|
|
1634
|
+
throw error;
|
|
1635
|
+
} finally {
|
|
1636
|
+
await finishCleanup(async () => {
|
|
1637
|
+
try {
|
|
1638
|
+
await handle.close();
|
|
1639
|
+
} catch (error) {
|
|
1640
|
+
signal?.throwIfAborted();
|
|
1641
|
+
throw error;
|
|
1642
|
+
}
|
|
1643
|
+
}, failed);
|
|
1644
|
+
}
|
|
1645
|
+
signal?.throwIfAborted();
|
|
1646
|
+
}
|
|
1647
|
+
function nextChunk(iterator, signal) {
|
|
1648
|
+
signal?.throwIfAborted();
|
|
1649
|
+
return new Promise((resolve, reject) => {
|
|
1650
|
+
const aborted = () => {
|
|
1651
|
+
signal?.removeEventListener("abort", aborted);
|
|
1652
|
+
reject(signal?.reason);
|
|
1653
|
+
};
|
|
1654
|
+
signal?.addEventListener("abort", aborted, { once: true });
|
|
1655
|
+
try {
|
|
1656
|
+
Promise.resolve(iterator.next()).then((result) => {
|
|
1657
|
+
signal?.removeEventListener("abort", aborted);
|
|
1658
|
+
if (signal?.aborted) reject(signal.reason);
|
|
1659
|
+
else resolve(result);
|
|
1660
|
+
}, (error) => {
|
|
1661
|
+
signal?.removeEventListener("abort", aborted);
|
|
1662
|
+
reject(signal?.aborted ? signal.reason : error);
|
|
1663
|
+
});
|
|
1664
|
+
} catch (error) {
|
|
1665
|
+
signal?.removeEventListener("abort", aborted);
|
|
1666
|
+
reject(signal?.aborted ? signal.reason : error);
|
|
1667
|
+
}
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
async function drainDeviceInput(source, signal) {
|
|
1671
|
+
signal?.throwIfAborted();
|
|
1672
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
1673
|
+
let failed = false;
|
|
1674
|
+
let bytes = 0;
|
|
1675
|
+
let pulls = 0;
|
|
1676
|
+
try {
|
|
1677
|
+
for (; ; ) {
|
|
1678
|
+
const result = await nextChunk(iterator, signal);
|
|
1679
|
+
signal?.throwIfAborted();
|
|
1680
|
+
if (result.done) break;
|
|
1681
|
+
if (!(result.value instanceof Uint8Array)) throw new TypeError("Byte sources must yield Uint8Array chunks");
|
|
1682
|
+
bytes += result.value.byteLength;
|
|
1683
|
+
if (++pulls >= 64 || bytes >= 65536) {
|
|
1684
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1685
|
+
signal?.throwIfAborted();
|
|
1686
|
+
bytes = 0;
|
|
1687
|
+
pulls = 0;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
} catch (error) {
|
|
1691
|
+
failed = true;
|
|
1692
|
+
throw error;
|
|
1693
|
+
} finally {
|
|
1694
|
+
await finishCleanup(async () => {
|
|
1695
|
+
try {
|
|
1696
|
+
await iterator.return?.();
|
|
1697
|
+
} catch (error) {
|
|
1698
|
+
signal?.throwIfAborted();
|
|
1699
|
+
throw error;
|
|
1700
|
+
}
|
|
1701
|
+
}, failed);
|
|
1702
|
+
}
|
|
1703
|
+
signal?.throwIfAborted();
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
// packages/safe-fs/src/fs/devices/index.ts
|
|
1707
|
+
var views = /* @__PURE__ */ new WeakMap();
|
|
1708
|
+
var deviceCapabilities = Object.freeze({
|
|
1709
|
+
readOnly: false,
|
|
1710
|
+
read: true,
|
|
1711
|
+
stat: true,
|
|
1712
|
+
realpath: true,
|
|
1713
|
+
access: true,
|
|
1714
|
+
readdir: false,
|
|
1715
|
+
write: true,
|
|
1716
|
+
append: true,
|
|
1717
|
+
exclusiveCreate: true,
|
|
1718
|
+
streamingRead: true,
|
|
1719
|
+
retainedRead: true,
|
|
1720
|
+
streamingWrite: true,
|
|
1721
|
+
streamingAppend: true,
|
|
1722
|
+
copy: true,
|
|
1723
|
+
exclusiveCopy: true,
|
|
1724
|
+
remove: false,
|
|
1725
|
+
removeDirectory: false,
|
|
1726
|
+
recursiveRemove: false,
|
|
1727
|
+
rename: false,
|
|
1728
|
+
mkdir: false,
|
|
1729
|
+
recursiveMkdir: false,
|
|
1730
|
+
symlinks: false,
|
|
1731
|
+
hardlinks: false,
|
|
1732
|
+
readlink: false,
|
|
1733
|
+
permissions: false,
|
|
1734
|
+
timestamps: false,
|
|
1735
|
+
truncate: false,
|
|
1736
|
+
randomAccessWrite: false,
|
|
1737
|
+
atomicRename: false,
|
|
1738
|
+
atomicRenameNoReplace: false,
|
|
1739
|
+
descriptorWriteStream: true
|
|
1740
|
+
});
|
|
1741
|
+
function globalCapabilities(filesystem) {
|
|
1742
|
+
const capabilities = { readOnly: false };
|
|
1743
|
+
const optional = {
|
|
1744
|
+
streamingRead: ["readStream"],
|
|
1745
|
+
streamingWrite: ["writeStream"],
|
|
1746
|
+
retainedRead: ["openReadFile"],
|
|
1747
|
+
streamingAppend: ["writeStream"],
|
|
1748
|
+
descriptorWriteStream: ["writeStream"],
|
|
1749
|
+
symlinks: ["symlink", "readlink"],
|
|
1750
|
+
hardlinks: ["link"],
|
|
1751
|
+
permissions: ["chmod"],
|
|
1752
|
+
timestamps: ["utimes"],
|
|
1753
|
+
readlink: ["readlink"],
|
|
1754
|
+
truncate: ["truncate"],
|
|
1755
|
+
removeDirectory: ["rmdir"]
|
|
1756
|
+
};
|
|
1757
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(filesystem.capabilities), ...Object.keys(deviceCapabilities)])) {
|
|
1758
|
+
if (key === "readOnly") continue;
|
|
1759
|
+
Object.defineProperty(capabilities, key, { enumerable: true, get() {
|
|
1760
|
+
if (key === "copy" || key === "exclusiveCopy") return void 0;
|
|
1761
|
+
let declared = filesystem.capabilities[key];
|
|
1762
|
+
if (declared === true && optional[key]?.some((method) => typeof filesystem[method] !== "function")) declared = false;
|
|
1763
|
+
if (key === "descriptorWriteStream" && filesystem.capabilities.streamingWrite === false) declared = false;
|
|
1764
|
+
return declared === deviceCapabilities[key] ? declared : void 0;
|
|
1765
|
+
} });
|
|
1766
|
+
}
|
|
1767
|
+
return Object.freeze(capabilities);
|
|
1768
|
+
}
|
|
1769
|
+
function reserved(path) {
|
|
1770
|
+
return path === "/" || path === deviceDirectory || path === nullPath;
|
|
1771
|
+
}
|
|
1772
|
+
function nonnegative(value, path) {
|
|
1773
|
+
if (value !== void 0 && (!Number.isSafeInteger(value) || value < 0)) throw new FsError("EINVAL", { path });
|
|
1774
|
+
}
|
|
1775
|
+
var DeviceFileSystem = class {
|
|
1776
|
+
#filesystem;
|
|
1777
|
+
capabilities;
|
|
1778
|
+
#nullStat;
|
|
1779
|
+
#directoryStat;
|
|
1780
|
+
constructor(filesystem) {
|
|
1781
|
+
this.#filesystem = filesystem;
|
|
1782
|
+
this.capabilities = globalCapabilities(filesystem);
|
|
1783
|
+
const identityScope = Object.freeze({});
|
|
1784
|
+
this.#nullStat = Object.freeze({
|
|
1785
|
+
type: "character",
|
|
1786
|
+
mode: 8630,
|
|
1787
|
+
size: 0,
|
|
1788
|
+
allocatedBytes: 0,
|
|
1789
|
+
mtimeMs: 0,
|
|
1790
|
+
atimeMs: 0,
|
|
1791
|
+
ctimeMs: 0,
|
|
1792
|
+
birthtimeMs: 0,
|
|
1793
|
+
identityScope,
|
|
1794
|
+
ino: 1,
|
|
1795
|
+
dev: 0,
|
|
1796
|
+
nlink: 1
|
|
1797
|
+
});
|
|
1798
|
+
this.#directoryStat = Object.freeze({ ...this.#nullStat, type: "directory", mode: 16877, ino: 2 });
|
|
1799
|
+
const methods = /* @__PURE__ */ new Map();
|
|
1800
|
+
const view = new Proxy(this, {
|
|
1801
|
+
set: (_target, property, value) => Reflect.set(filesystem, property, value, filesystem),
|
|
1802
|
+
get(target, property) {
|
|
1803
|
+
const value = Reflect.get(target, property, target);
|
|
1804
|
+
if (typeof value !== "function" || property === "constructor") return value;
|
|
1805
|
+
const backing = Reflect.get(filesystem, property, filesystem);
|
|
1806
|
+
const cached = methods.get(property);
|
|
1807
|
+
if (cached && cached.backing === backing) return cached.bound;
|
|
1808
|
+
const bound = value.bind(target);
|
|
1809
|
+
methods.set(property, { backing, bound });
|
|
1810
|
+
return bound;
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
for (const identity of [this, view]) registerEntryView(identity, async (path, options) => {
|
|
1814
|
+
const resolved = await this.#resolve(path, options);
|
|
1815
|
+
if (resolved === nullPath || resolved === deviceDirectory) return {
|
|
1816
|
+
filesystem: this,
|
|
1817
|
+
path: resolved,
|
|
1818
|
+
stat: resolved === nullPath ? this.#nullStat : this.#directoryStat,
|
|
1819
|
+
readOnly: false
|
|
1820
|
+
};
|
|
1821
|
+
return { filesystem, path };
|
|
1822
|
+
});
|
|
1823
|
+
return view;
|
|
1824
|
+
}
|
|
1825
|
+
#resolve(path, options, followFinal = true) {
|
|
1826
|
+
return resolveDevicePath(this.#filesystem, path, options, followFinal);
|
|
1827
|
+
}
|
|
1828
|
+
async #mutable(path, options, followFinal = true) {
|
|
1829
|
+
if (reserved(await this.#resolve(path, options, followFinal))) throw new FsError("EBUSY", { path });
|
|
1830
|
+
}
|
|
1831
|
+
async #writeTarget(path, options) {
|
|
1832
|
+
const resolved = await this.#resolve(path, options);
|
|
1833
|
+
if (resolved === nullPath) {
|
|
1834
|
+
if (options.flag === "wx" || options.flag === "ax") throw new FsError("EEXIST", { path });
|
|
1835
|
+
if (options.flag !== void 0 && options.flag !== "w" && options.flag !== "a") throw new FsError("EINVAL", { path });
|
|
1836
|
+
return true;
|
|
1837
|
+
}
|
|
1838
|
+
if (resolved === "/" || resolved === deviceDirectory) throw new FsError("EISDIR", { path });
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
canonicalizeMissingTarget(path, options = {}) {
|
|
1842
|
+
options.signal?.throwIfAborted();
|
|
1843
|
+
const resolved = lexicalDevicePath(path);
|
|
1844
|
+
return reserved(resolved) ? resolved : this.#filesystem.canonicalizeMissingTarget?.(path, options);
|
|
1845
|
+
}
|
|
1846
|
+
async capabilitiesFor(path, options = {}) {
|
|
1847
|
+
const resolved = await this.#resolve(path, options);
|
|
1848
|
+
if (resolved === nullPath) return deviceCapabilities;
|
|
1849
|
+
if (resolved === deviceDirectory) return {
|
|
1850
|
+
...deviceCapabilities,
|
|
1851
|
+
readdir: true,
|
|
1852
|
+
write: false,
|
|
1853
|
+
append: false,
|
|
1854
|
+
exclusiveCreate: false,
|
|
1855
|
+
streamingWrite: false,
|
|
1856
|
+
streamingAppend: false,
|
|
1857
|
+
descriptorWriteStream: false,
|
|
1858
|
+
retainedRead: false,
|
|
1859
|
+
streamingRead: false,
|
|
1860
|
+
copy: false,
|
|
1861
|
+
exclusiveCopy: false
|
|
1862
|
+
};
|
|
1863
|
+
const capabilities = await this.#filesystem.capabilitiesFor?.(path, options) ?? this.#filesystem.capabilities;
|
|
1864
|
+
const unavailable = {};
|
|
1865
|
+
if (typeof this.#filesystem.readStream !== "function") unavailable.streamingRead = false;
|
|
1866
|
+
if (typeof this.#filesystem.writeStream !== "function") {
|
|
1867
|
+
unavailable.streamingWrite = false;
|
|
1868
|
+
unavailable.streamingAppend = false;
|
|
1869
|
+
unavailable.descriptorWriteStream = false;
|
|
1870
|
+
}
|
|
1871
|
+
if (typeof this.#filesystem.openReadFile !== "function") unavailable.retainedRead = false;
|
|
1872
|
+
return Object.keys(unavailable).some((key) => capabilities[key] !== false) ? { ...capabilities, ...unavailable } : capabilities;
|
|
1873
|
+
}
|
|
1874
|
+
async stat(path, options = {}) {
|
|
1875
|
+
const resolved = await this.#resolve(path, options);
|
|
1876
|
+
if (resolved === nullPath) return { ...this.#nullStat };
|
|
1877
|
+
if (resolved === deviceDirectory) return { ...this.#directoryStat };
|
|
1878
|
+
return this.#filesystem.stat(path, options);
|
|
1879
|
+
}
|
|
1880
|
+
async lstat(path, options = {}) {
|
|
1881
|
+
const resolved = await this.#resolve(path, options, false);
|
|
1882
|
+
if (resolved === nullPath) return { ...this.#nullStat };
|
|
1883
|
+
if (resolved === deviceDirectory) return { ...this.#directoryStat };
|
|
1884
|
+
return this.#filesystem.lstat(path, options);
|
|
1885
|
+
}
|
|
1886
|
+
compareEntry(path, peer, peerPath, options = {}) {
|
|
1887
|
+
return compareEntries(this, path, peer, peerPath, options);
|
|
1888
|
+
}
|
|
1889
|
+
async realpath(path, options = {}) {
|
|
1890
|
+
const resolved = await this.#resolve(path, options);
|
|
1891
|
+
return reserved(resolved) ? resolved : this.#filesystem.realpath(path, options);
|
|
1892
|
+
}
|
|
1893
|
+
async readFile(path, options = {}) {
|
|
1894
|
+
const resolved = await this.#resolve(path, options);
|
|
1895
|
+
if (resolved === nullPath) {
|
|
1896
|
+
nonnegative(options.maxBytes, path);
|
|
1897
|
+
return new Uint8Array();
|
|
1898
|
+
}
|
|
1899
|
+
if (resolved === deviceDirectory) throw new FsError("EISDIR", { path });
|
|
1900
|
+
return this.#filesystem.readFile(path, options);
|
|
1901
|
+
}
|
|
1902
|
+
readStream(path, options = {}) {
|
|
1903
|
+
return deviceReadStream(async () => {
|
|
1904
|
+
const resolved = await this.#resolve(path, options);
|
|
1905
|
+
if (resolved === nullPath) {
|
|
1906
|
+
nonnegative(options.start, path);
|
|
1907
|
+
nonnegative(options.endExclusive, path);
|
|
1908
|
+
nonnegative(options.chunkSize, path);
|
|
1909
|
+
if (options.chunkSize === 0 || options.endExclusive !== void 0 && options.endExclusive < (options.start ?? 0)) throw new FsError("EINVAL", { path });
|
|
1910
|
+
return { [Symbol.asyncIterator]: () => ({ next: async () => ({ done: true, value: void 0 }) }) };
|
|
1911
|
+
}
|
|
1912
|
+
if (resolved === deviceDirectory) throw new FsError("EISDIR", { path });
|
|
1913
|
+
if (!this.#filesystem.readStream) throw new FsError("ENOTSUP", { path });
|
|
1914
|
+
return this.#filesystem.readStream(path, options);
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
async openReadFile(path, options = {}) {
|
|
1918
|
+
const resolved = await this.#resolve(path, options);
|
|
1919
|
+
if (resolved !== nullPath) {
|
|
1920
|
+
if (resolved === deviceDirectory) throw new FsError("EISDIR", { path });
|
|
1921
|
+
if (!this.#filesystem.openReadFile) throw new FsError("ENOTSUP", { path });
|
|
1922
|
+
return this.#filesystem.openReadFile(path, options);
|
|
1923
|
+
}
|
|
1924
|
+
const stat = this.#nullStat;
|
|
1925
|
+
let closed = false;
|
|
1926
|
+
const check = (settings) => {
|
|
1927
|
+
settings.signal?.throwIfAborted();
|
|
1928
|
+
if (closed) throw new FsError("EBADF", { path });
|
|
1929
|
+
};
|
|
1930
|
+
return {
|
|
1931
|
+
async stat(settings = {}) {
|
|
1932
|
+
check(settings);
|
|
1933
|
+
return { ...stat };
|
|
1934
|
+
},
|
|
1935
|
+
async read(position, maxBytes, settings = {}) {
|
|
1936
|
+
check(settings);
|
|
1937
|
+
nonnegative(position, path);
|
|
1938
|
+
nonnegative(maxBytes, path);
|
|
1939
|
+
return new Uint8Array();
|
|
1940
|
+
},
|
|
1941
|
+
async close() {
|
|
1942
|
+
closed = true;
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
async writeFile(path, data, options = {}) {
|
|
1947
|
+
if (await this.#writeTarget(path, options)) {
|
|
1948
|
+
if (!(data instanceof Uint8Array)) throw new TypeError("File data must be Uint8Array");
|
|
1949
|
+
return;
|
|
1950
|
+
}
|
|
1951
|
+
await this.#filesystem.writeFile(path, data, options);
|
|
1952
|
+
}
|
|
1953
|
+
async appendFile(path, data, options = {}) {
|
|
1954
|
+
if (await this.#writeTarget(path, options)) {
|
|
1955
|
+
if (!(data instanceof Uint8Array)) throw new TypeError("File data must be Uint8Array");
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1958
|
+
await this.#filesystem.appendFile(path, data, options);
|
|
1959
|
+
}
|
|
1960
|
+
async writeStream(path, source, options = {}) {
|
|
1961
|
+
if (await this.#writeTarget(path, options)) return drainDeviceInput(source, options.signal);
|
|
1962
|
+
if (!this.#filesystem.writeStream) throw new FsError("ENOTSUP", { path });
|
|
1963
|
+
await this.#filesystem.writeStream(path, source, options);
|
|
1964
|
+
}
|
|
1965
|
+
async readdir(path, options = {}) {
|
|
1966
|
+
const resolved = await this.#resolve(path, options);
|
|
1967
|
+
if (resolved === nullPath) throw new FsError("ENOTDIR", { path });
|
|
1968
|
+
if (resolved !== "/" && resolved !== deviceDirectory) return this.#filesystem.readdir(path, options);
|
|
1969
|
+
const limit = directoryEntryLimit(options, path);
|
|
1970
|
+
let entries2;
|
|
1971
|
+
try {
|
|
1972
|
+
entries2 = await this.#filesystem.readdir(resolved, options);
|
|
1973
|
+
} catch (error) {
|
|
1974
|
+
options.signal?.throwIfAborted();
|
|
1975
|
+
if (!isFsError(error, "ENOENT") && !isFsError(error, "ENOTDIR")) throw error;
|
|
1976
|
+
entries2 = [];
|
|
1977
|
+
}
|
|
1978
|
+
options.signal?.throwIfAborted();
|
|
1979
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1980
|
+
for (const entry of entries2) {
|
|
1981
|
+
if (entry.name === "." || entry.name === "..") continue;
|
|
1982
|
+
if (!entry.name || entry.name.includes("/") || entry.name.includes("\0")) throw new FsError("EIO", { path, message: "invalid directory entry" });
|
|
1983
|
+
merged.set(entry.name, { name: entry.name, type: entry.type });
|
|
1984
|
+
admitDirectoryEntries(merged.size, limit, path);
|
|
1985
|
+
}
|
|
1986
|
+
const name = resolved === "/" ? "dev" : "null";
|
|
1987
|
+
merged.set(name, { name, type: resolved === "/" ? "directory" : "character" });
|
|
1988
|
+
admitDirectoryEntries(merged.size, limit, path);
|
|
1989
|
+
return [...merged.values()];
|
|
1990
|
+
}
|
|
1991
|
+
async mkdir(path, options = {}) {
|
|
1992
|
+
const resolved = await this.#resolve(path, options);
|
|
1993
|
+
if (reserved(resolved)) {
|
|
1994
|
+
if (resolved !== nullPath && options.recursive) return;
|
|
1995
|
+
throw new FsError("EEXIST", { path });
|
|
1996
|
+
}
|
|
1997
|
+
await this.#filesystem.mkdir(path, options);
|
|
1998
|
+
}
|
|
1999
|
+
async rm(path, options = {}) {
|
|
2000
|
+
await this.#mutable(path, options, false);
|
|
2001
|
+
await this.#filesystem.rm(path, options);
|
|
2002
|
+
}
|
|
2003
|
+
async rmdir(path, options = {}) {
|
|
2004
|
+
const resolved = await this.#resolve(path, options, false);
|
|
2005
|
+
if (resolved === nullPath) throw new FsError("ENOTDIR", { path });
|
|
2006
|
+
if (reserved(resolved)) throw new FsError("EBUSY", { path });
|
|
2007
|
+
if (!this.#filesystem.rmdir) throw new FsError("ENOTSUP", { path });
|
|
2008
|
+
await this.#filesystem.rmdir(path, options);
|
|
2009
|
+
}
|
|
2010
|
+
async rename(source, destination, options = {}) {
|
|
2011
|
+
await this.#mutable(source, options, false);
|
|
2012
|
+
await this.#mutable(destination, options, false);
|
|
2013
|
+
if (options.noReplace) {
|
|
2014
|
+
const capabilities = await this.#filesystem.capabilitiesFor?.(destination, options) ?? this.#filesystem.capabilities;
|
|
2015
|
+
options.signal?.throwIfAborted();
|
|
2016
|
+
if (capabilities.atomicRenameNoReplace !== true) throw new FsError("ENOTSUP", { syscall: "rename", path: source, dest: destination });
|
|
2017
|
+
}
|
|
2018
|
+
await this.#filesystem.rename(source, destination, options);
|
|
2019
|
+
}
|
|
2020
|
+
async copyFile(source, destination, options = {}) {
|
|
2021
|
+
const target = await this.#resolve(destination, options);
|
|
2022
|
+
if (target === nullPath && options.exclusive) throw new FsError("EEXIST", { path: destination });
|
|
2023
|
+
const origin = await this.#resolve(source, options);
|
|
2024
|
+
if (target !== nullPath && origin !== nullPath) {
|
|
2025
|
+
if (target === "/" || target === deviceDirectory) throw new FsError("EISDIR", { path: destination });
|
|
2026
|
+
await this.#filesystem.copyFile(source, destination, options);
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
if (target === nullPath) {
|
|
2030
|
+
if (origin === nullPath) return;
|
|
2031
|
+
if (origin === "/" || origin === deviceDirectory) throw new FsError("EISDIR", { path: source });
|
|
2032
|
+
const capabilities = await this.capabilitiesFor(source, options);
|
|
2033
|
+
if (this.#filesystem.readStream && capabilities.streamingRead !== false) {
|
|
2034
|
+
await drainDeviceInput(this.#filesystem.readStream(source, options), options.signal);
|
|
2035
|
+
} else if (this.#filesystem.openReadFile && capabilities.retainedRead !== false) {
|
|
2036
|
+
await drainDeviceFile(await this.#filesystem.openReadFile(source, options), options.signal);
|
|
2037
|
+
} else throw new FsError("ENOTSUP", { path: source });
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
if (reserved(target)) throw new FsError("EISDIR", { path: destination });
|
|
2041
|
+
await this.#filesystem.writeFile(destination, new Uint8Array(), { ...options, flag: options.exclusive ? "wx" : "w" });
|
|
2042
|
+
}
|
|
2043
|
+
async access(path, mode2 = 0, options = {}) {
|
|
2044
|
+
const resolved = await this.#resolve(path, options);
|
|
2045
|
+
if (resolved === nullPath || resolved === deviceDirectory) {
|
|
2046
|
+
if (!Number.isInteger(mode2) || mode2 < 0 || mode2 > 7) throw new FsError("EINVAL", { path });
|
|
2047
|
+
if (resolved === nullPath && mode2 & 1 || resolved === deviceDirectory && mode2 & 2) throw new FsError("EACCES", { path });
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
await this.#filesystem.access(path, mode2, options);
|
|
2051
|
+
}
|
|
2052
|
+
async readlink(path, options = {}) {
|
|
2053
|
+
if (reserved(await this.#resolve(path, options, false))) throw new FsError("EINVAL", { path });
|
|
2054
|
+
if (!this.#filesystem.readlink) throw new FsError("ENOTSUP", { path });
|
|
2055
|
+
return this.#filesystem.readlink(path, options);
|
|
2056
|
+
}
|
|
2057
|
+
async symlink(target, path, options = {}) {
|
|
2058
|
+
await this.#mutable(path, options, false);
|
|
2059
|
+
if (!this.#filesystem.symlink) throw new FsError("ENOTSUP", { path });
|
|
2060
|
+
await this.#filesystem.symlink(target, path, options);
|
|
2061
|
+
}
|
|
2062
|
+
async link(existingPath, newPath, options = {}) {
|
|
2063
|
+
await this.#mutable(existingPath, options, false);
|
|
2064
|
+
await this.#mutable(newPath, options, false);
|
|
2065
|
+
if (!this.#filesystem.link) throw new FsError("ENOTSUP", { path: newPath });
|
|
2066
|
+
await this.#filesystem.link(existingPath, newPath, options);
|
|
2067
|
+
}
|
|
2068
|
+
async chmod(path, mode2, options = {}) {
|
|
2069
|
+
await this.#mutable(path, options);
|
|
2070
|
+
if (!this.#filesystem.chmod) throw new FsError("ENOTSUP", { path });
|
|
2071
|
+
await this.#filesystem.chmod(path, mode2, options);
|
|
2072
|
+
}
|
|
2073
|
+
async utimes(path, atimeMs, mtimeMs, options = {}) {
|
|
2074
|
+
await this.#mutable(path, options);
|
|
2075
|
+
if (!this.#filesystem.utimes) throw new FsError("ENOTSUP", { path });
|
|
2076
|
+
await this.#filesystem.utimes(path, atimeMs, mtimeMs, options);
|
|
2077
|
+
}
|
|
2078
|
+
async truncate(path, length, options = {}) {
|
|
2079
|
+
await this.#mutable(path, options);
|
|
2080
|
+
if (!this.#filesystem.truncate) throw new FsError("ENOTSUP", { path });
|
|
2081
|
+
await this.#filesystem.truncate(path, length, options);
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
function createDeviceFileSystem(filesystem) {
|
|
2085
|
+
if (filesystem instanceof DeviceFileSystem) return filesystem;
|
|
2086
|
+
let view = views.get(filesystem);
|
|
2087
|
+
if (!view) {
|
|
2088
|
+
view = new DeviceFileSystem(filesystem);
|
|
2089
|
+
views.set(filesystem, view);
|
|
2090
|
+
}
|
|
2091
|
+
return view;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
1524
2094
|
// packages/safe-fs/src/contracts/abort.ts
|
|
1525
2095
|
function composeAbortSignals(signals) {
|
|
1526
2096
|
const controller = new AbortController();
|
|
@@ -1890,6 +2460,7 @@ var WebDavFileSystem = class {
|
|
|
1890
2460
|
remove: true,
|
|
1891
2461
|
recursiveRemove: true,
|
|
1892
2462
|
rename: true,
|
|
2463
|
+
atomicRenameNoReplace: false,
|
|
1893
2464
|
copy: true,
|
|
1894
2465
|
exclusiveCopy: true,
|
|
1895
2466
|
readlink: false,
|
|
@@ -2828,6 +3399,10 @@ var WebDavFileSystem = class {
|
|
|
2828
3399
|
}
|
|
2829
3400
|
}
|
|
2830
3401
|
async rename(source, destination, options = {}) {
|
|
3402
|
+
if (options.noReplace) {
|
|
3403
|
+
options.signal?.throwIfAborted();
|
|
3404
|
+
fail("ENOTSUP", "rename", source, "atomic no-replace rename is unsupported");
|
|
3405
|
+
}
|
|
2831
3406
|
await this.transfer("MOVE", source, destination, options);
|
|
2832
3407
|
}
|
|
2833
3408
|
async copyFile(source, destination, options = {}) {
|
|
@@ -2964,6 +3539,7 @@ function readOnlyCapabilities(capabilities) {
|
|
|
2964
3539
|
timestamps: false,
|
|
2965
3540
|
descriptorWriteStream: false,
|
|
2966
3541
|
atomicRename: false,
|
|
3542
|
+
atomicRenameNoReplace: false,
|
|
2967
3543
|
streamingWrite: false
|
|
2968
3544
|
});
|
|
2969
3545
|
}
|
|
@@ -3219,7 +3795,7 @@ var MountFileSystem = class _MountFileSystem {
|
|
|
3219
3795
|
if (capability === "descriptorWriteStream" && backend.capabilities.streamingWrite === false) return false;
|
|
3220
3796
|
return declared === true && optional[capability]?.some((method) => typeof backend[method] !== "function") ? false : declared;
|
|
3221
3797
|
});
|
|
3222
|
-
if (["rename", "copy", "exclusiveCopy"].includes(capability) && mounts.length > 1) return void 0;
|
|
3798
|
+
if (["rename", "atomicRenameNoReplace", "copy", "exclusiveCopy"].includes(capability) && mounts.length > 1) return void 0;
|
|
3223
3799
|
return values.every((value) => value === true) ? true : values.every((value) => value === false) ? false : void 0;
|
|
3224
3800
|
};
|
|
3225
3801
|
const semantics = Object.fromEntries([
|
|
@@ -3239,6 +3815,7 @@ var MountFileSystem = class _MountFileSystem {
|
|
|
3239
3815
|
"removeDirectory",
|
|
3240
3816
|
"recursiveRemove",
|
|
3241
3817
|
"rename",
|
|
3818
|
+
"atomicRenameNoReplace",
|
|
3242
3819
|
"copy",
|
|
3243
3820
|
"exclusiveCopy",
|
|
3244
3821
|
"readlink",
|
|
@@ -3552,6 +4129,11 @@ var MountFileSystem = class _MountFileSystem {
|
|
|
3552
4129
|
this.mutable(target);
|
|
3553
4130
|
this.entryPath(source);
|
|
3554
4131
|
this.entryPath(destination);
|
|
4132
|
+
if (options.noReplace) {
|
|
4133
|
+
const capabilities = await target.mount.backend.capabilitiesFor?.(target.local, options) ?? target.mount.backend.capabilities;
|
|
4134
|
+
options.signal?.throwIfAborted();
|
|
4135
|
+
if (capabilities.atomicRenameNoReplace !== true) fail2("ENOTSUP");
|
|
4136
|
+
}
|
|
3555
4137
|
await origin.mount.backend.rename(origin.local, target.local, options);
|
|
3556
4138
|
}, destination);
|
|
3557
4139
|
}
|
|
@@ -3815,6 +4397,7 @@ var OverlayFileSystem = class {
|
|
|
3815
4397
|
...upper.readOnly === void 0 ? {} : { readOnly: upper.readOnly },
|
|
3816
4398
|
...effectiveAppend === void 0 ? {} : { append: effectiveAppend },
|
|
3817
4399
|
atomicRename: false,
|
|
4400
|
+
atomicRenameNoReplace: false,
|
|
3818
4401
|
descriptorWriteStream: false,
|
|
3819
4402
|
hardlinks: false,
|
|
3820
4403
|
symlinks: writable && this.#upper.capabilities.symlinks === true && typeof this.#upper.symlink === "function" && typeof this.#upper.readlink === "function" && (this.#lower.capabilities.symlinks !== true || typeof this.#lower.readlink === "function"),
|
|
@@ -4321,6 +4904,7 @@ var OverlayFileSystem = class {
|
|
|
4321
4904
|
}
|
|
4322
4905
|
async rename(source, destination, options = {}) {
|
|
4323
4906
|
return this.run(options, async () => {
|
|
4907
|
+
if (options.noReplace) fail3("ENOTSUP", source, "atomic no-replace rename is unsupported");
|
|
4324
4908
|
this.writable(source);
|
|
4325
4909
|
const original = await this.required(source, options, false);
|
|
4326
4910
|
const target = await this.resolve(destination, options, false, true);
|
|
@@ -4648,6 +5232,15 @@ function withFileSystemQuota(fs, options) {
|
|
|
4648
5232
|
await fs.appendFile(path, data, appendOptions);
|
|
4649
5233
|
});
|
|
4650
5234
|
},
|
|
5235
|
+
async rename(source, destination, renameOptions) {
|
|
5236
|
+
if (renameOptions?.noReplace) {
|
|
5237
|
+
renameOptions.signal?.throwIfAborted();
|
|
5238
|
+
const capabilities = await fs.capabilitiesFor?.(destination, renameOptions) ?? fs.capabilities;
|
|
5239
|
+
renameOptions?.signal?.throwIfAborted();
|
|
5240
|
+
if (capabilities.atomicRenameNoReplace !== true) throw new FsError("ENOTSUP", { syscall: "rename", path: source, dest: destination });
|
|
5241
|
+
}
|
|
5242
|
+
await fs.rename(source, destination, renameOptions);
|
|
5243
|
+
},
|
|
4651
5244
|
copyFile(source, destination, copyOptions) {
|
|
4652
5245
|
return mutate(async () => {
|
|
4653
5246
|
await assertDelta(destination, (await fs.stat(source, copyOptions)).size, copyOptions);
|
|
@@ -4803,6 +5396,17 @@ function scopeFileSystem(filesystem, charge, signal) {
|
|
|
4803
5396
|
const peer = args[1];
|
|
4804
5397
|
args[1] = originals.get(peer) ?? peer;
|
|
4805
5398
|
}
|
|
5399
|
+
if (property === "rename" && args[2]?.noReplace) return (async () => {
|
|
5400
|
+
const options = args[2];
|
|
5401
|
+
const capabilities = await original.capabilitiesFor?.(args[1], options) ?? original.capabilities;
|
|
5402
|
+
assertOpen(options);
|
|
5403
|
+
if (capabilities.atomicRenameNoReplace !== true) throw new FsError("ENOTSUP", {
|
|
5404
|
+
syscall: "rename",
|
|
5405
|
+
path: args[0],
|
|
5406
|
+
dest: args[1]
|
|
5407
|
+
});
|
|
5408
|
+
return Reflect.apply(method, original, args);
|
|
5409
|
+
})();
|
|
4806
5410
|
return Reflect.apply(method, original, args);
|
|
4807
5411
|
};
|
|
4808
5412
|
const scoped = property === "openReadFile" ? async (...args) => wrapHandle(await dispatch(...args)) : property === "readStream" ? (...args) => wrapStream(dispatch(...args), args[1]) : operations.has(property) && property !== "canonicalizeMissingTarget" ? async (...args) => dispatch(...args) : dispatch;
|
|
@@ -4825,7 +5429,7 @@ function predicates(type) {
|
|
|
4825
5429
|
isDirectory: () => type === "directory",
|
|
4826
5430
|
isSymbolicLink: () => type === "symlink",
|
|
4827
5431
|
isBlockDevice: () => false,
|
|
4828
|
-
isCharacterDevice: () =>
|
|
5432
|
+
isCharacterDevice: () => type === "character",
|
|
4829
5433
|
isFIFO: () => false,
|
|
4830
5434
|
isSocket: () => false
|
|
4831
5435
|
};
|
|
@@ -4834,7 +5438,7 @@ function bridgeStats(stat) {
|
|
|
4834
5438
|
return {
|
|
4835
5439
|
dev: stat.dev ?? 0,
|
|
4836
5440
|
ino: stat.ino ?? 0,
|
|
4837
|
-
mode: stat.mode & 4095 | (stat.type === "directory" ? 16384 : stat.type === "symlink" ? 40960 : 32768),
|
|
5441
|
+
mode: stat.mode & 4095 | (stat.type === "directory" ? 16384 : stat.type === "symlink" ? 40960 : stat.type === "character" ? 8192 : 32768),
|
|
4838
5442
|
nlink: stat.nlink ?? 1,
|
|
4839
5443
|
uid: stat.uid ?? 0,
|
|
4840
5444
|
gid: stat.gid ?? 0,
|
|
@@ -5439,6 +6043,8 @@ export {
|
|
|
5439
6043
|
normalizeMemoryFileSystemLimits,
|
|
5440
6044
|
MemoryFileSystem,
|
|
5441
6045
|
createMemoryFileSystem,
|
|
6046
|
+
DeviceFileSystem,
|
|
6047
|
+
createDeviceFileSystem,
|
|
5442
6048
|
composeAbortSignals,
|
|
5443
6049
|
WebDavFileSystem,
|
|
5444
6050
|
ReadOnlyFileSystem,
|
|
@@ -5452,4 +6058,4 @@ export {
|
|
|
5452
6058
|
scopeFileSystem,
|
|
5453
6059
|
FileSystemBridge
|
|
5454
6060
|
};
|
|
5455
|
-
//# sourceMappingURL=chunk-
|
|
6061
|
+
//# sourceMappingURL=chunk-6V4U2JZS.js.map
|