sandboxedjs 0.1.24 → 0.1.25
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/index.cjs +142 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +142 -109
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -853,8 +853,8 @@ function splitTopLevel(s, sep) {
|
|
|
853
853
|
out.push(cur);
|
|
854
854
|
return out;
|
|
855
855
|
}
|
|
856
|
-
function compileBracket(pattern,
|
|
857
|
-
let i =
|
|
856
|
+
function compileBracket(pattern, start2) {
|
|
857
|
+
let i = start2 + 1;
|
|
858
858
|
let negate = false;
|
|
859
859
|
if (pattern[i] === "!" || pattern[i] === "^") {
|
|
860
860
|
negate = true;
|
|
@@ -1206,7 +1206,7 @@ var init_arith = __esm({
|
|
|
1206
1206
|
return value;
|
|
1207
1207
|
}
|
|
1208
1208
|
assignment() {
|
|
1209
|
-
const
|
|
1209
|
+
const start2 = this.i;
|
|
1210
1210
|
const t = this.peek();
|
|
1211
1211
|
if (t.kind === "name") {
|
|
1212
1212
|
const next = this.toks[this.i + 1];
|
|
@@ -1256,7 +1256,7 @@ var init_arith = __esm({
|
|
|
1256
1256
|
return this.writeVar(t.value, Math.trunc(result));
|
|
1257
1257
|
}
|
|
1258
1258
|
}
|
|
1259
|
-
this.i =
|
|
1259
|
+
this.i = start2;
|
|
1260
1260
|
return this.ternary();
|
|
1261
1261
|
}
|
|
1262
1262
|
ternary() {
|
|
@@ -1549,7 +1549,7 @@ function splitBraceAlternatives(body) {
|
|
|
1549
1549
|
function expandSequence(body) {
|
|
1550
1550
|
const numeric = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/.exec(body);
|
|
1551
1551
|
if (numeric) {
|
|
1552
|
-
const
|
|
1552
|
+
const start2 = Number(numeric[1]);
|
|
1553
1553
|
const end = Number(numeric[2]);
|
|
1554
1554
|
let step = numeric[3] !== void 0 ? Math.abs(Number(numeric[3])) : 1;
|
|
1555
1555
|
if (step === 0) step = 1;
|
|
@@ -1558,18 +1558,18 @@ function expandSequence(body) {
|
|
|
1558
1558
|
/^-?0\d/.test(numeric[2]) ? numeric[2].replace("-", "").length : 0
|
|
1559
1559
|
);
|
|
1560
1560
|
const out = [];
|
|
1561
|
-
if (
|
|
1562
|
-
else for (let i =
|
|
1561
|
+
if (start2 <= end) for (let i = start2; i <= end; i += step) out.push(padNumber(i, width));
|
|
1562
|
+
else for (let i = start2; i >= end; i -= step) out.push(padNumber(i, width));
|
|
1563
1563
|
return out;
|
|
1564
1564
|
}
|
|
1565
1565
|
const alpha = /^([A-Za-z])\.\.([A-Za-z])(?:\.\.(-?\d+))?$/.exec(body);
|
|
1566
1566
|
if (alpha) {
|
|
1567
|
-
const
|
|
1567
|
+
const start2 = alpha[1].charCodeAt(0);
|
|
1568
1568
|
const end = alpha[2].charCodeAt(0);
|
|
1569
1569
|
const step = alpha[3] !== void 0 ? Math.abs(Number(alpha[3])) || 1 : 1;
|
|
1570
1570
|
const out = [];
|
|
1571
|
-
if (
|
|
1572
|
-
else for (let i =
|
|
1571
|
+
if (start2 <= end) for (let i = start2; i <= end; i += step) out.push(String.fromCharCode(i));
|
|
1572
|
+
else for (let i = start2; i >= end; i -= step) out.push(String.fromCharCode(i));
|
|
1573
1573
|
return out;
|
|
1574
1574
|
}
|
|
1575
1575
|
return null;
|
|
@@ -1679,10 +1679,10 @@ async function expandFragments(word, ctx, opts = {}) {
|
|
|
1679
1679
|
flushLiteral();
|
|
1680
1680
|
return out;
|
|
1681
1681
|
}
|
|
1682
|
-
async function expandDoubleQuoted(word,
|
|
1682
|
+
async function expandDoubleQuoted(word, start2, ctx, opts) {
|
|
1683
1683
|
const out = [];
|
|
1684
1684
|
let literal = "";
|
|
1685
|
-
let i =
|
|
1685
|
+
let i = start2;
|
|
1686
1686
|
const flush = () => {
|
|
1687
1687
|
if (literal !== "") {
|
|
1688
1688
|
out.push({ text: literal, split: false, glob: false });
|
|
@@ -1982,9 +1982,9 @@ function stripAffix(value, pattern, op, ctx) {
|
|
|
1982
1982
|
function substitute(value, pattern, replacement, opts) {
|
|
1983
1983
|
const matchOpts = { pathname: false, dot: true, extglob: opts.extglob };
|
|
1984
1984
|
const chars = [...value];
|
|
1985
|
-
const matchAt = (
|
|
1986
|
-
for (let end = chars.length; end >=
|
|
1987
|
-
if (fnmatch(pattern, chars.slice(
|
|
1985
|
+
const matchAt = (start2) => {
|
|
1986
|
+
for (let end = chars.length; end >= start2; end--) {
|
|
1987
|
+
if (fnmatch(pattern, chars.slice(start2, end).join(""), matchOpts)) return end;
|
|
1988
1988
|
}
|
|
1989
1989
|
return -1;
|
|
1990
1990
|
};
|
|
@@ -1993,9 +1993,9 @@ function substitute(value, pattern, replacement, opts) {
|
|
|
1993
1993
|
return end < 0 ? value : replacement + chars.slice(end).join("");
|
|
1994
1994
|
}
|
|
1995
1995
|
if (opts.anchorEnd) {
|
|
1996
|
-
for (let
|
|
1997
|
-
if (fnmatch(pattern, chars.slice(
|
|
1998
|
-
return chars.slice(0,
|
|
1996
|
+
for (let start2 = 0; start2 <= chars.length; start2++) {
|
|
1997
|
+
if (fnmatch(pattern, chars.slice(start2).join(""), matchOpts)) {
|
|
1998
|
+
return chars.slice(0, start2).join("") + replacement;
|
|
1999
1999
|
}
|
|
2000
2000
|
}
|
|
2001
2001
|
return value;
|
|
@@ -2854,18 +2854,18 @@ function builtinEcho({ argv, io }) {
|
|
|
2854
2854
|
function builtinPrintf({ argv, io }) {
|
|
2855
2855
|
const args = argv.slice(1);
|
|
2856
2856
|
let varName;
|
|
2857
|
-
let
|
|
2857
|
+
let start2 = 0;
|
|
2858
2858
|
if (args[0] === "-v" && args[1] !== void 0) {
|
|
2859
2859
|
varName = args[1];
|
|
2860
|
-
|
|
2860
|
+
start2 = 2;
|
|
2861
2861
|
}
|
|
2862
|
-
const format = args[
|
|
2862
|
+
const format = args[start2];
|
|
2863
2863
|
if (format === void 0) {
|
|
2864
2864
|
io.stderr.write("printf: usage: printf [-v var] format [arguments]\n");
|
|
2865
2865
|
return 2;
|
|
2866
2866
|
}
|
|
2867
2867
|
try {
|
|
2868
|
-
const text2 = formatPrintf(format, args.slice(
|
|
2868
|
+
const text2 = formatPrintf(format, args.slice(start2 + 1));
|
|
2869
2869
|
if (varName) return 0;
|
|
2870
2870
|
io.stdout.write(text2);
|
|
2871
2871
|
return 0;
|
|
@@ -3921,9 +3921,9 @@ function builtinHistory({ shell, argv, io }) {
|
|
|
3921
3921
|
return 0;
|
|
3922
3922
|
}
|
|
3923
3923
|
const limit = Number(args.find((a) => /^\d+$/.test(a)) ?? shell.history.length);
|
|
3924
|
-
const
|
|
3925
|
-
shell.history.slice(
|
|
3926
|
-
io.stdout.write(`${String(
|
|
3924
|
+
const start2 = Math.max(0, shell.history.length - limit);
|
|
3925
|
+
shell.history.slice(start2).forEach((entry, idx) => {
|
|
3926
|
+
io.stdout.write(`${String(start2 + idx + 1).padStart(5)} ${entry}
|
|
3927
3927
|
`);
|
|
3928
3928
|
});
|
|
3929
3929
|
return 0;
|
|
@@ -4692,8 +4692,8 @@ var Vfs = class {
|
|
|
4692
4692
|
/** Depth-first walk yielding absolute paths. Symlinks are not followed. */
|
|
4693
4693
|
*walk(abs, opts = {}) {
|
|
4694
4694
|
const { includeSelf = true, cred, maxDepth = Infinity } = opts;
|
|
4695
|
-
const
|
|
4696
|
-
if (includeSelf) yield
|
|
4695
|
+
const start2 = clean(abs);
|
|
4696
|
+
if (includeSelf) yield start2;
|
|
4697
4697
|
const recurse = (dir3, depth) => {
|
|
4698
4698
|
if (depth > maxDepth) return [];
|
|
4699
4699
|
let names;
|
|
@@ -4717,11 +4717,11 @@ var Vfs = class {
|
|
|
4717
4717
|
};
|
|
4718
4718
|
let st = null;
|
|
4719
4719
|
try {
|
|
4720
|
-
st = this.lstat(
|
|
4720
|
+
st = this.lstat(start2);
|
|
4721
4721
|
} catch {
|
|
4722
4722
|
return;
|
|
4723
4723
|
}
|
|
4724
|
-
if (st.isDirectory()) yield* recurse(
|
|
4724
|
+
if (st.isDirectory()) yield* recurse(start2, 1);
|
|
4725
4725
|
}
|
|
4726
4726
|
/** Recursive copy used by `cp -r` and the container's `copyIn` helper. */
|
|
4727
4727
|
copyTree(from, to, cred) {
|
|
@@ -5249,8 +5249,8 @@ var ProcessTable = class {
|
|
|
5249
5249
|
this.map.clear();
|
|
5250
5250
|
}
|
|
5251
5251
|
};
|
|
5252
|
-
function resetPidCounter(
|
|
5253
|
-
nextPid =
|
|
5252
|
+
function resetPidCounter(start2 = 1) {
|
|
5253
|
+
nextPid = start2;
|
|
5254
5254
|
}
|
|
5255
5255
|
|
|
5256
5256
|
// src/kernel/users.ts
|
|
@@ -6528,8 +6528,8 @@ function createProcProvider(kernel) {
|
|
|
6528
6528
|
loadavg: () => textFile(() => {
|
|
6529
6529
|
const running = kernel.procs.list().filter((p) => p.state === "R").length;
|
|
6530
6530
|
const total = kernel.procs.list().length;
|
|
6531
|
-
const
|
|
6532
|
-
return `${
|
|
6531
|
+
const load = (running / kernel.cpus).toFixed(2);
|
|
6532
|
+
return `${load} ${load} ${load} ${running}/${total} ${kernel.procs.list().length + 1}
|
|
6533
6533
|
`;
|
|
6534
6534
|
}),
|
|
6535
6535
|
meminfo: () => textFile(() => {
|
|
@@ -7029,7 +7029,7 @@ var Lexer = class _Lexer {
|
|
|
7029
7029
|
return null;
|
|
7030
7030
|
}
|
|
7031
7031
|
readWord() {
|
|
7032
|
-
const
|
|
7032
|
+
const start2 = this.pos;
|
|
7033
7033
|
let out = "";
|
|
7034
7034
|
while (this.pos < this.src.length) {
|
|
7035
7035
|
const ch = this.src[this.pos];
|
|
@@ -7079,10 +7079,10 @@ var Lexer = class _Lexer {
|
|
|
7079
7079
|
out = this.src[this.pos] ?? "";
|
|
7080
7080
|
this.pos++;
|
|
7081
7081
|
}
|
|
7082
|
-
this.push({ type: "word", value: out, pos:
|
|
7082
|
+
this.push({ type: "word", value: out, pos: start2 });
|
|
7083
7083
|
}
|
|
7084
7084
|
readDoubleQuoted() {
|
|
7085
|
-
const
|
|
7085
|
+
const start2 = this.pos;
|
|
7086
7086
|
this.pos++;
|
|
7087
7087
|
let out = '"';
|
|
7088
7088
|
while (this.pos < this.src.length) {
|
|
@@ -7113,14 +7113,14 @@ var Lexer = class _Lexer {
|
|
|
7113
7113
|
out += ch;
|
|
7114
7114
|
this.pos++;
|
|
7115
7115
|
}
|
|
7116
|
-
throw new IncompleteInputError("unexpected EOF while looking for matching `\"'",
|
|
7116
|
+
throw new IncompleteInputError("unexpected EOF while looking for matching `\"'", start2);
|
|
7117
7117
|
}
|
|
7118
7118
|
/**
|
|
7119
7119
|
* Consume a balanced `$( ... )` or `${ ... }`, honouring nesting and quotes
|
|
7120
7120
|
* inside. `prefix` is emitted before the opening delimiter.
|
|
7121
7121
|
*/
|
|
7122
7122
|
readBalanced(open, close, openIdx, prefix) {
|
|
7123
|
-
const
|
|
7123
|
+
const start2 = this.pos;
|
|
7124
7124
|
let depth = 0;
|
|
7125
7125
|
let i = openIdx;
|
|
7126
7126
|
for (; i < this.src.length; i++) {
|
|
@@ -7131,7 +7131,7 @@ var Lexer = class _Lexer {
|
|
|
7131
7131
|
}
|
|
7132
7132
|
if (c === "'" && open === "(") {
|
|
7133
7133
|
const end = this.src.indexOf("'", i + 1);
|
|
7134
|
-
if (end < 0) throw new IncompleteInputError("unexpected EOF in command substitution",
|
|
7134
|
+
if (end < 0) throw new IncompleteInputError("unexpected EOF in command substitution", start2);
|
|
7135
7135
|
i = end;
|
|
7136
7136
|
continue;
|
|
7137
7137
|
}
|
|
@@ -7149,7 +7149,7 @@ var Lexer = class _Lexer {
|
|
|
7149
7149
|
if (depth === 0) break;
|
|
7150
7150
|
}
|
|
7151
7151
|
}
|
|
7152
|
-
if (i >= this.src.length) throw new IncompleteInputError(`unexpected EOF while looking for matching \`${close}'`,
|
|
7152
|
+
if (i >= this.src.length) throw new IncompleteInputError(`unexpected EOF while looking for matching \`${close}'`, start2);
|
|
7153
7153
|
const text2 = prefix + this.src.slice(openIdx, i + 1);
|
|
7154
7154
|
this.pos = i + 1;
|
|
7155
7155
|
return text2;
|
|
@@ -11194,9 +11194,9 @@ var ScriptParser = class {
|
|
|
11194
11194
|
}
|
|
11195
11195
|
parseRange() {
|
|
11196
11196
|
this.skipBlanks();
|
|
11197
|
-
const
|
|
11198
|
-
if (!
|
|
11199
|
-
let range = { start, negated: false };
|
|
11197
|
+
const start2 = this.parseAddress();
|
|
11198
|
+
if (!start2) return { negated: this.parseNegation() };
|
|
11199
|
+
let range = { start: start2, negated: false };
|
|
11200
11200
|
if (this.src[this.i] === ",") {
|
|
11201
11201
|
this.i++;
|
|
11202
11202
|
this.skipBlanks();
|
|
@@ -11405,8 +11405,8 @@ function toJsRegex(pattern, extended) {
|
|
|
11405
11405
|
}
|
|
11406
11406
|
return out;
|
|
11407
11407
|
}
|
|
11408
|
-
function findBracketEnd(pattern,
|
|
11409
|
-
let i =
|
|
11408
|
+
function findBracketEnd(pattern, start2) {
|
|
11409
|
+
let i = start2 + 1;
|
|
11410
11410
|
if (pattern[i] === "^") i++;
|
|
11411
11411
|
if (pattern[i] === "]") i++;
|
|
11412
11412
|
while (i < pattern.length) {
|
|
@@ -12997,14 +12997,14 @@ var Interpreter = class {
|
|
|
12997
12997
|
}
|
|
12998
12998
|
case "substr": {
|
|
12999
12999
|
const source = [...str(0)];
|
|
13000
|
-
let
|
|
13000
|
+
let start2 = Math.round(num(1));
|
|
13001
13001
|
let length = args.length > 2 ? Math.round(num(2)) : Infinity;
|
|
13002
|
-
if (
|
|
13003
|
-
if (Number.isFinite(length)) length +=
|
|
13004
|
-
|
|
13002
|
+
if (start2 < 1) {
|
|
13003
|
+
if (Number.isFinite(length)) length += start2 - 1;
|
|
13004
|
+
start2 = 1;
|
|
13005
13005
|
}
|
|
13006
13006
|
if (length <= 0) return Value.fromString("");
|
|
13007
|
-
return Value.fromString(source.slice(
|
|
13007
|
+
return Value.fromString(source.slice(start2 - 1, Number.isFinite(length) ? start2 - 1 + length : void 0).join(""));
|
|
13008
13008
|
}
|
|
13009
13009
|
case "index": {
|
|
13010
13010
|
const haystack = [...str(0)];
|
|
@@ -13422,8 +13422,8 @@ function translateEre(pattern) {
|
|
|
13422
13422
|
}
|
|
13423
13423
|
return out;
|
|
13424
13424
|
}
|
|
13425
|
-
function findClassEnd(pattern,
|
|
13426
|
-
let i =
|
|
13425
|
+
function findClassEnd(pattern, start2) {
|
|
13426
|
+
let i = start2 + 1;
|
|
13427
13427
|
if (pattern[i] === "^") i++;
|
|
13428
13428
|
if (pattern[i] === "]") i++;
|
|
13429
13429
|
while (i < pattern.length) {
|
|
@@ -13753,10 +13753,10 @@ var sort = defineCommand({
|
|
|
13753
13753
|
const fieldOf = (line, spec) => {
|
|
13754
13754
|
const m = /^(\d+)(?:\.(\d+))?([a-zA-Z]*)(?:,(\d+)(?:\.(\d+))?([a-zA-Z]*))?$/.exec(spec);
|
|
13755
13755
|
if (!m) return line;
|
|
13756
|
-
const
|
|
13756
|
+
const start2 = Number(m[1]) - 1;
|
|
13757
13757
|
const end = m[4] !== void 0 ? Number(m[4]) : void 0;
|
|
13758
13758
|
const fields = separator === void 0 ? line.trim().split(/\s+/) : line.split(separator);
|
|
13759
|
-
const slice = fields.slice(
|
|
13759
|
+
const slice = fields.slice(start2, end === void 0 ? void 0 : end);
|
|
13760
13760
|
return slice.join(separator ?? " ");
|
|
13761
13761
|
};
|
|
13762
13762
|
const normalize3 = (line) => {
|
|
@@ -13907,9 +13907,9 @@ function parseRanges(spec) {
|
|
|
13907
13907
|
return spec.split(",").map((part) => {
|
|
13908
13908
|
const m = /^(\d*)-(\d*)$/.exec(part);
|
|
13909
13909
|
if (m) {
|
|
13910
|
-
const
|
|
13910
|
+
const start2 = m[1] === "" ? 1 : Number(m[1]);
|
|
13911
13911
|
const end = m[2] === "" ? Infinity : Number(m[2]);
|
|
13912
|
-
return [
|
|
13912
|
+
return [start2, end];
|
|
13913
13913
|
}
|
|
13914
13914
|
const n = Number(part);
|
|
13915
13915
|
return [n, n];
|
|
@@ -13918,7 +13918,7 @@ function parseRanges(spec) {
|
|
|
13918
13918
|
function pick(items, ranges, complement) {
|
|
13919
13919
|
const selected = items.filter((_, idx) => {
|
|
13920
13920
|
const position = idx + 1;
|
|
13921
|
-
const inRange = ranges.some(([
|
|
13921
|
+
const inRange = ranges.some(([start2, end]) => position >= start2 && position <= end);
|
|
13922
13922
|
return complement ? !inRange : inRange;
|
|
13923
13923
|
});
|
|
13924
13924
|
return selected;
|
|
@@ -14022,9 +14022,9 @@ function expandSet(spec) {
|
|
|
14022
14022
|
continue;
|
|
14023
14023
|
}
|
|
14024
14024
|
if (spec[i + 1] === "-" && i + 2 < spec.length && spec[i + 2] !== "]") {
|
|
14025
|
-
const
|
|
14025
|
+
const start2 = spec.charCodeAt(i);
|
|
14026
14026
|
const end = spec.charCodeAt(i + 2);
|
|
14027
|
-
for (let c =
|
|
14027
|
+
for (let c = start2; c <= end; c++) out.push(String.fromCharCode(c));
|
|
14028
14028
|
i += 3;
|
|
14029
14029
|
continue;
|
|
14030
14030
|
}
|
|
@@ -14627,10 +14627,10 @@ var grep = defineCommand({
|
|
|
14627
14627
|
const emitted = /* @__PURE__ */ new Set();
|
|
14628
14628
|
let lastPrinted = -2;
|
|
14629
14629
|
for (const index of matched) {
|
|
14630
|
-
const
|
|
14630
|
+
const start2 = Math.max(0, index - before);
|
|
14631
14631
|
const end = Math.min(lines.length - 1, index + after);
|
|
14632
|
-
if ((before || after) && lastPrinted >= 0 &&
|
|
14633
|
-
for (let i =
|
|
14632
|
+
if ((before || after) && lastPrinted >= 0 && start2 > lastPrinted + 1) ctx.line("--");
|
|
14633
|
+
for (let i = start2; i <= end; i++) {
|
|
14634
14634
|
if (emitted.has(i)) continue;
|
|
14635
14635
|
emitted.add(i);
|
|
14636
14636
|
const isMatchLine = matched.includes(i);
|
|
@@ -15046,8 +15046,8 @@ var diff = defineCommand({
|
|
|
15046
15046
|
return 1;
|
|
15047
15047
|
}
|
|
15048
15048
|
});
|
|
15049
|
-
function formatRange(
|
|
15050
|
-
return count <= 1 ? String(
|
|
15049
|
+
function formatRange(start2, count) {
|
|
15050
|
+
return count <= 1 ? String(start2) : `${start2},${start2 + count - 1}`;
|
|
15051
15051
|
}
|
|
15052
15052
|
function diffLines(a, b) {
|
|
15053
15053
|
const n = a.length;
|
|
@@ -15104,11 +15104,11 @@ function buildHunks(edits, a, b, context) {
|
|
|
15104
15104
|
i++;
|
|
15105
15105
|
continue;
|
|
15106
15106
|
}
|
|
15107
|
-
let
|
|
15107
|
+
let start2 = Math.max(0, i - context);
|
|
15108
15108
|
let end = i;
|
|
15109
15109
|
while (end < edits.length && (changed[end] || edits.slice(end, end + context + 1).some((_, k) => changed[end + k]))) end++;
|
|
15110
15110
|
end = Math.min(edits.length, end + context);
|
|
15111
|
-
const slice = edits.slice(
|
|
15111
|
+
const slice = edits.slice(start2, end);
|
|
15112
15112
|
const aStart = slice.find((e) => e.op !== "insert")?.aIndex ?? 0;
|
|
15113
15113
|
const bStart = slice.find((e) => e.op !== "delete")?.bIndex ?? 0;
|
|
15114
15114
|
const lines = [];
|
|
@@ -18376,11 +18376,11 @@ function safeTarget(destination, name) {
|
|
|
18376
18376
|
function stripPackageRoot(name) {
|
|
18377
18377
|
return name.replace(/^\.\//, "").replace(/^package\//, "").replace(/\/$/, "");
|
|
18378
18378
|
}
|
|
18379
|
-
function text(bytes,
|
|
18380
|
-
return new TextDecoder().decode(bytes.subarray(
|
|
18379
|
+
function text(bytes, start2, length) {
|
|
18380
|
+
return new TextDecoder().decode(bytes.subarray(start2, start2 + length)).replace(/\0.*$/, "").trim();
|
|
18381
18381
|
}
|
|
18382
|
-
function octal(bytes,
|
|
18383
|
-
return parseInt(text(bytes,
|
|
18382
|
+
function octal(bytes, start2, length) {
|
|
18383
|
+
return parseInt(text(bytes, start2, length).replace(/^0+/, "") || "0", 8);
|
|
18384
18384
|
}
|
|
18385
18385
|
function parsePax(data) {
|
|
18386
18386
|
const value = new TextDecoder().decode(data);
|
|
@@ -20097,8 +20097,8 @@ var CommonJsEngine = class {
|
|
|
20097
20097
|
throw this.moduleNotFound(specifier, importer);
|
|
20098
20098
|
}
|
|
20099
20099
|
load(filename, parent, isMain) {
|
|
20100
|
-
const
|
|
20101
|
-
if (
|
|
20100
|
+
const cached = this.cache.get(filename);
|
|
20101
|
+
if (cached) return cached;
|
|
20102
20102
|
const module = {
|
|
20103
20103
|
id: isMain ? "." : filename,
|
|
20104
20104
|
filename,
|
|
@@ -20331,8 +20331,8 @@ ${code}
|
|
|
20331
20331
|
}
|
|
20332
20332
|
}
|
|
20333
20333
|
readManifest(root) {
|
|
20334
|
-
const
|
|
20335
|
-
if (
|
|
20334
|
+
const cached = this.manifests.get(root);
|
|
20335
|
+
if (cached !== void 0) return cached;
|
|
20336
20336
|
let manifest = null;
|
|
20337
20337
|
try {
|
|
20338
20338
|
manifest = JSON.parse(this.readText(join(root, "package.json")));
|
|
@@ -20394,8 +20394,8 @@ function namespaceOf(exports) {
|
|
|
20394
20394
|
}
|
|
20395
20395
|
const target = exports;
|
|
20396
20396
|
if (target.__esModule) return target;
|
|
20397
|
-
const
|
|
20398
|
-
if (
|
|
20397
|
+
const cached = namespaces.get(target);
|
|
20398
|
+
if (cached) return cached;
|
|
20399
20399
|
const namespace = {};
|
|
20400
20400
|
for (const key of ownKeys(target)) {
|
|
20401
20401
|
if (key === "default" || key === "__esModule") continue;
|
|
@@ -20760,9 +20760,9 @@ function createCryptoModule() {
|
|
|
20760
20760
|
},
|
|
20761
20761
|
randomFill(target, offset = 0, size, callback) {
|
|
20762
20762
|
const done = [offset, size, callback].find((value) => typeof value === "function");
|
|
20763
|
-
const
|
|
20764
|
-
const length = typeof size === "number" ? size : target.length -
|
|
20765
|
-
cryptoObject.getRandomValues(target.subarray(
|
|
20763
|
+
const start2 = typeof offset === "number" ? offset : 0;
|
|
20764
|
+
const length = typeof size === "number" ? size : target.length - start2;
|
|
20765
|
+
cryptoObject.getRandomValues(target.subarray(start2, start2 + length));
|
|
20766
20766
|
queueMicrotask(() => done?.(null, target));
|
|
20767
20767
|
},
|
|
20768
20768
|
hash(algorithm, data, encoding = "hex") {
|
|
@@ -20859,7 +20859,7 @@ function createChildProcessModule(spawnChild, defaultCwd) {
|
|
|
20859
20859
|
const shell = typeof options.shell === "string" ? options.shell : "/bin/sh";
|
|
20860
20860
|
return { file: shell, args: ["-c", command] };
|
|
20861
20861
|
};
|
|
20862
|
-
const
|
|
20862
|
+
const start2 = (file3, args, options) => {
|
|
20863
20863
|
const resolved = options.shell ? throughShell([file3, ...args].join(" "), options) : { file: file3, args };
|
|
20864
20864
|
const handle = spawnChild({
|
|
20865
20865
|
command: resolved.file,
|
|
@@ -20870,8 +20870,8 @@ function createChildProcessModule(spawnChild, defaultCwd) {
|
|
|
20870
20870
|
return new ChildProcess(handle, resolved.file, resolved.args);
|
|
20871
20871
|
};
|
|
20872
20872
|
const spawn = (file3, args = [], options = {}) => {
|
|
20873
|
-
if (!Array.isArray(args)) return
|
|
20874
|
-
return
|
|
20873
|
+
if (!Array.isArray(args)) return start2(file3, [], args);
|
|
20874
|
+
return start2(file3, args, options);
|
|
20875
20875
|
};
|
|
20876
20876
|
const collect = (child, options, callback) => {
|
|
20877
20877
|
if (!callback) return child;
|
|
@@ -20899,12 +20899,12 @@ ${err.join("")}`),
|
|
|
20899
20899
|
const exec = (command, options = {}, callback) => {
|
|
20900
20900
|
const [opts, cb] = normalize2(options, callback);
|
|
20901
20901
|
const { file: file3, args } = throughShell(command, opts);
|
|
20902
|
-
return collect(
|
|
20902
|
+
return collect(start2(file3, args, { ...opts, shell: false }), opts, cb);
|
|
20903
20903
|
};
|
|
20904
20904
|
const execFile = (file3, args = [], options = {}, callback) => {
|
|
20905
20905
|
const list = Array.isArray(args) ? args : [];
|
|
20906
20906
|
const [opts, cb] = Array.isArray(args) ? normalize2(options, callback) : normalize2(args, options);
|
|
20907
|
-
return collect(
|
|
20907
|
+
return collect(start2(file3, list, opts), opts, cb);
|
|
20908
20908
|
};
|
|
20909
20909
|
return {
|
|
20910
20910
|
spawn,
|
|
@@ -21380,9 +21380,9 @@ function createFsModule(volume, cwd, stdinPath) {
|
|
|
21380
21380
|
readSync: (fd, target, offset, length, position) => {
|
|
21381
21381
|
const file3 = requiredFd(fds, fd);
|
|
21382
21382
|
const source = volume.readFileSync(resolveLinks(volume, file3.path));
|
|
21383
|
-
const
|
|
21384
|
-
const count = Math.max(0, Math.min(length, source.length -
|
|
21385
|
-
target.set(source.subarray(
|
|
21383
|
+
const start2 = position ?? file3.position;
|
|
21384
|
+
const count = Math.max(0, Math.min(length, source.length - start2));
|
|
21385
|
+
target.set(source.subarray(start2, start2 + count), offset);
|
|
21386
21386
|
if (position == null) file3.position += count;
|
|
21387
21387
|
return count;
|
|
21388
21388
|
},
|
|
@@ -21391,12 +21391,12 @@ function createFsModule(volume, cwd, stdinPath) {
|
|
|
21391
21391
|
const input = bytes(data);
|
|
21392
21392
|
const chunk = typeof data === "string" ? input : input.subarray(offset ?? 0, (offset ?? 0) + (length ?? input.length));
|
|
21393
21393
|
const old = volume.readFileSync(file3.path);
|
|
21394
|
-
const
|
|
21395
|
-
const next = new Uint8Array(Math.max(old.length,
|
|
21394
|
+
const start2 = file3.flags.startsWith("a") ? old.length : position ?? file3.position;
|
|
21395
|
+
const next = new Uint8Array(Math.max(old.length, start2 + chunk.length));
|
|
21396
21396
|
next.set(old);
|
|
21397
|
-
next.set(chunk,
|
|
21397
|
+
next.set(chunk, start2);
|
|
21398
21398
|
volume.writeFileSync(file3.path, next);
|
|
21399
|
-
if (position == null) file3.position =
|
|
21399
|
+
if (position == null) file3.position = start2 + chunk.length;
|
|
21400
21400
|
return chunk.length;
|
|
21401
21401
|
},
|
|
21402
21402
|
createReadStream: (path) => {
|
|
@@ -22324,29 +22324,61 @@ var MemoryVolume = class {
|
|
|
22324
22324
|
};
|
|
22325
22325
|
|
|
22326
22326
|
// src/runtime/host-esbuild.ts
|
|
22327
|
-
var
|
|
22328
|
-
function
|
|
22329
|
-
|
|
22330
|
-
|
|
22331
|
-
|
|
22332
|
-
|
|
22333
|
-
return
|
|
22327
|
+
var ASYNC_API = ["transform", "build", "context", "formatMessages", "analyzeMetafile"];
|
|
22328
|
+
function createHostEsbuild() {
|
|
22329
|
+
let loading = null;
|
|
22330
|
+
let started = null;
|
|
22331
|
+
const ensure = async () => {
|
|
22332
|
+
loading ??= start().then((api) => started = api);
|
|
22333
|
+
return loading;
|
|
22334
|
+
};
|
|
22335
|
+
const module = new Proxy({}, {
|
|
22336
|
+
get(_target, key) {
|
|
22337
|
+
if (typeof key !== "string") return void 0;
|
|
22338
|
+
if (ASYNC_API.includes(key)) {
|
|
22339
|
+
return async (...args) => {
|
|
22340
|
+
const api = await ensure();
|
|
22341
|
+
if (!api) throw esbuildUnavailable();
|
|
22342
|
+
return api[key](...args);
|
|
22343
|
+
};
|
|
22344
|
+
}
|
|
22345
|
+
if (key === "stop") return stop;
|
|
22346
|
+
return started?.[key];
|
|
22347
|
+
},
|
|
22348
|
+
has: (_target, key) => typeof key === "string"
|
|
22334
22349
|
});
|
|
22335
|
-
|
|
22350
|
+
function stop() {
|
|
22351
|
+
try {
|
|
22352
|
+
started?.stop?.();
|
|
22353
|
+
} catch {
|
|
22354
|
+
}
|
|
22355
|
+
started = null;
|
|
22356
|
+
}
|
|
22357
|
+
return { module, stop };
|
|
22336
22358
|
}
|
|
22337
|
-
async function
|
|
22359
|
+
async function start() {
|
|
22338
22360
|
if (typeof process === "undefined" || process.versions?.node == null) return null;
|
|
22339
22361
|
for (const specifier of ["esbuild-wasm", "esbuild"]) {
|
|
22340
22362
|
try {
|
|
22341
|
-
const
|
|
22342
|
-
const api =
|
|
22363
|
+
const loaded = await nodeOnlyModule(specifier);
|
|
22364
|
+
const api = loaded.default ?? loaded;
|
|
22343
22365
|
if (specifier === "esbuild-wasm") await api.initialize({});
|
|
22344
22366
|
return api;
|
|
22345
|
-
} catch {
|
|
22367
|
+
} catch (error) {
|
|
22368
|
+
if (typeof process !== "undefined" && process.env?.SANDBOXEDJS_DEBUG) {
|
|
22369
|
+
console.error(`[sandboxedjs] ${specifier} unavailable:`, error);
|
|
22370
|
+
}
|
|
22346
22371
|
}
|
|
22347
22372
|
}
|
|
22348
22373
|
return null;
|
|
22349
22374
|
}
|
|
22375
|
+
function esbuildUnavailable() {
|
|
22376
|
+
const error = new Error(
|
|
22377
|
+
"esbuild is unavailable: install `esbuild-wasm` to give the sandboxed runtime a build of esbuild it can execute."
|
|
22378
|
+
);
|
|
22379
|
+
error.code = "ERR_FEATURE_UNAVAILABLE_ON_PLATFORM";
|
|
22380
|
+
return error;
|
|
22381
|
+
}
|
|
22350
22382
|
|
|
22351
22383
|
// src/runtime/local-runtime-pod.ts
|
|
22352
22384
|
var WASM_ALIASES = {
|
|
@@ -22532,11 +22564,16 @@ var LocalRuntimePod = class _LocalRuntimePod {
|
|
|
22532
22564
|
env;
|
|
22533
22565
|
aliases;
|
|
22534
22566
|
modules;
|
|
22567
|
+
esbuild;
|
|
22535
22568
|
constructor(options) {
|
|
22536
22569
|
this.workdir = options.workdir ?? "/";
|
|
22537
22570
|
this.env = { ...options.env };
|
|
22538
22571
|
this.aliases = { ...WASM_ALIASES, ...options.aliases };
|
|
22539
22572
|
this.modules = { ...options.modules };
|
|
22573
|
+
if (options.hostEsbuild !== false && !this.modules.esbuild) {
|
|
22574
|
+
this.esbuild = createHostEsbuild();
|
|
22575
|
+
this.modules.esbuild = this.esbuild.module;
|
|
22576
|
+
}
|
|
22540
22577
|
if (options.onServerReady) {
|
|
22541
22578
|
const notify = options.onServerReady;
|
|
22542
22579
|
this.router.onListen = (port) => notify(port, `http://localhost:${port}`);
|
|
@@ -22549,12 +22586,7 @@ var LocalRuntimePod = class _LocalRuntimePod {
|
|
|
22549
22586
|
this.seed(options.files ?? {});
|
|
22550
22587
|
}
|
|
22551
22588
|
static async boot(options = {}) {
|
|
22552
|
-
|
|
22553
|
-
if (options.hostEsbuild !== false && !pod.modules.esbuild) {
|
|
22554
|
-
const esbuild = await loadHostEsbuild();
|
|
22555
|
-
if (esbuild) pod.modules.esbuild = esbuild;
|
|
22556
|
-
}
|
|
22557
|
-
return pod;
|
|
22589
|
+
return new _LocalRuntimePod(options);
|
|
22558
22590
|
}
|
|
22559
22591
|
async spawn(command, args = [], options = {}) {
|
|
22560
22592
|
this.assertActive();
|
|
@@ -22646,6 +22678,7 @@ var LocalRuntimePod = class _LocalRuntimePod {
|
|
|
22646
22678
|
teardown() {
|
|
22647
22679
|
this.disposed = true;
|
|
22648
22680
|
this.router.closeAll();
|
|
22681
|
+
this.esbuild?.stop();
|
|
22649
22682
|
}
|
|
22650
22683
|
seed(files) {
|
|
22651
22684
|
for (const [path, data] of Object.entries(files)) {
|