@poe-platform/safe-bash 0.1.539 → 0.1.540
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/safe-bash/chunks/bz2-B2RXT4EX.js +4836 -0
- package/dist/safe-bash/chunks/bz2-B2RXT4EX.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-4NMFAR4Z.js → chunk-2KL6W6NB.js} +3 -629
- package/dist/safe-bash/chunks/{chunk-4NMFAR4Z.js.map → chunk-2KL6W6NB.js.map} +4 -4
- package/dist/safe-bash/chunks/{chunk-RDIJ6M2D.js → chunk-32GGX4AS.js} +6 -4
- package/dist/safe-bash/chunks/{chunk-RDIJ6M2D.js.map → chunk-32GGX4AS.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-LUIEXTN5.js → chunk-DJHZJAB7.js} +6 -4
- package/dist/safe-bash/chunks/{chunk-LUIEXTN5.js.map → chunk-DJHZJAB7.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-CI42NIWL.js → chunk-DPJWEGIX.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-UL4TNDNV.js → chunk-EYJTLUBJ.js} +5 -3
- package/dist/safe-bash/chunks/{chunk-UL4TNDNV.js.map → chunk-EYJTLUBJ.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-GZKLXMBM.js +636 -0
- package/dist/safe-bash/chunks/chunk-GZKLXMBM.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-RVGX5DQT.js → chunk-IIWXPQB3.js} +15 -11
- package/dist/safe-bash/chunks/chunk-IIWXPQB3.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-R5ZK7V4W.js → chunk-J4CKSMJV.js} +7 -5
- package/dist/safe-bash/chunks/{chunk-R5ZK7V4W.js.map → chunk-J4CKSMJV.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-GV76QENF.js → chunk-LRVRQIG5.js} +6 -4
- package/dist/safe-bash/chunks/{chunk-GV76QENF.js.map → chunk-LRVRQIG5.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-ELK3CQTQ.js → chunk-LZUOZVGJ.js} +7 -5
- package/dist/safe-bash/chunks/{chunk-ELK3CQTQ.js.map → chunk-LZUOZVGJ.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-5X2TAR25.js → chunk-PPPN3OME.js} +6 -4
- package/dist/safe-bash/chunks/{chunk-5X2TAR25.js.map → chunk-PPPN3OME.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-QWCD4HKE.js → chunk-QKQNBJOU.js} +9 -7
- package/dist/safe-bash/chunks/{chunk-QWCD4HKE.js.map → chunk-QKQNBJOU.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-GZH6ILJC.js → chunk-UGMO7OO5.js} +7 -5
- package/dist/safe-bash/chunks/{chunk-GZH6ILJC.js.map → chunk-UGMO7OO5.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-67TENRTW.js → chunk-Z75O7XWR.js} +7 -5
- package/dist/safe-bash/chunks/{chunk-67TENRTW.js.map → chunk-Z75O7XWR.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-F4UILGOA.js → chunk-ZQEL7DYC.js} +8 -6
- package/dist/safe-bash/chunks/{chunk-F4UILGOA.js.map → chunk-ZQEL7DYC.js.map} +1 -1
- package/dist/safe-bash/chunks/xz-AVXFDXW4.js +6042 -0
- package/dist/safe-bash/chunks/xz-AVXFDXW4.js.map +7 -0
- package/dist/safe-bash/chunks/zstd-R6RPHJYO.js +27110 -0
- package/dist/safe-bash/chunks/zstd-R6RPHJYO.js.map +7 -0
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts +20 -0
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts.map +1 -0
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.js +111 -0
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.js.map +1 -0
- package/dist/safe-bash/commands/bytes/compression/codec-loader.d.ts +5 -0
- package/dist/safe-bash/commands/bytes/compression/codec-loader.d.ts.map +1 -0
- package/dist/safe-bash/commands/bytes/compression/codec-loader.js +89 -0
- package/dist/safe-bash/commands/bytes/compression/codec-loader.js.map +1 -0
- package/dist/safe-bash/commands/bytes/compression/files.d.ts +1 -1
- package/dist/safe-bash/commands/bytes/compression/files.d.ts.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/files.js +15 -0
- package/dist/safe-bash/commands/bytes/compression/files.js.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/index.js +3 -3
- package/dist/safe-bash/commands/bytes/compression/index.js.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/native/LICENSES.txt +777 -0
- package/dist/safe-bash/commands/bytes/compression/native/generated/bz2.d.mts +3 -0
- package/dist/safe-bash/commands/bytes/compression/native/generated/bz2.mjs +2 -0
- package/dist/safe-bash/commands/bytes/compression/native/generated/xz.d.mts +3 -0
- package/dist/safe-bash/commands/bytes/compression/native/generated/xz.mjs +2 -0
- package/dist/safe-bash/commands/bytes/compression/native/generated/zstd.d.mts +3 -0
- package/dist/safe-bash/commands/bytes/compression/native/generated/zstd.mjs +2 -0
- package/dist/safe-bash/commands/bytes/compression/native/sources.json +246 -0
- package/dist/safe-bash/commands/bytes/compression/native/types.d.ts +17 -0
- package/dist/safe-bash/commands/bytes/compression/native/types.d.ts.map +1 -0
- package/dist/safe-bash/commands/bytes/compression/native/types.js +2 -0
- package/dist/safe-bash/commands/bytes/compression/native/types.js.map +1 -0
- package/dist/safe-bash/commands/bytes/compression/options.d.ts +27 -0
- package/dist/safe-bash/commands/bytes/compression/options.d.ts.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/options.js +16 -3
- package/dist/safe-bash/commands/bytes/compression/options.js.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/stream.d.ts.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/stream.js +7 -4
- package/dist/safe-bash/commands/bytes/compression/stream.js.map +1 -1
- package/dist/safe-bash/commands/csplit/index.browser.js +6 -5
- package/dist/safe-bash/commands/factor/index.browser.js +4 -3
- package/dist/safe-bash/commands/getopt/index.browser.js +4 -3
- package/dist/safe-bash/commands/network/curl.js +1 -1
- package/dist/safe-bash/commands/network/curl.js.map +1 -1
- package/dist/safe-bash/commands/network/index.browser.js +7 -6
- package/dist/safe-bash/commands/network/output.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/output.js +2 -2
- package/dist/safe-bash/commands/network/output.js.map +1 -1
- package/dist/safe-bash/commands/network/types.d.ts +4 -0
- package/dist/safe-bash/commands/network/types.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/types.js.map +1 -1
- package/dist/safe-bash/commands/pr/index.browser.js +5 -4
- package/dist/safe-bash/commands/truncate.d.ts.map +1 -1
- package/dist/safe-bash/commands/truncate.js +14 -1
- package/dist/safe-bash/commands/truncate.js.map +1 -1
- package/dist/safe-bash/commands/tsort/index.browser.js +5 -4
- package/dist/safe-bash/commands/xml/index.browser.js +6 -5
- package/dist/safe-bash/commands/yq/index.browser.js +7 -6
- package/dist/safe-bash/contracts/filesystem.d.ts +1 -1
- package/dist/safe-bash/contracts/filesystem.d.ts.map +1 -1
- package/dist/safe-bash/core.browser.js +323 -97
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/package.json +2 -2
- package/dist/safe-bash/chunks/chunk-RVGX5DQT.js.map +0 -7
- /package/dist/safe-bash/chunks/{chunk-CI42NIWL.js.map → chunk-DPJWEGIX.js.map} +0 -0
|
@@ -1826,638 +1826,12 @@ var init_platform = __esm({
|
|
|
1826
1826
|
}
|
|
1827
1827
|
});
|
|
1828
1828
|
|
|
1829
|
-
// packages/safe-bash/src/contracts/value.ts
|
|
1830
|
-
init_platform();
|
|
1831
|
-
var byteValues = /* @__PURE__ */ new WeakMap();
|
|
1832
|
-
var encoder = new TextEncoder();
|
|
1833
|
-
var decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
1834
|
-
var typedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
|
|
1835
|
-
var viewBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
|
|
1836
|
-
var viewOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset").get;
|
|
1837
|
-
var viewLength = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength").get;
|
|
1838
|
-
function record(value) {
|
|
1839
|
-
const result = byteValues.get(value);
|
|
1840
|
-
if (!result) throw new TypeError("Expected an owned shell byte value");
|
|
1841
|
-
return result;
|
|
1842
|
-
}
|
|
1843
|
-
function allocationSize(length, multiplier) {
|
|
1844
|
-
const result = length * multiplier + 64;
|
|
1845
|
-
if (!Number.isSafeInteger(result)) throw new RangeError("Shell value allocation is too large");
|
|
1846
|
-
return result;
|
|
1847
|
-
}
|
|
1848
|
-
function allocate(bytes, allocation, create, slots = 1) {
|
|
1849
|
-
allocation?.assertOpen();
|
|
1850
|
-
const reservation = allocation?.reserve(bytes, slots);
|
|
1851
|
-
try {
|
|
1852
|
-
const result = create();
|
|
1853
|
-
reservation?.commit(result);
|
|
1854
|
-
return result;
|
|
1855
|
-
} catch (error) {
|
|
1856
|
-
try {
|
|
1857
|
-
reservation?.release();
|
|
1858
|
-
} catch (cleanup) {
|
|
1859
|
-
throw new AggregateError([error, cleanup], "Shell value allocation and release failed");
|
|
1860
|
-
}
|
|
1861
|
-
throw error;
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
function ownedBytes(bytes) {
|
|
1865
|
-
const value = Object.freeze({});
|
|
1866
|
-
byteValues.set(value, { bytes, text: decoder.decode(bytes) });
|
|
1867
|
-
return value;
|
|
1868
|
-
}
|
|
1869
|
-
function shellValueFromBytes(bytes, allocation) {
|
|
1870
|
-
if (!(bytes instanceof Uint8Array)) throw new TypeError("Shell bytes must be Uint8Array");
|
|
1871
|
-
const buffer = viewBuffer.call(bytes);
|
|
1872
|
-
const offset = viewOffset.call(bytes);
|
|
1873
|
-
const length = viewLength.call(bytes);
|
|
1874
|
-
return allocate(allocationSize(length, 3), allocation, () => {
|
|
1875
|
-
if (viewOffset.call(bytes) !== offset || viewLength.call(bytes) < length) throw new TypeError("Shell byte input extent changed during admission");
|
|
1876
|
-
return ownedBytes(new Uint8Array(new Uint8Array(buffer, offset, length)));
|
|
1877
|
-
});
|
|
1878
|
-
}
|
|
1879
|
-
function shellValueText(value) {
|
|
1880
|
-
return typeof value === "string" ? value : record(value).text;
|
|
1881
|
-
}
|
|
1882
|
-
function shellValueByteLength(value) {
|
|
1883
|
-
return typeof value === "string" ? import_buffer.Buffer.byteLength(value) : record(value).bytes.byteLength;
|
|
1884
|
-
}
|
|
1885
|
-
function shellValueRetainedBytes(value) {
|
|
1886
|
-
const stored = record(value);
|
|
1887
|
-
return stored.bytes.byteLength + stored.text.length * 2 + 64;
|
|
1888
|
-
}
|
|
1889
|
-
function shellValueBytes(value, allocation) {
|
|
1890
|
-
const length = shellValueByteLength(value);
|
|
1891
|
-
return allocate(allocationSize(length, 1), allocation, () => typeof value === "string" ? encoder.encode(value) : new Uint8Array(record(value).bytes));
|
|
1892
|
-
}
|
|
1893
|
-
function concatShellValues(values, allocation) {
|
|
1894
|
-
allocation?.assertOpen();
|
|
1895
|
-
if (!Array.isArray(values)) throw new TypeError("Shell value concatenation requires an array");
|
|
1896
|
-
const count = values.length;
|
|
1897
|
-
if (!Number.isSafeInteger(count) || count < 0 || count > 4294967295) throw new RangeError("Invalid shell value input extent");
|
|
1898
|
-
if (!count) return "";
|
|
1899
|
-
if (count === 1) {
|
|
1900
|
-
const value = values[0];
|
|
1901
|
-
if (typeof value !== "string") record(value);
|
|
1902
|
-
if (values.length !== count) throw new TypeError("Shell value input extent changed");
|
|
1903
|
-
return value;
|
|
1904
|
-
}
|
|
1905
|
-
let textOnly = true;
|
|
1906
|
-
for (let index = 0; index < count; index++) {
|
|
1907
|
-
if (typeof values[index] !== "string") {
|
|
1908
|
-
textOnly = false;
|
|
1909
|
-
break;
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
if (textOnly) {
|
|
1913
|
-
let text = "";
|
|
1914
|
-
for (let index = 0; index < count; index++) {
|
|
1915
|
-
const value = values[index];
|
|
1916
|
-
if (typeof value !== "string") throw new TypeError("Shell value input type changed during text concatenation");
|
|
1917
|
-
text += value;
|
|
1918
|
-
}
|
|
1919
|
-
if (values.length !== count) throw new TypeError("Shell value input extent changed");
|
|
1920
|
-
return text;
|
|
1921
|
-
}
|
|
1922
|
-
let reservation = allocation?.reserve(allocationSize(count, 16), count + 1);
|
|
1923
|
-
const release = () => {
|
|
1924
|
-
const pending = reservation;
|
|
1925
|
-
reservation = void 0;
|
|
1926
|
-
pending?.release();
|
|
1927
|
-
};
|
|
1928
|
-
try {
|
|
1929
|
-
if (values.length !== count) throw new TypeError("Shell value input extent changed during metadata admission");
|
|
1930
|
-
const snapshot = new Array(count);
|
|
1931
|
-
for (let index = 0; index < count; index++) {
|
|
1932
|
-
const value = values[index];
|
|
1933
|
-
if (typeof value !== "string") record(value);
|
|
1934
|
-
snapshot[index] = value;
|
|
1935
|
-
}
|
|
1936
|
-
if (values.length !== count) throw new TypeError("Shell value input extent changed during snapshot capture");
|
|
1937
|
-
Object.freeze(snapshot);
|
|
1938
|
-
reservation?.commit(snapshot);
|
|
1939
|
-
if (snapshot.every((value) => typeof value === "string")) {
|
|
1940
|
-
const result = snapshot.join("");
|
|
1941
|
-
release();
|
|
1942
|
-
return result;
|
|
1943
|
-
}
|
|
1944
|
-
const length = encodeValues(snapshot);
|
|
1945
|
-
return allocate(allocationSize(length, 3), allocation, () => {
|
|
1946
|
-
const bytes = new Uint8Array(length);
|
|
1947
|
-
encodeValues(snapshot, bytes);
|
|
1948
|
-
const result = ownedBytes(bytes);
|
|
1949
|
-
release();
|
|
1950
|
-
return result;
|
|
1951
|
-
});
|
|
1952
|
-
} catch (error) {
|
|
1953
|
-
try {
|
|
1954
|
-
release();
|
|
1955
|
-
} catch (cleanup) {
|
|
1956
|
-
throw new AggregateError([error, cleanup], "Shell value snapshot and release failed");
|
|
1957
|
-
}
|
|
1958
|
-
throw error;
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
function encodeValues(values, output) {
|
|
1962
|
-
let offset = 0;
|
|
1963
|
-
let high = 0;
|
|
1964
|
-
const write = (byte) => {
|
|
1965
|
-
if (output) output[offset] = byte;
|
|
1966
|
-
offset++;
|
|
1967
|
-
};
|
|
1968
|
-
const point = (code) => {
|
|
1969
|
-
if (code < 128) write(code);
|
|
1970
|
-
else if (code < 2048) {
|
|
1971
|
-
write(192 | code >> 6);
|
|
1972
|
-
write(128 | code & 63);
|
|
1973
|
-
} else if (code < 65536) {
|
|
1974
|
-
write(224 | code >> 12);
|
|
1975
|
-
write(128 | code >> 6 & 63);
|
|
1976
|
-
write(128 | code & 63);
|
|
1977
|
-
} else {
|
|
1978
|
-
write(240 | code >> 18);
|
|
1979
|
-
write(128 | code >> 12 & 63);
|
|
1980
|
-
write(128 | code >> 6 & 63);
|
|
1981
|
-
write(128 | code & 63);
|
|
1982
|
-
}
|
|
1983
|
-
};
|
|
1984
|
-
for (const value of values) {
|
|
1985
|
-
if (typeof value !== "string") {
|
|
1986
|
-
if (high) {
|
|
1987
|
-
point(65533);
|
|
1988
|
-
high = 0;
|
|
1989
|
-
}
|
|
1990
|
-
const bytes = record(value).bytes;
|
|
1991
|
-
output?.set(bytes, offset);
|
|
1992
|
-
offset += bytes.byteLength;
|
|
1993
|
-
continue;
|
|
1994
|
-
}
|
|
1995
|
-
for (let index = 0; index < value.length; index++) {
|
|
1996
|
-
const code = value.charCodeAt(index);
|
|
1997
|
-
if (high) {
|
|
1998
|
-
const previous = high;
|
|
1999
|
-
high = 0;
|
|
2000
|
-
if (code >= 56320 && code <= 57343) {
|
|
2001
|
-
point(65536 + (previous - 55296 << 10) + code - 56320);
|
|
2002
|
-
continue;
|
|
2003
|
-
}
|
|
2004
|
-
point(65533);
|
|
2005
|
-
}
|
|
2006
|
-
if (code >= 55296 && code <= 56319) high = code;
|
|
2007
|
-
else point(code >= 56320 && code <= 57343 ? 65533 : code);
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
if (high) point(65533);
|
|
2011
|
-
if (!Number.isSafeInteger(offset)) throw new RangeError("Shell value allocation is too large");
|
|
2012
|
-
return offset;
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
// packages/safe-bash/src/contracts/command.ts
|
|
2016
|
-
init_platform();
|
|
2017
|
-
var argumentCarriers = /* @__PURE__ */ new WeakSet();
|
|
2018
|
-
var CommandArgumentIdentityError = class extends TypeError {
|
|
2019
|
-
constructor() {
|
|
2020
|
-
super("Command argument identity does not match its carrier");
|
|
2021
|
-
}
|
|
2022
|
-
};
|
|
2023
|
-
function argumentAllocation(allocation) {
|
|
2024
|
-
const reservations = [];
|
|
2025
|
-
const tracked = allocation && {
|
|
2026
|
-
assertOpen() {
|
|
2027
|
-
allocation.assertOpen();
|
|
2028
|
-
},
|
|
2029
|
-
reserve(bytes, slots) {
|
|
2030
|
-
const reservation = allocation.reserve(bytes, slots);
|
|
2031
|
-
let released = false;
|
|
2032
|
-
const owned = {
|
|
2033
|
-
commit(value) {
|
|
2034
|
-
reservation.commit(value);
|
|
2035
|
-
},
|
|
2036
|
-
release() {
|
|
2037
|
-
if (released) return;
|
|
2038
|
-
released = true;
|
|
2039
|
-
reservation.release();
|
|
2040
|
-
}
|
|
2041
|
-
};
|
|
2042
|
-
reservations.push(owned);
|
|
2043
|
-
return owned;
|
|
2044
|
-
}
|
|
2045
|
-
};
|
|
2046
|
-
return {
|
|
2047
|
-
allocation: tracked,
|
|
2048
|
-
rollback(error) {
|
|
2049
|
-
const failures = [error];
|
|
2050
|
-
for (let index = reservations.length - 1; index >= 0; index--) {
|
|
2051
|
-
try {
|
|
2052
|
-
reservations[index].release();
|
|
2053
|
-
} catch (cleanup) {
|
|
2054
|
-
failures.push(cleanup);
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
if (failures.length > 1) throw new AggregateError(failures, "Command argument allocation and release failed");
|
|
2058
|
-
throw error;
|
|
2059
|
-
}
|
|
2060
|
-
};
|
|
2061
|
-
}
|
|
2062
|
-
function ownedCommandArguments(size, valueAt, allocation, extent) {
|
|
2063
|
-
allocation?.assertOpen();
|
|
2064
|
-
const length = typeof size === "number" ? size : size();
|
|
2065
|
-
const bytes = 128 + length * 40;
|
|
2066
|
-
const slots = length * 4 + 1;
|
|
2067
|
-
if (!Number.isSafeInteger(length) || length < 0 || !Number.isSafeInteger(bytes) || !Number.isSafeInteger(slots)) {
|
|
2068
|
-
throw new RangeError("Command argument allocation is too large");
|
|
2069
|
-
}
|
|
2070
|
-
const transaction = argumentAllocation(allocation);
|
|
2071
|
-
const reservation = transaction.allocation?.reserve(bytes, slots);
|
|
2072
|
-
try {
|
|
2073
|
-
if (extent && extent() !== length) throw new TypeError("Command argument extent changed during admission");
|
|
2074
|
-
const snapshot = [];
|
|
2075
|
-
for (let index = 0; index < length; index++) snapshot.push(valueAt(index));
|
|
2076
|
-
if (extent && extent() !== length) throw new TypeError("Command argument extent changed during admission");
|
|
2077
|
-
const values = [];
|
|
2078
|
-
const args = [];
|
|
2079
|
-
for (const incoming of snapshot) {
|
|
2080
|
-
const value = incoming instanceof Uint8Array ? shellValueFromBytes(incoming, transaction.allocation) : incoming;
|
|
2081
|
-
args.push(shellValueText(value));
|
|
2082
|
-
values.push(value);
|
|
2083
|
-
}
|
|
2084
|
-
Object.freeze(values);
|
|
2085
|
-
Object.freeze(args);
|
|
2086
|
-
const carrier = Object.freeze({
|
|
2087
|
-
args,
|
|
2088
|
-
values,
|
|
2089
|
-
bytes(index) {
|
|
2090
|
-
return Number.isInteger(index) && index >= 0 && index < length ? shellValueBytes(values[index], allocation) : void 0;
|
|
2091
|
-
},
|
|
2092
|
-
slice(start = 0, end = length) {
|
|
2093
|
-
const offset = (index) => {
|
|
2094
|
-
const integral = Math.trunc(index) || 0;
|
|
2095
|
-
return integral < 0 ? Math.max(0, length + integral) : Math.min(length, integral);
|
|
2096
|
-
};
|
|
2097
|
-
const first = offset(start);
|
|
2098
|
-
return ownedCommandArguments(Math.max(0, offset(end) - first), (index) => values[first + index], allocation);
|
|
2099
|
-
},
|
|
2100
|
-
select(indices) {
|
|
2101
|
-
return ownedCommandArguments(() => {
|
|
2102
|
-
if (!Array.isArray(indices)) throw new TypeError("Command argument selection must be an array");
|
|
2103
|
-
return indices.length;
|
|
2104
|
-
}, (index) => {
|
|
2105
|
-
const selected = indices[index];
|
|
2106
|
-
if (!Number.isInteger(selected) || selected < 0 || selected >= length) throw new RangeError("Command argument index is out of range");
|
|
2107
|
-
return values[selected];
|
|
2108
|
-
}, allocation, () => indices.length);
|
|
2109
|
-
},
|
|
2110
|
-
concat(...others) {
|
|
2111
|
-
let total = length;
|
|
2112
|
-
for (const other of others) {
|
|
2113
|
-
if (!argumentCarriers.has(other)) throw new TypeError("Expected owned command arguments");
|
|
2114
|
-
total += other.values.length;
|
|
2115
|
-
}
|
|
2116
|
-
return ownedCommandArguments(total, (index) => {
|
|
2117
|
-
if (index < length) return values[index];
|
|
2118
|
-
let offset = index - length;
|
|
2119
|
-
for (const other of others) {
|
|
2120
|
-
if (offset < other.values.length) return other.values[offset];
|
|
2121
|
-
offset -= other.values.length;
|
|
2122
|
-
}
|
|
2123
|
-
throw new RangeError("Command argument index is out of range");
|
|
2124
|
-
}, allocation);
|
|
2125
|
-
},
|
|
2126
|
-
withValues(incoming) {
|
|
2127
|
-
return ownedCommandArguments(() => {
|
|
2128
|
-
if (!Array.isArray(incoming)) throw new TypeError("Command arguments must be an array");
|
|
2129
|
-
return incoming.length;
|
|
2130
|
-
}, (index) => incoming[index], allocation, () => incoming.length);
|
|
2131
|
-
},
|
|
2132
|
-
join(separator = "") {
|
|
2133
|
-
allocation?.assertOpen();
|
|
2134
|
-
const count = Math.max(0, length * 2 - 1);
|
|
2135
|
-
const bytes2 = 128 + count * 16;
|
|
2136
|
-
if (!Number.isSafeInteger(bytes2) || !Number.isSafeInteger(count + 1)) throw new RangeError("Command argument join allocation is too large");
|
|
2137
|
-
const transaction2 = argumentAllocation(allocation);
|
|
2138
|
-
const scratch = transaction2.allocation?.reserve(bytes2, count + 1);
|
|
2139
|
-
try {
|
|
2140
|
-
const parts = [];
|
|
2141
|
-
for (let index = 0; index < length; index++) {
|
|
2142
|
-
if (index) parts.push(separator);
|
|
2143
|
-
parts.push(values[index]);
|
|
2144
|
-
}
|
|
2145
|
-
Object.freeze(parts);
|
|
2146
|
-
scratch?.commit(parts);
|
|
2147
|
-
const result = concatShellValues(parts, transaction2.allocation);
|
|
2148
|
-
scratch?.release();
|
|
2149
|
-
return result;
|
|
2150
|
-
} catch (error) {
|
|
2151
|
-
return transaction2.rollback(error);
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
});
|
|
2155
|
-
reservation?.commit(carrier);
|
|
2156
|
-
argumentCarriers.add(carrier);
|
|
2157
|
-
return carrier;
|
|
2158
|
-
} catch (error) {
|
|
2159
|
-
return transaction.rollback(error);
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
function createCommandArguments(values, allocation) {
|
|
2163
|
-
return ownedCommandArguments(() => {
|
|
2164
|
-
if (!Array.isArray(values)) throw new TypeError("Command arguments must be an array");
|
|
2165
|
-
return values.length;
|
|
2166
|
-
}, (index) => values[index], allocation, () => values.length);
|
|
2167
|
-
}
|
|
2168
|
-
function getCommandArguments(context) {
|
|
2169
|
-
const carrier = context.argumentValues;
|
|
2170
|
-
if (carrier === void 0) return createCommandArguments(context.args);
|
|
2171
|
-
if (!argumentCarriers.has(carrier)) throw new TypeError("Expected owned command arguments");
|
|
2172
|
-
if (carrier.args !== context.args) throw new CommandArgumentIdentityError();
|
|
2173
|
-
return carrier;
|
|
2174
|
-
}
|
|
2175
|
-
var CommandRegistry = class {
|
|
2176
|
-
#commands = /* @__PURE__ */ new Map();
|
|
2177
|
-
constructor(commands = []) {
|
|
2178
|
-
for (const command of commands) this.register(command);
|
|
2179
|
-
}
|
|
2180
|
-
register(command, options = {}) {
|
|
2181
|
-
const { name, execute } = command;
|
|
2182
|
-
if (typeof name !== "string" || !name || /[\s/\0]/u.test(name)) {
|
|
2183
|
-
throw new TypeError("Command names must be nonempty and contain no whitespace, slash, or NUL");
|
|
2184
|
-
}
|
|
2185
|
-
if (typeof execute !== "function") {
|
|
2186
|
-
throw new TypeError("Command execute must be a function");
|
|
2187
|
-
}
|
|
2188
|
-
if (this.#commands.has(name) && !options.replace) {
|
|
2189
|
-
throw new Error(`Command already registered: ${name}`);
|
|
2190
|
-
}
|
|
2191
|
-
this.#commands.set(name, Object.freeze({ ...command, name, execute }));
|
|
2192
|
-
return this;
|
|
2193
|
-
}
|
|
2194
|
-
get(name) {
|
|
2195
|
-
return this.#commands.get(name);
|
|
2196
|
-
}
|
|
2197
|
-
has(name) {
|
|
2198
|
-
return this.#commands.has(name);
|
|
2199
|
-
}
|
|
2200
|
-
unregister(name) {
|
|
2201
|
-
return this.#commands.delete(name);
|
|
2202
|
-
}
|
|
2203
|
-
list() {
|
|
2204
|
-
return Array.from(this.#commands.values());
|
|
2205
|
-
}
|
|
2206
|
-
};
|
|
2207
|
-
function validateExitCode(exitCode) {
|
|
2208
|
-
if (!Number.isInteger(exitCode) || exitCode < 0 || exitCode > 255) {
|
|
2209
|
-
throw new RangeError("Exit status must be an integer between 0 and 255");
|
|
2210
|
-
}
|
|
2211
|
-
return exitCode;
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
|
-
// packages/safe-bash/src/contracts/errors.ts
|
|
2215
|
-
init_platform();
|
|
2216
|
-
import { isErrnoCode, isFsError, toFsError, FsError } from "@poe-platform/safe-fs/core";
|
|
2217
|
-
|
|
2218
|
-
// packages/safe-bash/src/contracts/io.ts
|
|
2219
|
-
init_platform();
|
|
2220
|
-
init_platform();
|
|
2221
|
-
import { collectBytes, readBytes } from "@poe-platform/safe-fs/core";
|
|
2222
|
-
import { collectBytes as collectBytes2, readBytes as readBytes2, toByteSource } from "@poe-platform/safe-fs/core";
|
|
2223
|
-
var outputFailure = /* @__PURE__ */ Symbol("output failure");
|
|
2224
|
-
function createBytePipe(options = {}) {
|
|
2225
|
-
const highWaterMark = options.highWaterMark ?? 64 * 1024;
|
|
2226
|
-
const signal = options.signal;
|
|
2227
|
-
if (!Number.isSafeInteger(highWaterMark) || highWaterMark < 1) {
|
|
2228
|
-
throw new RangeError("highWaterMark must be a positive safe integer");
|
|
2229
|
-
}
|
|
2230
|
-
const stream = new TransformStream(
|
|
2231
|
-
void 0,
|
|
2232
|
-
{ highWaterMark: 1 },
|
|
2233
|
-
{ highWaterMark, size: (chunk) => chunk.byteLength }
|
|
2234
|
-
);
|
|
2235
|
-
const reader = stream.readable.getReader();
|
|
2236
|
-
const writer = stream.writable.getWriter();
|
|
2237
|
-
let ended = false;
|
|
2238
|
-
let failed = false;
|
|
2239
|
-
let failure;
|
|
2240
|
-
let closePromise;
|
|
2241
|
-
let abortPromise;
|
|
2242
|
-
let finished = false;
|
|
2243
|
-
const consumer = new AbortController();
|
|
2244
|
-
const abort = (reason = new FsError("EPIPE", { syscall: "pipe" })) => {
|
|
2245
|
-
if (abortPromise) return abortPromise;
|
|
2246
|
-
if (finished) return Promise.resolve();
|
|
2247
|
-
failed = true;
|
|
2248
|
-
failure = reason;
|
|
2249
|
-
ended = true;
|
|
2250
|
-
consumer.abort(reason);
|
|
2251
|
-
abortPromise = Promise.allSettled([reader.cancel(reason), writer.abort(reason)]).then(() => {
|
|
2252
|
-
});
|
|
2253
|
-
return abortPromise;
|
|
2254
|
-
};
|
|
2255
|
-
const onAbort = () => {
|
|
2256
|
-
void abort(signal?.reason);
|
|
2257
|
-
};
|
|
2258
|
-
const cleanup = () => signal?.removeEventListener("abort", onAbort);
|
|
2259
|
-
void writer.closed.catch(() => {
|
|
2260
|
-
});
|
|
2261
|
-
void reader.closed.then(cleanup, cleanup);
|
|
2262
|
-
if (signal?.aborted) onAbort();
|
|
2263
|
-
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
2264
|
-
const iterator = (async function* () {
|
|
2265
|
-
try {
|
|
2266
|
-
while (true) {
|
|
2267
|
-
if (failed) throw failure;
|
|
2268
|
-
const result = await reader.read();
|
|
2269
|
-
if (failed) throw failure;
|
|
2270
|
-
if (result.done) {
|
|
2271
|
-
finished = true;
|
|
2272
|
-
return;
|
|
2273
|
-
}
|
|
2274
|
-
yield result.value;
|
|
2275
|
-
}
|
|
2276
|
-
} finally {
|
|
2277
|
-
if (!finished) await abort();
|
|
2278
|
-
reader.releaseLock();
|
|
2279
|
-
}
|
|
2280
|
-
})();
|
|
2281
|
-
const readable = {
|
|
2282
|
-
[Symbol.asyncIterator]() {
|
|
2283
|
-
return this;
|
|
2284
|
-
},
|
|
2285
|
-
next() {
|
|
2286
|
-
return iterator.next();
|
|
2287
|
-
},
|
|
2288
|
-
async return() {
|
|
2289
|
-
if (!finished) await abort();
|
|
2290
|
-
try {
|
|
2291
|
-
return await iterator.return(void 0);
|
|
2292
|
-
} finally {
|
|
2293
|
-
reader.releaseLock();
|
|
2294
|
-
}
|
|
2295
|
-
},
|
|
2296
|
-
async throw(reason) {
|
|
2297
|
-
await abort(reason);
|
|
2298
|
-
try {
|
|
2299
|
-
return await iterator.throw(reason);
|
|
2300
|
-
} finally {
|
|
2301
|
-
reader.releaseLock();
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
};
|
|
2305
|
-
const write = async (chunk) => {
|
|
2306
|
-
if (failed) throw failure;
|
|
2307
|
-
if (ended) throw new FsError("EPIPE", { syscall: "write" });
|
|
2308
|
-
if (!(chunk instanceof Uint8Array)) throw new TypeError("Byte sinks require Uint8Array chunks");
|
|
2309
|
-
if (chunk.byteLength > 0) await writer.write(new Uint8Array(chunk));
|
|
2310
|
-
};
|
|
2311
|
-
return {
|
|
2312
|
-
readable,
|
|
2313
|
-
writable: {
|
|
2314
|
-
write,
|
|
2315
|
-
[outputFailure]: abort,
|
|
2316
|
-
ownedOutput: { consumerClosed: consumer.signal, write }
|
|
2317
|
-
},
|
|
2318
|
-
close() {
|
|
2319
|
-
if (failed) return Promise.reject(failure);
|
|
2320
|
-
ended = true;
|
|
2321
|
-
closePromise ??= writer.close();
|
|
2322
|
-
return closePromise;
|
|
2323
|
-
},
|
|
2324
|
-
abort
|
|
2325
|
-
};
|
|
2326
|
-
}
|
|
2327
|
-
async function writeText(sink, text) {
|
|
2328
|
-
await sink.write(new TextEncoder().encode(text));
|
|
2329
|
-
}
|
|
2330
|
-
async function writeBytes(sink, chunk, signal) {
|
|
2331
|
-
if (!(chunk instanceof Uint8Array)) throw new TypeError("Byte sinks require Uint8Array chunks");
|
|
2332
|
-
await abortable(() => sink.write(chunk), signal);
|
|
2333
|
-
}
|
|
2334
|
-
async function pipeBytes(source, sink, signal) {
|
|
2335
|
-
signal?.throwIfAborted();
|
|
2336
|
-
for await (const chunk of readBytes(source, signal)) {
|
|
2337
|
-
await writeBytes(sink, chunk, signal);
|
|
2338
|
-
}
|
|
2339
|
-
signal?.throwIfAborted();
|
|
2340
|
-
}
|
|
2341
|
-
async function collectText(source, options) {
|
|
2342
|
-
return new TextDecoder().decode(await collectBytes(source, options));
|
|
2343
|
-
}
|
|
2344
|
-
async function abortable(operation, signal) {
|
|
2345
|
-
signal?.throwIfAborted();
|
|
2346
|
-
if (!signal) return operation();
|
|
2347
|
-
return new Promise((resolve, reject) => {
|
|
2348
|
-
const onAbort = () => {
|
|
2349
|
-
signal.removeEventListener("abort", onAbort);
|
|
2350
|
-
reject(signal.reason);
|
|
2351
|
-
};
|
|
2352
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
2353
|
-
try {
|
|
2354
|
-
Promise.resolve(operation()).then(
|
|
2355
|
-
(result) => {
|
|
2356
|
-
signal.removeEventListener("abort", onAbort);
|
|
2357
|
-
resolve(result);
|
|
2358
|
-
},
|
|
2359
|
-
(error) => {
|
|
2360
|
-
signal.removeEventListener("abort", onAbort);
|
|
2361
|
-
reject(error);
|
|
2362
|
-
}
|
|
2363
|
-
);
|
|
2364
|
-
} catch (error) {
|
|
2365
|
-
signal.removeEventListener("abort", onAbort);
|
|
2366
|
-
reject(error);
|
|
2367
|
-
}
|
|
2368
|
-
});
|
|
2369
|
-
}
|
|
2370
|
-
|
|
2371
|
-
// packages/safe-bash/src/diagnostics.ts
|
|
2372
|
-
init_platform();
|
|
2373
|
-
var PublicDiagnostic = class extends Error {
|
|
2374
|
-
};
|
|
2375
|
-
function publicDiagnosticMessage(error, onInternalError) {
|
|
2376
|
-
if (error instanceof FsError || error instanceof CommandArgumentIdentityError) return error.message;
|
|
2377
|
-
if (error instanceof PublicDiagnostic && !Object.hasOwn(error, "cause")) return error.message;
|
|
2378
|
-
const original = error instanceof PublicDiagnostic ? error.cause : error;
|
|
2379
|
-
const detail = error instanceof PublicDiagnostic ? error.message : "internal error";
|
|
2380
|
-
try {
|
|
2381
|
-
const pending = onInternalError?.(original);
|
|
2382
|
-
if (pending !== void 0) void Promise.resolve(pending).catch(() => void 0);
|
|
2383
|
-
} catch {
|
|
2384
|
-
return detail;
|
|
2385
|
-
}
|
|
2386
|
-
return detail;
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
// packages/safe-bash/src/contracts/yield.ts
|
|
2390
|
-
init_platform();
|
|
2391
|
-
var checkpoints = /* @__PURE__ */ new WeakMap();
|
|
2392
|
-
function monotonicNow() {
|
|
2393
|
-
return globalThis.performance?.now() ?? Date.now();
|
|
2394
|
-
}
|
|
2395
|
-
function registerYieldCheckpoint(signal, checkpoint) {
|
|
2396
|
-
checkpoints.set(signal, checkpoint);
|
|
2397
|
-
}
|
|
2398
|
-
function scheduleTurn(callback) {
|
|
2399
|
-
const host = globalThis;
|
|
2400
|
-
return host.setImmediate ? { kind: "immediate", value: host.setImmediate(callback) } : { kind: "timeout", value: setTimeout(callback, 0) };
|
|
2401
|
-
}
|
|
2402
|
-
function cancelTurn(handle) {
|
|
2403
|
-
if (handle?.kind === "immediate") globalThis.clearImmediate?.(handle.value);
|
|
2404
|
-
else if (handle) clearTimeout(handle.value);
|
|
2405
|
-
}
|
|
2406
|
-
function yieldTurn(signal) {
|
|
2407
|
-
signal?.throwIfAborted();
|
|
2408
|
-
if (signal) checkpoints.get(signal)?.();
|
|
2409
|
-
return new Promise((resolve, reject) => {
|
|
2410
|
-
let handle;
|
|
2411
|
-
const finish = () => {
|
|
2412
|
-
signal?.removeEventListener("abort", abort);
|
|
2413
|
-
resolve();
|
|
2414
|
-
};
|
|
2415
|
-
const abort = () => {
|
|
2416
|
-
cancelTurn(handle);
|
|
2417
|
-
reject(signal.reason);
|
|
2418
|
-
};
|
|
2419
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
2420
|
-
if (signal?.aborted) abort();
|
|
2421
|
-
else handle = scheduleTurn(finish);
|
|
2422
|
-
});
|
|
2423
|
-
}
|
|
2424
|
-
|
|
2425
1829
|
export {
|
|
2426
1830
|
__toESM,
|
|
2427
1831
|
require_buffer,
|
|
1832
|
+
TransformStream,
|
|
2428
1833
|
import_buffer,
|
|
2429
|
-
init_platform
|
|
2430
|
-
shellValueFromBytes,
|
|
2431
|
-
shellValueText,
|
|
2432
|
-
shellValueByteLength,
|
|
2433
|
-
shellValueRetainedBytes,
|
|
2434
|
-
shellValueBytes,
|
|
2435
|
-
concatShellValues,
|
|
2436
|
-
CommandArgumentIdentityError,
|
|
2437
|
-
createCommandArguments,
|
|
2438
|
-
getCommandArguments,
|
|
2439
|
-
CommandRegistry,
|
|
2440
|
-
validateExitCode,
|
|
2441
|
-
isErrnoCode,
|
|
2442
|
-
isFsError,
|
|
2443
|
-
toFsError,
|
|
2444
|
-
FsError,
|
|
2445
|
-
outputFailure,
|
|
2446
|
-
createBytePipe,
|
|
2447
|
-
writeText,
|
|
2448
|
-
writeBytes,
|
|
2449
|
-
pipeBytes,
|
|
2450
|
-
collectText,
|
|
2451
|
-
collectBytes2 as collectBytes,
|
|
2452
|
-
readBytes2 as readBytes,
|
|
2453
|
-
toByteSource,
|
|
2454
|
-
PublicDiagnostic,
|
|
2455
|
-
publicDiagnosticMessage,
|
|
2456
|
-
monotonicNow,
|
|
2457
|
-
registerYieldCheckpoint,
|
|
2458
|
-
scheduleTurn,
|
|
2459
|
-
cancelTurn,
|
|
2460
|
-
yieldTurn
|
|
1834
|
+
init_platform
|
|
2461
1835
|
};
|
|
2462
1836
|
/*! Bundled license information:
|
|
2463
1837
|
|
|
@@ -2472,4 +1846,4 @@ buffer/index.js:
|
|
|
2472
1846
|
* @license MIT
|
|
2473
1847
|
*)
|
|
2474
1848
|
*/
|
|
2475
|
-
//# sourceMappingURL=chunk-
|
|
1849
|
+
//# sourceMappingURL=chunk-2KL6W6NB.js.map
|