@poe-platform/safe-bash 0.1.534 → 0.1.535
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/chunk-5Y4AEZB2.js +517 -0
- package/dist/safe-bash/chunks/chunk-5Y4AEZB2.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-IKATLB4I.js → chunk-AVXYPKV7.js} +7 -5
- package/dist/safe-bash/chunks/{chunk-IKATLB4I.js.map → chunk-AVXYPKV7.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-LUJYX5H5.js → chunk-L2GZSOSJ.js} +245 -747
- package/dist/safe-bash/chunks/chunk-L2GZSOSJ.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-54Z5EUCW.js → chunk-M7KZ7V4P.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-UGMUVHIY.js → chunk-NVUC5B2R.js} +10 -188
- package/dist/safe-bash/chunks/{chunk-UGMUVHIY.js.map → chunk-NVUC5B2R.js.map} +3 -3
- package/dist/safe-bash/chunks/{chunk-2GV4WO7O.js → chunk-PPVCI2F2.js} +2 -2
- package/dist/safe-bash/chunks/chunk-QY2XHZTE.js +192 -0
- package/dist/safe-bash/chunks/chunk-QY2XHZTE.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-6MHYEBAJ.js → chunk-UZELUFGF.js} +8 -6
- package/dist/safe-bash/chunks/{chunk-6MHYEBAJ.js.map → chunk-UZELUFGF.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-XROAIPKA.js +12095 -0
- package/dist/safe-bash/chunks/chunk-XROAIPKA.js.map +7 -0
- package/dist/safe-bash/commands/csplit/command.d.ts +6 -0
- package/dist/safe-bash/commands/csplit/command.d.ts.map +1 -0
- package/dist/safe-bash/commands/csplit/command.js +78 -0
- package/dist/safe-bash/commands/csplit/command.js.map +1 -0
- package/dist/safe-bash/commands/csplit/index.browser.js +14 -0
- package/dist/safe-bash/commands/csplit/index.browser.js.map +7 -0
- package/dist/safe-bash/commands/csplit/index.d.ts +7 -0
- package/dist/safe-bash/commands/csplit/index.d.ts.map +1 -0
- package/dist/safe-bash/commands/csplit/index.js +21 -0
- package/dist/safe-bash/commands/csplit/index.js.map +1 -0
- package/dist/safe-bash/commands/csplit/internal.d.ts +61 -0
- package/dist/safe-bash/commands/csplit/internal.d.ts.map +1 -0
- package/dist/safe-bash/commands/csplit/internal.js +147 -0
- package/dist/safe-bash/commands/csplit/internal.js.map +1 -0
- package/dist/safe-bash/commands/csplit/io.d.ts +52 -0
- package/dist/safe-bash/commands/csplit/io.d.ts.map +1 -0
- package/dist/safe-bash/commands/csplit/io.js +330 -0
- package/dist/safe-bash/commands/csplit/io.js.map +1 -0
- package/dist/safe-bash/commands/csplit/options.d.ts +16 -0
- package/dist/safe-bash/commands/csplit/options.d.ts.map +1 -0
- package/dist/safe-bash/commands/csplit/options.js +178 -0
- package/dist/safe-bash/commands/csplit/options.js.map +1 -0
- package/dist/safe-bash/commands/csplit/patterns.d.ts +19 -0
- package/dist/safe-bash/commands/csplit/patterns.d.ts.map +1 -0
- package/dist/safe-bash/commands/csplit/patterns.js +92 -0
- package/dist/safe-bash/commands/csplit/patterns.js.map +1 -0
- package/dist/safe-bash/commands/csplit/quoting.d.ts +2 -0
- package/dist/safe-bash/commands/csplit/quoting.d.ts.map +1 -0
- package/dist/safe-bash/commands/csplit/quoting.js +138 -0
- package/dist/safe-bash/commands/csplit/quoting.js.map +1 -0
- package/dist/safe-bash/commands/csplit/split.d.ts +18 -0
- package/dist/safe-bash/commands/csplit/split.d.ts.map +1 -0
- package/dist/safe-bash/commands/csplit/split.js +122 -0
- package/dist/safe-bash/commands/csplit/split.js.map +1 -0
- package/dist/safe-bash/commands/expr/bre-engine.d.ts +4 -1
- package/dist/safe-bash/commands/expr/bre-engine.d.ts.map +1 -1
- package/dist/safe-bash/commands/expr/bre-engine.js +724 -13
- package/dist/safe-bash/commands/expr/bre-engine.js.map +1 -1
- package/dist/safe-bash/commands/expr/bre-worker.d.ts +2 -1
- package/dist/safe-bash/commands/expr/bre-worker.d.ts.map +1 -1
- package/dist/safe-bash/commands/expr/bre-worker.js +10 -1
- package/dist/safe-bash/commands/expr/bre-worker.js.map +1 -1
- package/dist/safe-bash/commands/network/index.browser.js +5 -3
- package/dist/safe-bash/commands/regex-execution/bounded-provider.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/bounded-provider.js +16 -5
- package/dist/safe-bash/commands/regex-execution/bounded-provider.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/portable.d.ts +3 -1
- package/dist/safe-bash/commands/regex-execution/portable.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/portable.js +17 -4
- package/dist/safe-bash/commands/regex-execution/portable.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/protocol.d.ts +31 -0
- package/dist/safe-bash/commands/regex-execution/protocol.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/protocol.js +83 -0
- package/dist/safe-bash/commands/regex-execution/protocol.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/provider.d.ts +2 -2
- package/dist/safe-bash/commands/regex-execution/provider.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/worker.js +16 -2
- package/dist/safe-bash/commands/regex-execution/worker.js.map +1 -1
- package/dist/safe-bash/commands/xml/index.browser.js +4 -3
- package/dist/safe-bash/commands/yq/index.browser.js +5 -4
- package/dist/safe-bash/core.browser.js +1918 -4077
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/dist/safe-bash/core.d.ts +1 -0
- package/dist/safe-bash/core.d.ts.map +1 -1
- package/dist/safe-bash/core.js +1 -0
- package/dist/safe-bash/core.js.map +1 -1
- package/dist/safe-bash/plugins/composition.d.ts +3 -0
- package/dist/safe-bash/plugins/composition.d.ts.map +1 -1
- package/dist/safe-bash/plugins/composition.js +3 -1
- package/dist/safe-bash/plugins/composition.js.map +1 -1
- package/dist/safe-bash/plugins/index.js +1 -1
- package/dist/safe-bash/plugins/index.js.map +1 -1
- package/package.json +8 -2
- package/dist/safe-bash/chunks/chunk-LUJYX5H5.js.map +0 -7
- /package/dist/safe-bash/chunks/{chunk-54Z5EUCW.js.map → chunk-M7KZ7V4P.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-2GV4WO7O.js.map → chunk-PPVCI2F2.js.map} +0 -0
|
@@ -106,34 +106,34 @@ var require_base64_js = __commonJS({
|
|
|
106
106
|
}
|
|
107
107
|
function encodeChunk(uint8, start, end) {
|
|
108
108
|
var tmp;
|
|
109
|
-
var
|
|
109
|
+
var output = [];
|
|
110
110
|
for (var i2 = start; i2 < end; i2 += 3) {
|
|
111
111
|
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
|
|
112
|
-
|
|
112
|
+
output.push(tripletToBase64(tmp));
|
|
113
113
|
}
|
|
114
|
-
return
|
|
114
|
+
return output.join("");
|
|
115
115
|
}
|
|
116
116
|
function fromByteArray(uint8) {
|
|
117
117
|
var tmp;
|
|
118
118
|
var len2 = uint8.length;
|
|
119
119
|
var extraBytes = len2 % 3;
|
|
120
|
-
var
|
|
120
|
+
var parts = [];
|
|
121
121
|
var maxChunkLength = 16383;
|
|
122
122
|
for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
|
|
123
|
-
|
|
123
|
+
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
|
|
124
124
|
}
|
|
125
125
|
if (extraBytes === 1) {
|
|
126
126
|
tmp = uint8[len2 - 1];
|
|
127
|
-
|
|
127
|
+
parts.push(
|
|
128
128
|
lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
|
|
129
129
|
);
|
|
130
130
|
} else if (extraBytes === 2) {
|
|
131
131
|
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
132
|
-
|
|
132
|
+
parts.push(
|
|
133
133
|
lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
|
-
return
|
|
136
|
+
return parts.join("");
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
});
|
|
@@ -172,7 +172,7 @@ var require_ieee754 = __commonJS({
|
|
|
172
172
|
}
|
|
173
173
|
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
174
174
|
};
|
|
175
|
-
exports.write = function(buffer,
|
|
175
|
+
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
176
176
|
var e, m, c;
|
|
177
177
|
var eLen = nBytes * 8 - mLen - 1;
|
|
178
178
|
var eMax = (1 << eLen) - 1;
|
|
@@ -180,23 +180,23 @@ var require_ieee754 = __commonJS({
|
|
|
180
180
|
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
181
181
|
var i = isLE ? 0 : nBytes - 1;
|
|
182
182
|
var d = isLE ? 1 : -1;
|
|
183
|
-
var s =
|
|
184
|
-
|
|
185
|
-
if (isNaN(
|
|
186
|
-
m = isNaN(
|
|
183
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
184
|
+
value = Math.abs(value);
|
|
185
|
+
if (isNaN(value) || value === Infinity) {
|
|
186
|
+
m = isNaN(value) ? 1 : 0;
|
|
187
187
|
e = eMax;
|
|
188
188
|
} else {
|
|
189
|
-
e = Math.floor(Math.log(
|
|
190
|
-
if (
|
|
189
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
190
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
191
191
|
e--;
|
|
192
192
|
c *= 2;
|
|
193
193
|
}
|
|
194
194
|
if (e + eBias >= 1) {
|
|
195
|
-
|
|
195
|
+
value += rt / c;
|
|
196
196
|
} else {
|
|
197
|
-
|
|
197
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
198
198
|
}
|
|
199
|
-
if (
|
|
199
|
+
if (value * c >= 2) {
|
|
200
200
|
e++;
|
|
201
201
|
c /= 2;
|
|
202
202
|
}
|
|
@@ -204,10 +204,10 @@ var require_ieee754 = __commonJS({
|
|
|
204
204
|
m = 0;
|
|
205
205
|
e = eMax;
|
|
206
206
|
} else if (e + eBias >= 1) {
|
|
207
|
-
m = (
|
|
207
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
208
208
|
e = e + eBias;
|
|
209
209
|
} else {
|
|
210
|
-
m =
|
|
210
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
211
211
|
e = 0;
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -288,44 +288,44 @@ var require_buffer = __commonJS({
|
|
|
288
288
|
return from(arg, encodingOrOffset, length);
|
|
289
289
|
}
|
|
290
290
|
Buffer3.poolSize = 8192;
|
|
291
|
-
function from(
|
|
292
|
-
if (typeof
|
|
293
|
-
return fromString(
|
|
291
|
+
function from(value, encodingOrOffset, length) {
|
|
292
|
+
if (typeof value === "string") {
|
|
293
|
+
return fromString(value, encodingOrOffset);
|
|
294
294
|
}
|
|
295
|
-
if (ArrayBuffer.isView(
|
|
296
|
-
return fromArrayView(
|
|
295
|
+
if (ArrayBuffer.isView(value)) {
|
|
296
|
+
return fromArrayView(value);
|
|
297
297
|
}
|
|
298
|
-
if (
|
|
298
|
+
if (value == null) {
|
|
299
299
|
throw new TypeError(
|
|
300
|
-
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof
|
|
300
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
301
301
|
);
|
|
302
302
|
}
|
|
303
|
-
if (isInstance(
|
|
304
|
-
return fromArrayBuffer(
|
|
303
|
+
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
|
|
304
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
305
305
|
}
|
|
306
|
-
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(
|
|
307
|
-
return fromArrayBuffer(
|
|
306
|
+
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
|
|
307
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
308
308
|
}
|
|
309
|
-
if (typeof
|
|
309
|
+
if (typeof value === "number") {
|
|
310
310
|
throw new TypeError(
|
|
311
311
|
'The "value" argument must not be of type number. Received type number'
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
|
-
const valueOf =
|
|
315
|
-
if (valueOf != null && valueOf !==
|
|
314
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
315
|
+
if (valueOf != null && valueOf !== value) {
|
|
316
316
|
return Buffer3.from(valueOf, encodingOrOffset, length);
|
|
317
317
|
}
|
|
318
|
-
const b = fromObject(
|
|
318
|
+
const b = fromObject(value);
|
|
319
319
|
if (b) return b;
|
|
320
|
-
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof
|
|
321
|
-
return Buffer3.from(
|
|
320
|
+
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
321
|
+
return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
|
322
322
|
}
|
|
323
323
|
throw new TypeError(
|
|
324
|
-
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof
|
|
324
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
325
325
|
);
|
|
326
326
|
}
|
|
327
|
-
Buffer3.from = function(
|
|
328
|
-
return from(
|
|
327
|
+
Buffer3.from = function(value, encodingOrOffset, length) {
|
|
328
|
+
return from(value, encodingOrOffset, length);
|
|
329
329
|
};
|
|
330
330
|
Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
|
|
331
331
|
Object.setPrototypeOf(Buffer3, Uint8Array);
|
|
@@ -1239,89 +1239,89 @@ var require_buffer = __commonJS({
|
|
|
1239
1239
|
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1240
1240
|
return ieee754.read(this, offset, false, 52, 8);
|
|
1241
1241
|
};
|
|
1242
|
-
function checkInt(buf,
|
|
1242
|
+
function checkInt(buf, value, offset, ext, max, min) {
|
|
1243
1243
|
if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1244
|
-
if (
|
|
1244
|
+
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
|
1245
1245
|
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1246
1246
|
}
|
|
1247
|
-
Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(
|
|
1248
|
-
|
|
1247
|
+
Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
1248
|
+
value = +value;
|
|
1249
1249
|
offset = offset >>> 0;
|
|
1250
1250
|
byteLength2 = byteLength2 >>> 0;
|
|
1251
1251
|
if (!noAssert) {
|
|
1252
1252
|
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1253
|
-
checkInt(this,
|
|
1253
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1254
1254
|
}
|
|
1255
1255
|
let mul = 1;
|
|
1256
1256
|
let i = 0;
|
|
1257
|
-
this[offset] =
|
|
1257
|
+
this[offset] = value & 255;
|
|
1258
1258
|
while (++i < byteLength2 && (mul *= 256)) {
|
|
1259
|
-
this[offset + i] =
|
|
1259
|
+
this[offset + i] = value / mul & 255;
|
|
1260
1260
|
}
|
|
1261
1261
|
return offset + byteLength2;
|
|
1262
1262
|
};
|
|
1263
|
-
Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(
|
|
1264
|
-
|
|
1263
|
+
Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
1264
|
+
value = +value;
|
|
1265
1265
|
offset = offset >>> 0;
|
|
1266
1266
|
byteLength2 = byteLength2 >>> 0;
|
|
1267
1267
|
if (!noAssert) {
|
|
1268
1268
|
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1269
|
-
checkInt(this,
|
|
1269
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1270
1270
|
}
|
|
1271
1271
|
let i = byteLength2 - 1;
|
|
1272
1272
|
let mul = 1;
|
|
1273
|
-
this[offset + i] =
|
|
1273
|
+
this[offset + i] = value & 255;
|
|
1274
1274
|
while (--i >= 0 && (mul *= 256)) {
|
|
1275
|
-
this[offset + i] =
|
|
1275
|
+
this[offset + i] = value / mul & 255;
|
|
1276
1276
|
}
|
|
1277
1277
|
return offset + byteLength2;
|
|
1278
1278
|
};
|
|
1279
|
-
Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(
|
|
1280
|
-
|
|
1279
|
+
Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1280
|
+
value = +value;
|
|
1281
1281
|
offset = offset >>> 0;
|
|
1282
|
-
if (!noAssert) checkInt(this,
|
|
1283
|
-
this[offset] =
|
|
1282
|
+
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1283
|
+
this[offset] = value & 255;
|
|
1284
1284
|
return offset + 1;
|
|
1285
1285
|
};
|
|
1286
|
-
Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(
|
|
1287
|
-
|
|
1286
|
+
Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1287
|
+
value = +value;
|
|
1288
1288
|
offset = offset >>> 0;
|
|
1289
|
-
if (!noAssert) checkInt(this,
|
|
1290
|
-
this[offset] =
|
|
1291
|
-
this[offset + 1] =
|
|
1289
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1290
|
+
this[offset] = value & 255;
|
|
1291
|
+
this[offset + 1] = value >>> 8;
|
|
1292
1292
|
return offset + 2;
|
|
1293
1293
|
};
|
|
1294
|
-
Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(
|
|
1295
|
-
|
|
1294
|
+
Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1295
|
+
value = +value;
|
|
1296
1296
|
offset = offset >>> 0;
|
|
1297
|
-
if (!noAssert) checkInt(this,
|
|
1298
|
-
this[offset] =
|
|
1299
|
-
this[offset + 1] =
|
|
1297
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1298
|
+
this[offset] = value >>> 8;
|
|
1299
|
+
this[offset + 1] = value & 255;
|
|
1300
1300
|
return offset + 2;
|
|
1301
1301
|
};
|
|
1302
|
-
Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(
|
|
1303
|
-
|
|
1302
|
+
Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1303
|
+
value = +value;
|
|
1304
1304
|
offset = offset >>> 0;
|
|
1305
|
-
if (!noAssert) checkInt(this,
|
|
1306
|
-
this[offset + 3] =
|
|
1307
|
-
this[offset + 2] =
|
|
1308
|
-
this[offset + 1] =
|
|
1309
|
-
this[offset] =
|
|
1305
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1306
|
+
this[offset + 3] = value >>> 24;
|
|
1307
|
+
this[offset + 2] = value >>> 16;
|
|
1308
|
+
this[offset + 1] = value >>> 8;
|
|
1309
|
+
this[offset] = value & 255;
|
|
1310
1310
|
return offset + 4;
|
|
1311
1311
|
};
|
|
1312
|
-
Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(
|
|
1313
|
-
|
|
1312
|
+
Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1313
|
+
value = +value;
|
|
1314
1314
|
offset = offset >>> 0;
|
|
1315
|
-
if (!noAssert) checkInt(this,
|
|
1316
|
-
this[offset] =
|
|
1317
|
-
this[offset + 1] =
|
|
1318
|
-
this[offset + 2] =
|
|
1319
|
-
this[offset + 3] =
|
|
1315
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1316
|
+
this[offset] = value >>> 24;
|
|
1317
|
+
this[offset + 1] = value >>> 16;
|
|
1318
|
+
this[offset + 2] = value >>> 8;
|
|
1319
|
+
this[offset + 3] = value & 255;
|
|
1320
1320
|
return offset + 4;
|
|
1321
1321
|
};
|
|
1322
|
-
function wrtBigUInt64LE(buf,
|
|
1323
|
-
checkIntBI(
|
|
1324
|
-
let lo = Number(
|
|
1322
|
+
function wrtBigUInt64LE(buf, value, offset, min, max) {
|
|
1323
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1324
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1325
1325
|
buf[offset++] = lo;
|
|
1326
1326
|
lo = lo >> 8;
|
|
1327
1327
|
buf[offset++] = lo;
|
|
@@ -1329,7 +1329,7 @@ var require_buffer = __commonJS({
|
|
|
1329
1329
|
buf[offset++] = lo;
|
|
1330
1330
|
lo = lo >> 8;
|
|
1331
1331
|
buf[offset++] = lo;
|
|
1332
|
-
let hi = Number(
|
|
1332
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1333
1333
|
buf[offset++] = hi;
|
|
1334
1334
|
hi = hi >> 8;
|
|
1335
1335
|
buf[offset++] = hi;
|
|
@@ -1339,9 +1339,9 @@ var require_buffer = __commonJS({
|
|
|
1339
1339
|
buf[offset++] = hi;
|
|
1340
1340
|
return offset;
|
|
1341
1341
|
}
|
|
1342
|
-
function wrtBigUInt64BE(buf,
|
|
1343
|
-
checkIntBI(
|
|
1344
|
-
let lo = Number(
|
|
1342
|
+
function wrtBigUInt64BE(buf, value, offset, min, max) {
|
|
1343
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1344
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1345
1345
|
buf[offset + 7] = lo;
|
|
1346
1346
|
lo = lo >> 8;
|
|
1347
1347
|
buf[offset + 6] = lo;
|
|
@@ -1349,7 +1349,7 @@ var require_buffer = __commonJS({
|
|
|
1349
1349
|
buf[offset + 5] = lo;
|
|
1350
1350
|
lo = lo >> 8;
|
|
1351
1351
|
buf[offset + 4] = lo;
|
|
1352
|
-
let hi = Number(
|
|
1352
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1353
1353
|
buf[offset + 3] = hi;
|
|
1354
1354
|
hi = hi >> 8;
|
|
1355
1355
|
buf[offset + 2] = hi;
|
|
@@ -1359,134 +1359,134 @@ var require_buffer = __commonJS({
|
|
|
1359
1359
|
buf[offset] = hi;
|
|
1360
1360
|
return offset + 8;
|
|
1361
1361
|
}
|
|
1362
|
-
Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(
|
|
1363
|
-
return wrtBigUInt64LE(this,
|
|
1362
|
+
Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
|
1363
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1364
1364
|
});
|
|
1365
|
-
Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(
|
|
1366
|
-
return wrtBigUInt64BE(this,
|
|
1365
|
+
Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
|
1366
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1367
1367
|
});
|
|
1368
|
-
Buffer3.prototype.writeIntLE = function writeIntLE(
|
|
1369
|
-
|
|
1368
|
+
Buffer3.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
1369
|
+
value = +value;
|
|
1370
1370
|
offset = offset >>> 0;
|
|
1371
1371
|
if (!noAssert) {
|
|
1372
1372
|
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1373
|
-
checkInt(this,
|
|
1373
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1374
1374
|
}
|
|
1375
1375
|
let i = 0;
|
|
1376
1376
|
let mul = 1;
|
|
1377
1377
|
let sub = 0;
|
|
1378
|
-
this[offset] =
|
|
1378
|
+
this[offset] = value & 255;
|
|
1379
1379
|
while (++i < byteLength2 && (mul *= 256)) {
|
|
1380
|
-
if (
|
|
1380
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
1381
1381
|
sub = 1;
|
|
1382
1382
|
}
|
|
1383
|
-
this[offset + i] = (
|
|
1383
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1384
1384
|
}
|
|
1385
1385
|
return offset + byteLength2;
|
|
1386
1386
|
};
|
|
1387
|
-
Buffer3.prototype.writeIntBE = function writeIntBE(
|
|
1388
|
-
|
|
1387
|
+
Buffer3.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
1388
|
+
value = +value;
|
|
1389
1389
|
offset = offset >>> 0;
|
|
1390
1390
|
if (!noAssert) {
|
|
1391
1391
|
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1392
|
-
checkInt(this,
|
|
1392
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1393
1393
|
}
|
|
1394
1394
|
let i = byteLength2 - 1;
|
|
1395
1395
|
let mul = 1;
|
|
1396
1396
|
let sub = 0;
|
|
1397
|
-
this[offset + i] =
|
|
1397
|
+
this[offset + i] = value & 255;
|
|
1398
1398
|
while (--i >= 0 && (mul *= 256)) {
|
|
1399
|
-
if (
|
|
1399
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
1400
1400
|
sub = 1;
|
|
1401
1401
|
}
|
|
1402
|
-
this[offset + i] = (
|
|
1402
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1403
1403
|
}
|
|
1404
1404
|
return offset + byteLength2;
|
|
1405
1405
|
};
|
|
1406
|
-
Buffer3.prototype.writeInt8 = function writeInt8(
|
|
1407
|
-
|
|
1406
|
+
Buffer3.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1407
|
+
value = +value;
|
|
1408
1408
|
offset = offset >>> 0;
|
|
1409
|
-
if (!noAssert) checkInt(this,
|
|
1410
|
-
if (
|
|
1411
|
-
this[offset] =
|
|
1409
|
+
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
1410
|
+
if (value < 0) value = 255 + value + 1;
|
|
1411
|
+
this[offset] = value & 255;
|
|
1412
1412
|
return offset + 1;
|
|
1413
1413
|
};
|
|
1414
|
-
Buffer3.prototype.writeInt16LE = function writeInt16LE(
|
|
1415
|
-
|
|
1414
|
+
Buffer3.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1415
|
+
value = +value;
|
|
1416
1416
|
offset = offset >>> 0;
|
|
1417
|
-
if (!noAssert) checkInt(this,
|
|
1418
|
-
this[offset] =
|
|
1419
|
-
this[offset + 1] =
|
|
1417
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1418
|
+
this[offset] = value & 255;
|
|
1419
|
+
this[offset + 1] = value >>> 8;
|
|
1420
1420
|
return offset + 2;
|
|
1421
1421
|
};
|
|
1422
|
-
Buffer3.prototype.writeInt16BE = function writeInt16BE(
|
|
1423
|
-
|
|
1422
|
+
Buffer3.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1423
|
+
value = +value;
|
|
1424
1424
|
offset = offset >>> 0;
|
|
1425
|
-
if (!noAssert) checkInt(this,
|
|
1426
|
-
this[offset] =
|
|
1427
|
-
this[offset + 1] =
|
|
1425
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1426
|
+
this[offset] = value >>> 8;
|
|
1427
|
+
this[offset + 1] = value & 255;
|
|
1428
1428
|
return offset + 2;
|
|
1429
1429
|
};
|
|
1430
|
-
Buffer3.prototype.writeInt32LE = function writeInt32LE(
|
|
1431
|
-
|
|
1430
|
+
Buffer3.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1431
|
+
value = +value;
|
|
1432
1432
|
offset = offset >>> 0;
|
|
1433
|
-
if (!noAssert) checkInt(this,
|
|
1434
|
-
this[offset] =
|
|
1435
|
-
this[offset + 1] =
|
|
1436
|
-
this[offset + 2] =
|
|
1437
|
-
this[offset + 3] =
|
|
1433
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1434
|
+
this[offset] = value & 255;
|
|
1435
|
+
this[offset + 1] = value >>> 8;
|
|
1436
|
+
this[offset + 2] = value >>> 16;
|
|
1437
|
+
this[offset + 3] = value >>> 24;
|
|
1438
1438
|
return offset + 4;
|
|
1439
1439
|
};
|
|
1440
|
-
Buffer3.prototype.writeInt32BE = function writeInt32BE(
|
|
1441
|
-
|
|
1440
|
+
Buffer3.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1441
|
+
value = +value;
|
|
1442
1442
|
offset = offset >>> 0;
|
|
1443
|
-
if (!noAssert) checkInt(this,
|
|
1444
|
-
if (
|
|
1445
|
-
this[offset] =
|
|
1446
|
-
this[offset + 1] =
|
|
1447
|
-
this[offset + 2] =
|
|
1448
|
-
this[offset + 3] =
|
|
1443
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1444
|
+
if (value < 0) value = 4294967295 + value + 1;
|
|
1445
|
+
this[offset] = value >>> 24;
|
|
1446
|
+
this[offset + 1] = value >>> 16;
|
|
1447
|
+
this[offset + 2] = value >>> 8;
|
|
1448
|
+
this[offset + 3] = value & 255;
|
|
1449
1449
|
return offset + 4;
|
|
1450
1450
|
};
|
|
1451
|
-
Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(
|
|
1452
|
-
return wrtBigUInt64LE(this,
|
|
1451
|
+
Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
|
1452
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1453
1453
|
});
|
|
1454
|
-
Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(
|
|
1455
|
-
return wrtBigUInt64BE(this,
|
|
1454
|
+
Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
|
1455
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1456
1456
|
});
|
|
1457
|
-
function checkIEEE754(buf,
|
|
1457
|
+
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
1458
1458
|
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1459
1459
|
if (offset < 0) throw new RangeError("Index out of range");
|
|
1460
1460
|
}
|
|
1461
|
-
function writeFloat(buf,
|
|
1462
|
-
|
|
1461
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
1462
|
+
value = +value;
|
|
1463
1463
|
offset = offset >>> 0;
|
|
1464
1464
|
if (!noAssert) {
|
|
1465
|
-
checkIEEE754(buf,
|
|
1465
|
+
checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
|
|
1466
1466
|
}
|
|
1467
|
-
ieee754.write(buf,
|
|
1467
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
1468
1468
|
return offset + 4;
|
|
1469
1469
|
}
|
|
1470
|
-
Buffer3.prototype.writeFloatLE = function writeFloatLE(
|
|
1471
|
-
return writeFloat(this,
|
|
1470
|
+
Buffer3.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1471
|
+
return writeFloat(this, value, offset, true, noAssert);
|
|
1472
1472
|
};
|
|
1473
|
-
Buffer3.prototype.writeFloatBE = function writeFloatBE(
|
|
1474
|
-
return writeFloat(this,
|
|
1473
|
+
Buffer3.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1474
|
+
return writeFloat(this, value, offset, false, noAssert);
|
|
1475
1475
|
};
|
|
1476
|
-
function writeDouble(buf,
|
|
1477
|
-
|
|
1476
|
+
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
1477
|
+
value = +value;
|
|
1478
1478
|
offset = offset >>> 0;
|
|
1479
1479
|
if (!noAssert) {
|
|
1480
|
-
checkIEEE754(buf,
|
|
1480
|
+
checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
|
|
1481
1481
|
}
|
|
1482
|
-
ieee754.write(buf,
|
|
1482
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
1483
1483
|
return offset + 8;
|
|
1484
1484
|
}
|
|
1485
|
-
Buffer3.prototype.writeDoubleLE = function writeDoubleLE(
|
|
1486
|
-
return writeDouble(this,
|
|
1485
|
+
Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1486
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
1487
1487
|
};
|
|
1488
|
-
Buffer3.prototype.writeDoubleBE = function writeDoubleBE(
|
|
1489
|
-
return writeDouble(this,
|
|
1488
|
+
Buffer3.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1489
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
1490
1490
|
};
|
|
1491
1491
|
Buffer3.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1492
1492
|
if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
|
@@ -1588,11 +1588,11 @@ var require_buffer = __commonJS({
|
|
|
1588
1588
|
get code() {
|
|
1589
1589
|
return sym;
|
|
1590
1590
|
}
|
|
1591
|
-
set code(
|
|
1591
|
+
set code(value) {
|
|
1592
1592
|
Object.defineProperty(this, "code", {
|
|
1593
1593
|
configurable: true,
|
|
1594
1594
|
enumerable: true,
|
|
1595
|
-
value
|
|
1595
|
+
value,
|
|
1596
1596
|
writable: true
|
|
1597
1597
|
});
|
|
1598
1598
|
}
|
|
@@ -1620,14 +1620,14 @@ var require_buffer = __commonJS({
|
|
|
1620
1620
|
);
|
|
1621
1621
|
E(
|
|
1622
1622
|
"ERR_OUT_OF_RANGE",
|
|
1623
|
-
function(str, range,
|
|
1623
|
+
function(str, range, input) {
|
|
1624
1624
|
let msg = `The value of "${str}" is out of range.`;
|
|
1625
|
-
let received =
|
|
1626
|
-
if (Number.isInteger(
|
|
1627
|
-
received = addNumericalSeparator(String(
|
|
1628
|
-
} else if (typeof
|
|
1629
|
-
received = String(
|
|
1630
|
-
if (
|
|
1625
|
+
let received = input;
|
|
1626
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
1627
|
+
received = addNumericalSeparator(String(input));
|
|
1628
|
+
} else if (typeof input === "bigint") {
|
|
1629
|
+
received = String(input);
|
|
1630
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
1631
1631
|
received = addNumericalSeparator(received);
|
|
1632
1632
|
}
|
|
1633
1633
|
received += "n";
|
|
@@ -1652,8 +1652,8 @@ var require_buffer = __commonJS({
|
|
|
1652
1652
|
boundsError(offset, buf.length - (byteLength2 + 1));
|
|
1653
1653
|
}
|
|
1654
1654
|
}
|
|
1655
|
-
function checkIntBI(
|
|
1656
|
-
if (
|
|
1655
|
+
function checkIntBI(value, min, max, buf, offset, byteLength2) {
|
|
1656
|
+
if (value > max || value < min) {
|
|
1657
1657
|
const n = typeof min === "bigint" ? "n" : "";
|
|
1658
1658
|
let range;
|
|
1659
1659
|
if (byteLength2 > 3) {
|
|
@@ -1665,19 +1665,19 @@ var require_buffer = __commonJS({
|
|
|
1665
1665
|
} else {
|
|
1666
1666
|
range = `>= ${min}${n} and <= ${max}${n}`;
|
|
1667
1667
|
}
|
|
1668
|
-
throw new errors.ERR_OUT_OF_RANGE("value", range,
|
|
1668
|
+
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
|
|
1669
1669
|
}
|
|
1670
1670
|
checkBounds(buf, offset, byteLength2);
|
|
1671
1671
|
}
|
|
1672
|
-
function validateNumber(
|
|
1673
|
-
if (typeof
|
|
1674
|
-
throw new errors.ERR_INVALID_ARG_TYPE(name, "number",
|
|
1672
|
+
function validateNumber(value, name) {
|
|
1673
|
+
if (typeof value !== "number") {
|
|
1674
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
1675
1675
|
}
|
|
1676
1676
|
}
|
|
1677
|
-
function boundsError(
|
|
1678
|
-
if (Math.floor(
|
|
1679
|
-
validateNumber(
|
|
1680
|
-
throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer",
|
|
1677
|
+
function boundsError(value, length, type) {
|
|
1678
|
+
if (Math.floor(value) !== value) {
|
|
1679
|
+
validateNumber(value, type);
|
|
1680
|
+
throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
|
|
1681
1681
|
}
|
|
1682
1682
|
if (length < 0) {
|
|
1683
1683
|
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
|
|
@@ -1685,7 +1685,7 @@ var require_buffer = __commonJS({
|
|
|
1685
1685
|
throw new errors.ERR_OUT_OF_RANGE(
|
|
1686
1686
|
type || "offset",
|
|
1687
1687
|
`>= ${type ? 1 : 0} and <= ${length}`,
|
|
1688
|
-
|
|
1688
|
+
value
|
|
1689
1689
|
);
|
|
1690
1690
|
}
|
|
1691
1691
|
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
@@ -1835,8 +1835,8 @@ var typedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
|
|
|
1835
1835
|
var viewBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
|
|
1836
1836
|
var viewOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset").get;
|
|
1837
1837
|
var viewLength = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength").get;
|
|
1838
|
-
function record(
|
|
1839
|
-
const result = byteValues.get(
|
|
1838
|
+
function record(value) {
|
|
1839
|
+
const result = byteValues.get(value);
|
|
1840
1840
|
if (!result) throw new TypeError("Expected an owned shell byte value");
|
|
1841
1841
|
return result;
|
|
1842
1842
|
}
|
|
@@ -1862,9 +1862,9 @@ function allocate(bytes, allocation, create, slots = 1) {
|
|
|
1862
1862
|
}
|
|
1863
1863
|
}
|
|
1864
1864
|
function ownedBytes(bytes) {
|
|
1865
|
-
const
|
|
1866
|
-
byteValues.set(
|
|
1867
|
-
return
|
|
1865
|
+
const value = Object.freeze({});
|
|
1866
|
+
byteValues.set(value, { bytes, text: decoder.decode(bytes) });
|
|
1867
|
+
return value;
|
|
1868
1868
|
}
|
|
1869
1869
|
function shellValueFromBytes(bytes, allocation) {
|
|
1870
1870
|
if (!(bytes instanceof Uint8Array)) throw new TypeError("Shell bytes must be Uint8Array");
|
|
@@ -1876,19 +1876,19 @@ function shellValueFromBytes(bytes, allocation) {
|
|
|
1876
1876
|
return ownedBytes(new Uint8Array(new Uint8Array(buffer, offset, length)));
|
|
1877
1877
|
});
|
|
1878
1878
|
}
|
|
1879
|
-
function shellValueText(
|
|
1880
|
-
return typeof
|
|
1879
|
+
function shellValueText(value) {
|
|
1880
|
+
return typeof value === "string" ? value : record(value).text;
|
|
1881
1881
|
}
|
|
1882
|
-
function shellValueByteLength(
|
|
1883
|
-
return typeof
|
|
1882
|
+
function shellValueByteLength(value) {
|
|
1883
|
+
return typeof value === "string" ? import_buffer.Buffer.byteLength(value) : record(value).bytes.byteLength;
|
|
1884
1884
|
}
|
|
1885
|
-
function shellValueRetainedBytes(
|
|
1886
|
-
const stored = record(
|
|
1885
|
+
function shellValueRetainedBytes(value) {
|
|
1886
|
+
const stored = record(value);
|
|
1887
1887
|
return stored.bytes.byteLength + stored.text.length * 2 + 64;
|
|
1888
1888
|
}
|
|
1889
|
-
function shellValueBytes(
|
|
1890
|
-
const length = shellValueByteLength(
|
|
1891
|
-
return allocate(allocationSize(length, 1), allocation, () => typeof
|
|
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
1892
|
}
|
|
1893
1893
|
function concatShellValues(values, allocation) {
|
|
1894
1894
|
allocation?.assertOpen();
|
|
@@ -1897,10 +1897,10 @@ function concatShellValues(values, allocation) {
|
|
|
1897
1897
|
if (!Number.isSafeInteger(count) || count < 0 || count > 4294967295) throw new RangeError("Invalid shell value input extent");
|
|
1898
1898
|
if (!count) return "";
|
|
1899
1899
|
if (count === 1) {
|
|
1900
|
-
const
|
|
1901
|
-
if (typeof
|
|
1900
|
+
const value = values[0];
|
|
1901
|
+
if (typeof value !== "string") record(value);
|
|
1902
1902
|
if (values.length !== count) throw new TypeError("Shell value input extent changed");
|
|
1903
|
-
return
|
|
1903
|
+
return value;
|
|
1904
1904
|
}
|
|
1905
1905
|
let textOnly = true;
|
|
1906
1906
|
for (let index = 0; index < count; index++) {
|
|
@@ -1912,9 +1912,9 @@ function concatShellValues(values, allocation) {
|
|
|
1912
1912
|
if (textOnly) {
|
|
1913
1913
|
let text = "";
|
|
1914
1914
|
for (let index = 0; index < count; index++) {
|
|
1915
|
-
const
|
|
1916
|
-
if (typeof
|
|
1917
|
-
text +=
|
|
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
1918
|
}
|
|
1919
1919
|
if (values.length !== count) throw new TypeError("Shell value input extent changed");
|
|
1920
1920
|
return text;
|
|
@@ -1929,14 +1929,14 @@ function concatShellValues(values, allocation) {
|
|
|
1929
1929
|
if (values.length !== count) throw new TypeError("Shell value input extent changed during metadata admission");
|
|
1930
1930
|
const snapshot = new Array(count);
|
|
1931
1931
|
for (let index = 0; index < count; index++) {
|
|
1932
|
-
const
|
|
1933
|
-
if (typeof
|
|
1934
|
-
snapshot[index] =
|
|
1932
|
+
const value = values[index];
|
|
1933
|
+
if (typeof value !== "string") record(value);
|
|
1934
|
+
snapshot[index] = value;
|
|
1935
1935
|
}
|
|
1936
1936
|
if (values.length !== count) throw new TypeError("Shell value input extent changed during snapshot capture");
|
|
1937
1937
|
Object.freeze(snapshot);
|
|
1938
1938
|
reservation?.commit(snapshot);
|
|
1939
|
-
if (snapshot.every((
|
|
1939
|
+
if (snapshot.every((value) => typeof value === "string")) {
|
|
1940
1940
|
const result = snapshot.join("");
|
|
1941
1941
|
release();
|
|
1942
1942
|
return result;
|
|
@@ -1958,11 +1958,11 @@ function concatShellValues(values, allocation) {
|
|
|
1958
1958
|
throw error;
|
|
1959
1959
|
}
|
|
1960
1960
|
}
|
|
1961
|
-
function encodeValues(values,
|
|
1961
|
+
function encodeValues(values, output) {
|
|
1962
1962
|
let offset = 0;
|
|
1963
1963
|
let high = 0;
|
|
1964
1964
|
const write = (byte) => {
|
|
1965
|
-
if (
|
|
1965
|
+
if (output) output[offset] = byte;
|
|
1966
1966
|
offset++;
|
|
1967
1967
|
};
|
|
1968
1968
|
const point = (code) => {
|
|
@@ -1981,19 +1981,19 @@ function encodeValues(values, output2) {
|
|
|
1981
1981
|
write(128 | code & 63);
|
|
1982
1982
|
}
|
|
1983
1983
|
};
|
|
1984
|
-
for (const
|
|
1985
|
-
if (typeof
|
|
1984
|
+
for (const value of values) {
|
|
1985
|
+
if (typeof value !== "string") {
|
|
1986
1986
|
if (high) {
|
|
1987
1987
|
point(65533);
|
|
1988
1988
|
high = 0;
|
|
1989
1989
|
}
|
|
1990
|
-
const bytes = record(
|
|
1991
|
-
|
|
1990
|
+
const bytes = record(value).bytes;
|
|
1991
|
+
output?.set(bytes, offset);
|
|
1992
1992
|
offset += bytes.byteLength;
|
|
1993
1993
|
continue;
|
|
1994
1994
|
}
|
|
1995
|
-
for (let index = 0; index <
|
|
1996
|
-
const code =
|
|
1995
|
+
for (let index = 0; index < value.length; index++) {
|
|
1996
|
+
const code = value.charCodeAt(index);
|
|
1997
1997
|
if (high) {
|
|
1998
1998
|
const previous = high;
|
|
1999
1999
|
high = 0;
|
|
@@ -2030,8 +2030,8 @@ function argumentAllocation(allocation) {
|
|
|
2030
2030
|
const reservation = allocation.reserve(bytes, slots);
|
|
2031
2031
|
let released = false;
|
|
2032
2032
|
const owned = {
|
|
2033
|
-
commit(
|
|
2034
|
-
reservation.commit(
|
|
2033
|
+
commit(value) {
|
|
2034
|
+
reservation.commit(value);
|
|
2035
2035
|
},
|
|
2036
2036
|
release() {
|
|
2037
2037
|
if (released) return;
|
|
@@ -2077,9 +2077,9 @@ function ownedCommandArguments(size, valueAt, allocation, extent) {
|
|
|
2077
2077
|
const values = [];
|
|
2078
2078
|
const args = [];
|
|
2079
2079
|
for (const incoming of snapshot) {
|
|
2080
|
-
const
|
|
2081
|
-
args.push(shellValueText(
|
|
2082
|
-
values.push(
|
|
2080
|
+
const value = incoming instanceof Uint8Array ? shellValueFromBytes(incoming, transaction.allocation) : incoming;
|
|
2081
|
+
args.push(shellValueText(value));
|
|
2082
|
+
values.push(value);
|
|
2083
2083
|
}
|
|
2084
2084
|
Object.freeze(values);
|
|
2085
2085
|
Object.freeze(args);
|
|
@@ -2137,14 +2137,14 @@ function ownedCommandArguments(size, valueAt, allocation, extent) {
|
|
|
2137
2137
|
const transaction2 = argumentAllocation(allocation);
|
|
2138
2138
|
const scratch = transaction2.allocation?.reserve(bytes2, count + 1);
|
|
2139
2139
|
try {
|
|
2140
|
-
const
|
|
2140
|
+
const parts = [];
|
|
2141
2141
|
for (let index = 0; index < length; index++) {
|
|
2142
|
-
if (index)
|
|
2143
|
-
|
|
2142
|
+
if (index) parts.push(separator);
|
|
2143
|
+
parts.push(values[index]);
|
|
2144
2144
|
}
|
|
2145
|
-
Object.freeze(
|
|
2146
|
-
scratch?.commit(
|
|
2147
|
-
const result = concatShellValues(
|
|
2145
|
+
Object.freeze(parts);
|
|
2146
|
+
scratch?.commit(parts);
|
|
2147
|
+
const result = concatShellValues(parts, transaction2.allocation);
|
|
2148
2148
|
scratch?.release();
|
|
2149
2149
|
return result;
|
|
2150
2150
|
} catch (error) {
|
|
@@ -2177,7 +2177,7 @@ var CommandRegistry = class {
|
|
|
2177
2177
|
constructor(commands = []) {
|
|
2178
2178
|
for (const command of commands) this.register(command);
|
|
2179
2179
|
}
|
|
2180
|
-
register(command,
|
|
2180
|
+
register(command, options = {}) {
|
|
2181
2181
|
const { name, execute } = command;
|
|
2182
2182
|
if (typeof name !== "string" || !name || /[\s/\0]/u.test(name)) {
|
|
2183
2183
|
throw new TypeError("Command names must be nonempty and contain no whitespace, slash, or NUL");
|
|
@@ -2185,7 +2185,7 @@ var CommandRegistry = class {
|
|
|
2185
2185
|
if (typeof execute !== "function") {
|
|
2186
2186
|
throw new TypeError("Command execute must be a function");
|
|
2187
2187
|
}
|
|
2188
|
-
if (this.#commands.has(name) && !
|
|
2188
|
+
if (this.#commands.has(name) && !options.replace) {
|
|
2189
2189
|
throw new Error(`Command already registered: ${name}`);
|
|
2190
2190
|
}
|
|
2191
2191
|
this.#commands.set(name, Object.freeze({ ...command, name, execute }));
|
|
@@ -2215,59 +2215,15 @@ function validateExitCode(exitCode) {
|
|
|
2215
2215
|
init_platform();
|
|
2216
2216
|
import { isErrnoCode, isFsError, toFsError, FsError } from "@poe-platform/safe-fs/core";
|
|
2217
2217
|
|
|
2218
|
-
// packages/safe-bash/src/contracts/command-requirements.ts
|
|
2219
|
-
init_platform();
|
|
2220
|
-
function evaluateMode(requirement, capabilities) {
|
|
2221
|
-
const missing = requirement.capabilities.filter((name) => capabilities[name] === false);
|
|
2222
|
-
const unknown = requirement.capabilities.filter((name) => capabilities[name] === void 0);
|
|
2223
|
-
if (requirement.mutates && capabilities.readOnly === true) missing.push("readOnly");
|
|
2224
|
-
const alternatives = requirement.anyOf;
|
|
2225
|
-
if (alternatives && !alternatives.some((group) => group.every((name) => capabilities[name] === true))) {
|
|
2226
|
-
if (alternatives.every((group) => group.some((name) => capabilities[name] === false))) {
|
|
2227
|
-
missing.push(...alternatives.flatMap((group) => group.filter((name) => capabilities[name] === false)));
|
|
2228
|
-
} else {
|
|
2229
|
-
unknown.push(...alternatives.filter((group) => !group.some((name) => capabilities[name] === false)).flatMap((group) => group.filter((name) => capabilities[name] === void 0)));
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
return {
|
|
2233
|
-
...requirement,
|
|
2234
|
-
status: missing.length ? "unsupported" : unknown.length ? "unknown" : "supported",
|
|
2235
|
-
missing: [...new Set(missing)],
|
|
2236
|
-
unknown: [...new Set(unknown)]
|
|
2237
|
-
};
|
|
2238
|
-
}
|
|
2239
|
-
function evaluateCommandSupport(command, capabilities) {
|
|
2240
|
-
const modes = (command.filesystemRequirements ?? []).map((requirement) => evaluateMode(requirement, capabilities));
|
|
2241
|
-
return {
|
|
2242
|
-
declared: command.filesystemRequirements !== void 0,
|
|
2243
|
-
status: command.filesystemRequirements !== void 0 && modes.every((mode) => mode.status === "supported") ? "supported" : modes.length && modes.every((mode) => mode.status === "unsupported") ? "unsupported" : "partial",
|
|
2244
|
-
modes
|
|
2245
|
-
};
|
|
2246
|
-
}
|
|
2247
|
-
function assertCommandRequirements(context, requirements, selected, capabilities = context.fs.capabilities) {
|
|
2248
|
-
context.signal.throwIfAborted();
|
|
2249
|
-
for (const id of new Set(selected)) {
|
|
2250
|
-
const requirement = requirements.find((mode) => mode.id === id);
|
|
2251
|
-
if (!requirement) throw new TypeError(`Unknown filesystem requirement mode: ${id}`);
|
|
2252
|
-
const support = evaluateMode(requirement, capabilities);
|
|
2253
|
-
if (support.status === "unsupported") {
|
|
2254
|
-
throw new FsError(support.missing.includes("readOnly") ? "EROFS" : "ENOTSUP", {
|
|
2255
|
-
syscall: context.command,
|
|
2256
|
-
message: `${requirement.description} requires unavailable filesystem capabilities: ${support.missing.join(", ")}`
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
|
|
2262
2218
|
// packages/safe-bash/src/contracts/io.ts
|
|
2263
2219
|
init_platform();
|
|
2264
2220
|
init_platform();
|
|
2265
2221
|
import { collectBytes, readBytes } from "@poe-platform/safe-fs/core";
|
|
2266
2222
|
import { collectBytes as collectBytes2, readBytes as readBytes2, toByteSource } from "@poe-platform/safe-fs/core";
|
|
2267
2223
|
var outputFailure = /* @__PURE__ */ Symbol("output failure");
|
|
2268
|
-
function createBytePipe(
|
|
2269
|
-
const highWaterMark =
|
|
2270
|
-
const signal =
|
|
2224
|
+
function createBytePipe(options = {}) {
|
|
2225
|
+
const highWaterMark = options.highWaterMark ?? 64 * 1024;
|
|
2226
|
+
const signal = options.signal;
|
|
2271
2227
|
if (!Number.isSafeInteger(highWaterMark) || highWaterMark < 1) {
|
|
2272
2228
|
throw new RangeError("highWaterMark must be a positive safe integer");
|
|
2273
2229
|
}
|
|
@@ -2382,8 +2338,8 @@ async function pipeBytes(source, sink, signal) {
|
|
|
2382
2338
|
}
|
|
2383
2339
|
signal?.throwIfAborted();
|
|
2384
2340
|
}
|
|
2385
|
-
async function collectText(source,
|
|
2386
|
-
return new TextDecoder().decode(await collectBytes(source,
|
|
2341
|
+
async function collectText(source, options) {
|
|
2342
|
+
return new TextDecoder().decode(await collectBytes(source, options));
|
|
2387
2343
|
}
|
|
2388
2344
|
async function abortable(operation, signal) {
|
|
2389
2345
|
signal?.throwIfAborted();
|
|
@@ -2412,12 +2368,23 @@ async function abortable(operation, signal) {
|
|
|
2412
2368
|
});
|
|
2413
2369
|
}
|
|
2414
2370
|
|
|
2415
|
-
// packages/safe-bash/src/
|
|
2416
|
-
init_platform();
|
|
2417
|
-
|
|
2418
|
-
// packages/safe-bash/src/contracts/path.ts
|
|
2371
|
+
// packages/safe-bash/src/diagnostics.ts
|
|
2419
2372
|
init_platform();
|
|
2420
|
-
|
|
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
|
+
}
|
|
2421
2388
|
|
|
2422
2389
|
// packages/safe-bash/src/contracts/yield.ts
|
|
2423
2390
|
init_platform();
|
|
@@ -2455,448 +2422,9 @@ function yieldTurn(signal) {
|
|
|
2455
2422
|
});
|
|
2456
2423
|
}
|
|
2457
2424
|
|
|
2458
|
-
// packages/safe-bash/src/
|
|
2459
|
-
var controls = { 8: "\\b", 9: "\\t", 10: "\\n", 11: "\\v", 12: "\\f", 13: "\\r", 92: "\\\\" };
|
|
2460
|
-
var encoder2 = new TextEncoder();
|
|
2461
|
-
function* parts(value2, mode) {
|
|
2462
|
-
for (const character of value2) {
|
|
2463
|
-
const point = character.codePointAt(0);
|
|
2464
|
-
if (mode === "diagnostic" && (point === 9 || point === 10 || point >= 32 && (point < 127 || point > 159))) {
|
|
2465
|
-
yield character;
|
|
2466
|
-
} else {
|
|
2467
|
-
for (const byte of encoder2.encode(character)) {
|
|
2468
|
-
yield controls[byte] ?? (byte >= 32 && byte < 127 ? String.fromCharCode(byte) : `\\${byte.toString(8).padStart(3, "0")}`);
|
|
2469
|
-
}
|
|
2470
|
-
}
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
function escapeText(value2, mode, checkOutput) {
|
|
2474
|
-
let result = "", bytes = 0;
|
|
2475
|
-
for (const part of parts(value2, mode)) {
|
|
2476
|
-
bytes += import_buffer.Buffer.byteLength(part);
|
|
2477
|
-
checkOutput?.(bytes);
|
|
2478
|
-
result += part;
|
|
2479
|
-
}
|
|
2480
|
-
return result;
|
|
2481
|
-
}
|
|
2482
|
-
async function writeDiagnostic(sink, value2, signal) {
|
|
2483
|
-
signal?.throwIfAborted();
|
|
2484
|
-
let chunk = "", bytes = 0, work = 0;
|
|
2485
|
-
for (const part of parts(value2, "diagnostic")) {
|
|
2486
|
-
signal?.throwIfAborted();
|
|
2487
|
-
const size = import_buffer.Buffer.byteLength(part);
|
|
2488
|
-
if (bytes + size > 16384) {
|
|
2489
|
-
await writeBytes(sink, encoder2.encode(chunk), signal);
|
|
2490
|
-
chunk = "";
|
|
2491
|
-
bytes = 0;
|
|
2492
|
-
}
|
|
2493
|
-
chunk += part;
|
|
2494
|
-
bytes += size;
|
|
2495
|
-
if (++work % 1024 === 0) await yieldTurn(signal);
|
|
2496
|
-
}
|
|
2497
|
-
if (bytes) await writeBytes(sink, encoder2.encode(chunk), signal);
|
|
2498
|
-
signal?.throwIfAborted();
|
|
2499
|
-
}
|
|
2500
|
-
|
|
2501
|
-
// packages/safe-bash/src/commands/internal.ts
|
|
2502
|
-
init_platform();
|
|
2503
|
-
|
|
2504
|
-
// packages/safe-bash/src/diagnostics.ts
|
|
2505
|
-
init_platform();
|
|
2506
|
-
var PublicDiagnostic = class extends Error {
|
|
2507
|
-
};
|
|
2508
|
-
function publicDiagnosticMessage(error, onInternalError) {
|
|
2509
|
-
if (error instanceof FsError || error instanceof CommandArgumentIdentityError) return error.message;
|
|
2510
|
-
if (error instanceof PublicDiagnostic && !Object.hasOwn(error, "cause")) return error.message;
|
|
2511
|
-
const original = error instanceof PublicDiagnostic ? error.cause : error;
|
|
2512
|
-
const detail = error instanceof PublicDiagnostic ? error.message : "internal error";
|
|
2513
|
-
try {
|
|
2514
|
-
const pending = onInternalError?.(original);
|
|
2515
|
-
if (pending !== void 0) void Promise.resolve(pending).catch(() => void 0);
|
|
2516
|
-
} catch {
|
|
2517
|
-
return detail;
|
|
2518
|
-
}
|
|
2519
|
-
return detail;
|
|
2520
|
-
}
|
|
2521
|
-
|
|
2522
|
-
// packages/safe-bash/src/commands/portable-requirements.ts
|
|
2523
|
-
init_platform();
|
|
2524
|
-
var inputRequirements = [
|
|
2525
|
-
{ id: "stdin", description: "Read standard input", capabilities: [] },
|
|
2526
|
-
{ id: "file", description: "Read file operands", capabilities: [], anyOf: [["streamingRead"], ["read"]] }
|
|
2527
|
-
];
|
|
2528
|
-
var textOutputRequirements = [
|
|
2529
|
-
...inputRequirements,
|
|
2530
|
-
{ id: "output", description: "Write or truncate an output file", capabilities: [], anyOf: [["streamingWrite"], ["write"]], mutates: true }
|
|
2531
|
-
];
|
|
2532
|
-
var pwdRequirements = [
|
|
2533
|
-
{ id: "logical", description: "Print the logical working directory", capabilities: [] },
|
|
2534
|
-
{ id: "physical", description: "Resolve the physical working directory (-P)", capabilities: ["realpath"] }
|
|
2535
|
-
];
|
|
2536
|
-
var predicateRequirements = [
|
|
2537
|
-
{ id: "expression", description: "Evaluate strings and integers", capabilities: [] },
|
|
2538
|
-
{ id: "metadata", description: "Inspect file metadata", capabilities: ["stat"] },
|
|
2539
|
-
{ id: "access", description: "Inspect path access permissions", capabilities: ["access"] }
|
|
2540
|
-
];
|
|
2541
|
-
|
|
2542
|
-
// packages/safe-bash/src/commands/record-buffer.ts
|
|
2425
|
+
// packages/safe-bash/src/contracts/path.ts
|
|
2543
2426
|
init_platform();
|
|
2544
|
-
|
|
2545
|
-
var RecordBuffer = class {
|
|
2546
|
-
constructor(capacity, finalizationCapacity = capacity * 2) {
|
|
2547
|
-
this.capacity = capacity;
|
|
2548
|
-
this.finalizationCapacity = finalizationCapacity;
|
|
2549
|
-
}
|
|
2550
|
-
capacity;
|
|
2551
|
-
finalizationCapacity;
|
|
2552
|
-
#segments = [];
|
|
2553
|
-
#size = 0;
|
|
2554
|
-
#allocated = 0;
|
|
2555
|
-
get size() {
|
|
2556
|
-
return this.#size;
|
|
2557
|
-
}
|
|
2558
|
-
#admit(length) {
|
|
2559
|
-
if (length > this.capacity - this.#size) {
|
|
2560
|
-
throw new FsError("EFBIG", { message: "line buffer limit exceeded" });
|
|
2561
|
-
}
|
|
2562
|
-
}
|
|
2563
|
-
append(bytes, start = 0, end = bytes.length) {
|
|
2564
|
-
this.#admit(end - start);
|
|
2565
|
-
let offset = start;
|
|
2566
|
-
while (offset < end) {
|
|
2567
|
-
let segment = this.#segments.at(-1);
|
|
2568
|
-
const used = this.#size % segmentSize;
|
|
2569
|
-
if (!segment || used === 0) {
|
|
2570
|
-
segment = new Uint8Array(Math.min(segmentSize, this.capacity - this.#allocated));
|
|
2571
|
-
this.#segments.push(segment);
|
|
2572
|
-
this.#allocated += segment.length;
|
|
2573
|
-
}
|
|
2574
|
-
const length = Math.min(end - offset, segment.length - used);
|
|
2575
|
-
segment.set(bytes.subarray(offset, offset + length), used);
|
|
2576
|
-
this.#size += length;
|
|
2577
|
-
offset += length;
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
finish(admit, bytes, start = 0, end = bytes?.length ?? 0) {
|
|
2581
|
-
this.#admit(end - start);
|
|
2582
|
-
const size = this.#size + end - start;
|
|
2583
|
-
admit?.(size);
|
|
2584
|
-
if (size > this.finalizationCapacity - this.#allocated) {
|
|
2585
|
-
throw new FsError("EFBIG", { message: "line finalization buffer limit exceeded" });
|
|
2586
|
-
}
|
|
2587
|
-
const result = new Uint8Array(size);
|
|
2588
|
-
let offset = 0;
|
|
2589
|
-
for (const segment of this.#segments) {
|
|
2590
|
-
const length = Math.min(segment.length, this.#size - offset);
|
|
2591
|
-
result.set(segment.subarray(0, length), offset);
|
|
2592
|
-
offset += length;
|
|
2593
|
-
}
|
|
2594
|
-
if (bytes && end > start) result.set(bytes.subarray(start, end), offset);
|
|
2595
|
-
this.clear();
|
|
2596
|
-
return result;
|
|
2597
|
-
}
|
|
2598
|
-
clear() {
|
|
2599
|
-
this.#segments = [];
|
|
2600
|
-
this.#size = 0;
|
|
2601
|
-
this.#allocated = 0;
|
|
2602
|
-
}
|
|
2603
|
-
};
|
|
2604
|
-
|
|
2605
|
-
// packages/safe-bash/src/commands/internal.ts
|
|
2606
|
-
var encoder3 = new TextEncoder();
|
|
2607
|
-
var decoder2 = new TextDecoder();
|
|
2608
|
-
var bufferLimit = 32 * 1024 * 1024;
|
|
2609
|
-
var UsageError = class extends PublicDiagnostic {
|
|
2610
|
-
};
|
|
2611
|
-
function options(args, short, long = {}, stopAtOperand = false, onOperand) {
|
|
2612
|
-
const flags = /* @__PURE__ */ new Set();
|
|
2613
|
-
const values = /* @__PURE__ */ new Map();
|
|
2614
|
-
const operands = [];
|
|
2615
|
-
const specifications = /* @__PURE__ */ new Map();
|
|
2616
|
-
for (let index = 0; index < short.length; index++) {
|
|
2617
|
-
const key = short[index];
|
|
2618
|
-
specifications.set(key, short[index + 1] === ":");
|
|
2619
|
-
if (short[index + 1] === ":") index++;
|
|
2620
|
-
}
|
|
2621
|
-
let ended = false;
|
|
2622
|
-
for (let index = 0; index < args.length; index++) {
|
|
2623
|
-
const argument = args[index];
|
|
2624
|
-
if (ended || argument === "-" || !argument.startsWith("-")) {
|
|
2625
|
-
operands.push(argument);
|
|
2626
|
-
onOperand?.(index);
|
|
2627
|
-
if (stopAtOperand) ended = true;
|
|
2628
|
-
continue;
|
|
2629
|
-
}
|
|
2630
|
-
if (argument === "--") {
|
|
2631
|
-
ended = true;
|
|
2632
|
-
continue;
|
|
2633
|
-
}
|
|
2634
|
-
if (argument.startsWith("--")) {
|
|
2635
|
-
const equals = argument.indexOf("=");
|
|
2636
|
-
const name = argument.slice(2, equals < 0 ? void 0 : equals);
|
|
2637
|
-
const key = long[name];
|
|
2638
|
-
if (!key || !specifications.has(key)) throw new UsageError(`unrecognized option '${argument}'`);
|
|
2639
|
-
if (specifications.get(key)) {
|
|
2640
|
-
const value2 = equals >= 0 ? argument.slice(equals + 1) : args[++index];
|
|
2641
|
-
if (value2 === void 0) throw new UsageError(`option '--${name}' requires an argument`);
|
|
2642
|
-
values.set(key, [...values.get(key) ?? [], value2]);
|
|
2643
|
-
} else if (equals >= 0) throw new UsageError(`option '--${name}' does not take an argument`);
|
|
2644
|
-
flags.add(key);
|
|
2645
|
-
continue;
|
|
2646
|
-
}
|
|
2647
|
-
for (let offset = 1; offset < argument.length; offset++) {
|
|
2648
|
-
const key = argument[offset];
|
|
2649
|
-
if (!specifications.has(key)) throw new UsageError(`invalid option -- '${key}'`);
|
|
2650
|
-
if (specifications.get(key)) {
|
|
2651
|
-
const value2 = argument.slice(offset + 1) || args[++index];
|
|
2652
|
-
if (value2 === void 0) throw new UsageError(`option requires an argument -- '${key}'`);
|
|
2653
|
-
values.set(key, [...values.get(key) ?? [], value2]);
|
|
2654
|
-
offset = argument.length;
|
|
2655
|
-
}
|
|
2656
|
-
flags.add(key);
|
|
2657
|
-
}
|
|
2658
|
-
}
|
|
2659
|
-
return { flags, values, operands };
|
|
2660
|
-
}
|
|
2661
|
-
function value(parsed, key) {
|
|
2662
|
-
return parsed.values.get(key)?.at(-1);
|
|
2663
|
-
}
|
|
2664
|
-
function integer(text, minimum = 0) {
|
|
2665
|
-
if (!/^[+]?[0-9]+$/u.test(text)) throw new UsageError(`invalid number '${text}'`);
|
|
2666
|
-
const number = Number(text);
|
|
2667
|
-
if (!Number.isSafeInteger(number) || number < minimum) throw new UsageError(`invalid number '${text}'`);
|
|
2668
|
-
return number;
|
|
2669
|
-
}
|
|
2670
|
-
function requireOperands(operands, minimum = 1, maximum = Infinity) {
|
|
2671
|
-
if (operands.length < minimum) throw new UsageError("missing operand");
|
|
2672
|
-
if (operands.length > maximum) throw new UsageError(`extra operand '${operands[maximum]}'`);
|
|
2673
|
-
}
|
|
2674
|
-
function pathOf(context, path) {
|
|
2675
|
-
if (!path) throw new FsError("ENOENT", { path });
|
|
2676
|
-
validatePath(path);
|
|
2677
|
-
validatePath(context.cwd);
|
|
2678
|
-
if (!isAbsolutePath(context.cwd)) throw new FsError("EINVAL", { path: context.cwd, message: "cwd must be absolute" });
|
|
2679
|
-
return isAbsolutePath(path) ? path : `${context.cwd.replace(/\/$/u, "")}/${path}`;
|
|
2680
|
-
}
|
|
2681
|
-
function codeOf(error) {
|
|
2682
|
-
return error instanceof Error && "code" in error ? String(error.code) : void 0;
|
|
2683
|
-
}
|
|
2684
|
-
async function output(context, text) {
|
|
2685
|
-
context.signal.throwIfAborted();
|
|
2686
|
-
await writeBytes(context.stdout, typeof text === "string" ? encoder3.encode(text) : text, context.signal);
|
|
2687
|
-
}
|
|
2688
|
-
async function diagnostic(context, error) {
|
|
2689
|
-
context.signal.throwIfAborted();
|
|
2690
|
-
await writeDiagnostic(context.stderr, `${context.command}: ${publicDiagnosticMessage(error, context.onInternalError)}
|
|
2691
|
-
`, context.signal);
|
|
2692
|
-
}
|
|
2693
|
-
function define(name, handler, failureCode = 1) {
|
|
2694
|
-
return {
|
|
2695
|
-
name,
|
|
2696
|
-
async execute(context) {
|
|
2697
|
-
context.signal.throwIfAborted();
|
|
2698
|
-
try {
|
|
2699
|
-
return await handler(context);
|
|
2700
|
-
} catch (error) {
|
|
2701
|
-
context.signal.throwIfAborted();
|
|
2702
|
-
await diagnostic(context, error);
|
|
2703
|
-
return { exitCode: error instanceof UsageError ? 2 : failureCode };
|
|
2704
|
-
}
|
|
2705
|
-
}
|
|
2706
|
-
};
|
|
2707
|
-
}
|
|
2708
|
-
async function eachOperand(context, operands, operation) {
|
|
2709
|
-
let exitCode = 0;
|
|
2710
|
-
for (const operand of operands) {
|
|
2711
|
-
context.signal.throwIfAborted();
|
|
2712
|
-
try {
|
|
2713
|
-
await operation(operand);
|
|
2714
|
-
} catch (error) {
|
|
2715
|
-
await diagnostic(context, error);
|
|
2716
|
-
exitCode = 1;
|
|
2717
|
-
}
|
|
2718
|
-
}
|
|
2719
|
-
return { exitCode };
|
|
2720
|
-
}
|
|
2721
|
-
async function* input(context, name = "-") {
|
|
2722
|
-
context.signal.throwIfAborted();
|
|
2723
|
-
if (name === "-") {
|
|
2724
|
-
yield* readBytes2(context.stdin, context.signal);
|
|
2725
|
-
} else {
|
|
2726
|
-
await assertInputRequirements(context, [name]);
|
|
2727
|
-
const path = pathOf(context, name);
|
|
2728
|
-
const capabilities = await context.fs.capabilitiesFor?.(path, { signal: context.signal }) ?? context.fs.capabilities;
|
|
2729
|
-
if (context.fs.readStream && capabilities.streamingRead !== false) {
|
|
2730
|
-
let emitted = false;
|
|
2731
|
-
let reading = true;
|
|
2732
|
-
try {
|
|
2733
|
-
for await (const chunk of readBytes2(context.fs.readStream(path, { signal: context.signal }), context.signal)) {
|
|
2734
|
-
reading = false;
|
|
2735
|
-
if (chunk.byteLength) emitted = true;
|
|
2736
|
-
yield chunk;
|
|
2737
|
-
reading = true;
|
|
2738
|
-
}
|
|
2739
|
-
return;
|
|
2740
|
-
} catch (error) {
|
|
2741
|
-
context.signal.throwIfAborted();
|
|
2742
|
-
if (!reading || emitted || !(error instanceof FsError) || error.code !== "ENOTSUP") throw error;
|
|
2743
|
-
}
|
|
2744
|
-
}
|
|
2745
|
-
if (capabilities.read === false) throw new FsError("ENOTSUP", { syscall: "readFile", path });
|
|
2746
|
-
yield* readBytes2({
|
|
2747
|
-
async *[Symbol.asyncIterator]() {
|
|
2748
|
-
const bytes = await context.fs.readFile(path, { signal: context.signal, maxBytes: bufferLimit });
|
|
2749
|
-
context.signal.throwIfAborted();
|
|
2750
|
-
if (bytes.byteLength > bufferLimit) throw new FsError("EFBIG", { syscall: "readFile", path });
|
|
2751
|
-
yield bytes;
|
|
2752
|
-
}
|
|
2753
|
-
}, context.signal);
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
async function assertInputRequirements(context, names) {
|
|
2757
|
-
const files = names.filter((name) => name !== "-");
|
|
2758
|
-
assertCommandRequirements(context, inputRequirements, [files.length ? "file" : "stdin"]);
|
|
2759
|
-
if (!context.fs.capabilitiesFor) return;
|
|
2760
|
-
for (const name of files) {
|
|
2761
|
-
try {
|
|
2762
|
-
const capabilities = await context.fs.capabilitiesFor(pathOf(context, name), { signal: context.signal });
|
|
2763
|
-
assertCommandRequirements(context, inputRequirements, ["file"], capabilities);
|
|
2764
|
-
} catch (error) {
|
|
2765
|
-
context.signal.throwIfAborted();
|
|
2766
|
-
if (codeOf(error) === "ENOTSUP" || codeOf(error) === "EROFS") throw error;
|
|
2767
|
-
}
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
function concatenate(chunks, size = chunks.reduce((sum, chunk) => sum + chunk.length, 0)) {
|
|
2771
|
-
const result = new Uint8Array(size);
|
|
2772
|
-
let offset = 0;
|
|
2773
|
-
for (const chunk of chunks) {
|
|
2774
|
-
result.set(chunk, offset);
|
|
2775
|
-
offset += chunk.length;
|
|
2776
|
-
}
|
|
2777
|
-
return result;
|
|
2778
|
-
}
|
|
2779
|
-
async function* lines(source, separator = 10, admit) {
|
|
2780
|
-
const pending = new RecordBuffer(bufferLimit);
|
|
2781
|
-
try {
|
|
2782
|
-
for await (const chunk of source) {
|
|
2783
|
-
let start = 0;
|
|
2784
|
-
for (let offset = 0; offset < chunk.length; offset++) {
|
|
2785
|
-
if (chunk[offset] !== separator) continue;
|
|
2786
|
-
yield { bytes: pending.finish(admit, chunk, start, offset), terminated: true };
|
|
2787
|
-
start = offset + 1;
|
|
2788
|
-
}
|
|
2789
|
-
pending.append(chunk, start);
|
|
2790
|
-
}
|
|
2791
|
-
if (pending.size) yield { bytes: pending.finish(admit), terminated: false };
|
|
2792
|
-
} finally {
|
|
2793
|
-
pending.clear();
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
function emptyInput() {
|
|
2797
|
-
return toByteSource("");
|
|
2798
|
-
}
|
|
2799
|
-
function replaceArgument(source, pattern, replacement) {
|
|
2800
|
-
if (typeof source === "string") return source.split(pattern).join(replacement);
|
|
2801
|
-
const needle = encoder3.encode(pattern);
|
|
2802
|
-
if (!needle.length) throw new UsageError("replacement string cannot be empty");
|
|
2803
|
-
const substituted = encoder3.encode(replacement);
|
|
2804
|
-
const chunks = [];
|
|
2805
|
-
let start = 0;
|
|
2806
|
-
for (let offset = 0; offset <= source.length - needle.length; ) {
|
|
2807
|
-
if (needle.every((byte, index) => source[offset + index] === byte)) {
|
|
2808
|
-
chunks.push(source.subarray(start, offset), substituted);
|
|
2809
|
-
offset += needle.length;
|
|
2810
|
-
start = offset;
|
|
2811
|
-
} else offset++;
|
|
2812
|
-
}
|
|
2813
|
-
chunks.push(source.subarray(start));
|
|
2814
|
-
return concatenate(chunks);
|
|
2815
|
-
}
|
|
2816
|
-
function escapeBytes(text, zeroOctal = false, bareOctal = false) {
|
|
2817
|
-
if (typeof text === "string") {
|
|
2818
|
-
const chunks = [];
|
|
2819
|
-
const control2 = { a: 7, b: 8, e: 27, E: 27, f: 12, n: 10, r: 13, t: 9, v: 11, "\\": 92 };
|
|
2820
|
-
for (let index = 0; index < text.length; ) {
|
|
2821
|
-
if (text[index] !== "\\" || index + 1 === text.length) {
|
|
2822
|
-
const character = String.fromCodePoint(text.codePointAt(index));
|
|
2823
|
-
chunks.push(encoder3.encode(character));
|
|
2824
|
-
index += character.length;
|
|
2825
|
-
continue;
|
|
2826
|
-
}
|
|
2827
|
-
const next = text[index + 1];
|
|
2828
|
-
if (next === "c") return { bytes: concatenate(chunks), stop: true };
|
|
2829
|
-
if (control2[next] !== void 0) {
|
|
2830
|
-
chunks.push(Uint8Array.of(control2[next]));
|
|
2831
|
-
index += 2;
|
|
2832
|
-
continue;
|
|
2833
|
-
}
|
|
2834
|
-
const rest = text.slice(index + 1);
|
|
2835
|
-
const octal = zeroOctal ? (bareOctal ? /^(?:0([0-7]{0,3})|([1-7][0-7]{0,2}))/u : /^0([0-7]{0,3})/u).exec(rest) : /^([0-7]{1,3})/u.exec(rest);
|
|
2836
|
-
if (octal) {
|
|
2837
|
-
chunks.push(Uint8Array.of(parseInt(octal[1] || octal[2] || "0", 8) & 255));
|
|
2838
|
-
index += 1 + octal[0].length;
|
|
2839
|
-
continue;
|
|
2840
|
-
}
|
|
2841
|
-
const hexadecimal = /^x([0-9a-fA-F]{1,2})/u.exec(rest);
|
|
2842
|
-
if (hexadecimal) {
|
|
2843
|
-
chunks.push(Uint8Array.of(parseInt(hexadecimal[1], 16)));
|
|
2844
|
-
index += 1 + hexadecimal[0].length;
|
|
2845
|
-
continue;
|
|
2846
|
-
}
|
|
2847
|
-
chunks.push(encoder3.encode(`\\${next}`));
|
|
2848
|
-
index += 2;
|
|
2849
|
-
}
|
|
2850
|
-
return { bytes: concatenate(chunks), stop: false };
|
|
2851
|
-
}
|
|
2852
|
-
const source = text;
|
|
2853
|
-
const bytes = new Uint8Array(source.length);
|
|
2854
|
-
const control = { 97: 7, 98: 8, 101: 27, 69: 27, 102: 12, 110: 10, 114: 13, 116: 9, 118: 11, 92: 92 };
|
|
2855
|
-
let size = 0;
|
|
2856
|
-
for (let index = 0; index < source.length; ) {
|
|
2857
|
-
if (source[index] !== 92 || index + 1 === source.length) {
|
|
2858
|
-
bytes[size++] = source[index++];
|
|
2859
|
-
continue;
|
|
2860
|
-
}
|
|
2861
|
-
const next = source[index + 1];
|
|
2862
|
-
if (next === 99) return { bytes: bytes.subarray(0, size), stop: true };
|
|
2863
|
-
if (control[next] !== void 0) {
|
|
2864
|
-
bytes[size++] = control[next];
|
|
2865
|
-
index += 2;
|
|
2866
|
-
continue;
|
|
2867
|
-
}
|
|
2868
|
-
if (zeroOctal ? next === 48 || bareOctal && next >= 49 && next <= 55 : next >= 48 && next <= 55) {
|
|
2869
|
-
let offset = index + (zeroOctal && next === 48 ? 2 : 1);
|
|
2870
|
-
const end = Math.min(source.length, offset + 3);
|
|
2871
|
-
let value2 = 0;
|
|
2872
|
-
while (offset < end && source[offset] >= 48 && source[offset] <= 55) value2 = value2 * 8 + source[offset++] - 48;
|
|
2873
|
-
bytes[size++] = value2 & 255;
|
|
2874
|
-
index = offset;
|
|
2875
|
-
continue;
|
|
2876
|
-
}
|
|
2877
|
-
if (next === 120) {
|
|
2878
|
-
let offset = index + 2;
|
|
2879
|
-
const end = Math.min(source.length, offset + 2);
|
|
2880
|
-
let value2 = 0;
|
|
2881
|
-
while (offset < end) {
|
|
2882
|
-
const digit = source[offset];
|
|
2883
|
-
const number = digit >= 48 && digit <= 57 ? digit - 48 : digit >= 65 && digit <= 70 ? digit - 55 : digit >= 97 && digit <= 102 ? digit - 87 : -1;
|
|
2884
|
-
if (number < 0) break;
|
|
2885
|
-
value2 = value2 * 16 + number;
|
|
2886
|
-
offset++;
|
|
2887
|
-
}
|
|
2888
|
-
if (offset > index + 2) {
|
|
2889
|
-
bytes[size++] = value2;
|
|
2890
|
-
index = offset;
|
|
2891
|
-
continue;
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
bytes[size++] = 92;
|
|
2895
|
-
bytes[size++] = next;
|
|
2896
|
-
index += 2;
|
|
2897
|
-
}
|
|
2898
|
-
return { bytes: bytes.subarray(0, size), stop: false };
|
|
2899
|
-
}
|
|
2427
|
+
import { validatePath, resolvePath, normalizePath, relativePath, isPathWithin, assertPathWithin, basename, dirname, extname, joinPath, isAbsolutePath, posixPath as posixPath2 } from "@poe-platform/safe-fs/core";
|
|
2900
2428
|
|
|
2901
2429
|
export {
|
|
2902
2430
|
__toESM,
|
|
@@ -2918,8 +2446,6 @@ export {
|
|
|
2918
2446
|
isFsError,
|
|
2919
2447
|
toFsError,
|
|
2920
2448
|
FsError,
|
|
2921
|
-
evaluateCommandSupport,
|
|
2922
|
-
assertCommandRequirements,
|
|
2923
2449
|
outputFailure,
|
|
2924
2450
|
createBytePipe,
|
|
2925
2451
|
writeText,
|
|
@@ -2945,35 +2471,7 @@ export {
|
|
|
2945
2471
|
dirname,
|
|
2946
2472
|
joinPath,
|
|
2947
2473
|
isAbsolutePath,
|
|
2948
|
-
posixPath2 as posixPath
|
|
2949
|
-
escapeText,
|
|
2950
|
-
writeDiagnostic,
|
|
2951
|
-
inputRequirements,
|
|
2952
|
-
textOutputRequirements,
|
|
2953
|
-
pwdRequirements,
|
|
2954
|
-
predicateRequirements,
|
|
2955
|
-
RecordBuffer,
|
|
2956
|
-
encoder3 as encoder,
|
|
2957
|
-
decoder2 as decoder,
|
|
2958
|
-
bufferLimit,
|
|
2959
|
-
UsageError,
|
|
2960
|
-
options,
|
|
2961
|
-
value,
|
|
2962
|
-
integer,
|
|
2963
|
-
requireOperands,
|
|
2964
|
-
pathOf,
|
|
2965
|
-
codeOf,
|
|
2966
|
-
output,
|
|
2967
|
-
diagnostic,
|
|
2968
|
-
define,
|
|
2969
|
-
eachOperand,
|
|
2970
|
-
input,
|
|
2971
|
-
assertInputRequirements,
|
|
2972
|
-
concatenate,
|
|
2973
|
-
lines,
|
|
2974
|
-
emptyInput,
|
|
2975
|
-
replaceArgument,
|
|
2976
|
-
escapeBytes
|
|
2474
|
+
posixPath2 as posixPath
|
|
2977
2475
|
};
|
|
2978
2476
|
/*! Bundled license information:
|
|
2979
2477
|
|
|
@@ -2988,4 +2486,4 @@ buffer/index.js:
|
|
|
2988
2486
|
* @license MIT
|
|
2989
2487
|
*)
|
|
2990
2488
|
*/
|
|
2991
|
-
//# sourceMappingURL=chunk-
|
|
2489
|
+
//# sourceMappingURL=chunk-L2GZSOSJ.js.map
|