@poe-platform/safe-bash 0.1.744 → 0.1.746
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/image-ast/browser/sharp.d.ts +1 -1
- package/dist/image-ast/index.js +133 -35
- package/dist/image-ast/sharp.d.ts +1 -1
- package/dist/safe-bash/chunks/{chunk-2CO4WCMK.js → chunk-3ZNXN3XO.js} +434 -245
- package/dist/safe-bash/chunks/{chunk-2F7Q532M.js → chunk-4GK4FAT6.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-WCNFCN2G.js → chunk-BS6QFRNX.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-IZZ7KX4E.js → chunk-JCXAGOEK.js} +40 -3
- package/dist/safe-bash/chunks/{chunk-WN7FYUWU.js → chunk-MC2KZY3D.js} +26 -13
- package/dist/safe-bash/chunks/{chunk-I3DOFJSJ.js → chunk-MUWJPSGN.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-7RP6WOWK.js → chunk-OF2PDE3W.js} +2 -2
- package/dist/safe-bash/chunks/{pdf-renderer-3TVUXNBT.js → pdf-renderer-4APIM7F7.js} +2 -2
- package/dist/safe-bash/chunks/{src-5VZS2ZKB.js → src-T2WAWJXF.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-DRCPJVZF.js → chunk-44N2IRVP.js} +17 -5
- package/dist/safe-bash/command-chunks/{chunk-LYKC7WJB.js → chunk-6742OVAC.js} +37 -3
- package/dist/safe-bash/command-chunks/{chunk-BMBXSLVX.js → chunk-6QU5OLPJ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-YHANNN7I.js → chunk-S3BO2NJT.js} +7 -0
- package/dist/safe-bash/commands/basic.d.ts +2 -0
- package/dist/safe-bash/commands/basic.js +236 -9
- package/dist/safe-bash/commands/pr/index.browser.js +1 -1
- package/dist/safe-bash/commands/streams.js +9 -56
- package/dist/safe-bash/commands/table-text/index.js +5 -1
- package/dist/safe-bash/commands/text.js +13 -2
- package/dist/safe-bash/commands/time-env/shared.js +2 -2
- package/dist/safe-bash/commands/time-env/sleep.js +6 -4
- package/dist/safe-bash/commands/timeout/index.d.ts +7 -0
- package/dist/safe-bash/commands/timeout/index.js +52 -32
- package/dist/safe-bash/commands/timeout/scheduler.js +7 -6
- package/dist/safe-bash/core.browser.js +3475 -883
- package/dist/safe-bash/opt-in/commands/shuf/random.js +2 -3
- package/dist/safe-bash/opt-in/shell/extensions/read/index.js +1 -2
- package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +1 -2
- package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +1 -8
- package/dist/safe-bash/playwright/adapter.d.ts +2 -0
- package/dist/safe-bash/playwright/capability-events.d.ts +7 -0
- package/dist/safe-bash/playwright/capability-events.js +11 -3
- package/dist/safe-bash/playwright/controller.d.ts +14 -0
- package/dist/safe-bash/playwright/controller.js +36 -8
- package/dist/safe-bash/playwright/index.d.ts +1 -0
- package/dist/safe-bash/playwright/index.js +1 -0
- package/dist/safe-bash/playwright/private-target-transport.d.ts +1 -0
- package/dist/safe-bash/playwright/private-target-transport.js +21 -21
- package/dist/safe-bash/shell/runtime.d.ts +34 -2
- package/dist/safe-bash/shell/runtime.js +4107 -947
- package/dist/safe-bash/shell/sync-jq-expression.d.ts +6 -0
- package/dist/safe-bash/shell/sync-jq-expression.js +46 -0
- package/dist/safe-bash-command-cal/index.js +32 -12
- package/dist/safe-bash-command-hostname/index.js +22 -7
- package/dist/safe-bash-command-id/index.js +28 -9
- package/dist/safe-bash-command-pandoc/command.js +1 -1
- package/dist/safe-bash-command-pandoc/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/command.d.ts +2 -2
- package/dist/safe-bash-command-ssconvert/contracts.d.ts +4 -0
- package/dist/safe-bash-command-ssconvert/engine.d.ts +2 -2
- package/dist/safe-bash-command-ssconvert/index.js +421 -237
- package/dist/safe-bash-command-whoami/index.js +26 -12
- package/dist/safe-bash-command-wkhtmltopdf/index.js +24 -11
- package/dist/safe-bash-command-wkhtmltopdf/limits.d.ts +1 -1
- package/dist/safe-bash-command-wkhtmltopdf/resources.d.ts +1 -1
- package/dist/safe-bash-query-engine/index.js +3 -3
- package/dist/safe-bash-query-engine/interpreter.js +1 -1
- package/dist/safe-bash-query-engine/parser.js +1 -1
- package/dist/safe-bash-query-engine/query-core.js +3 -3
- package/dist/safe-playwright-cloudflare/browser-private-transport.js +8 -13
- package/dist/safe-playwright-cloudflare/browser-storage-control.js +13 -4
- package/dist/safe-playwright-cloudflare/browser-trace-archive.js +1 -1
- package/package.json +18 -14
- package/dist/image-ast/streams/node.d.ts +0 -10
- package/dist/image-ast/streams/node.js +0 -5
- package/dist/image-ast/streams/web.js +0 -94
|
@@ -8,6 +8,7 @@ import { printfHex } from "./printf-hex.js";
|
|
|
8
8
|
import { parsePrintfFloat } from "./printf-float.js";
|
|
9
9
|
import { printfDecimal } from "./printf-decimal.js";
|
|
10
10
|
import { parsePrintfDirective } from "./printf-format.js";
|
|
11
|
+
const utf8Encoder = new TextEncoder();
|
|
11
12
|
export const defaultEchoExecutors = new WeakSet();
|
|
12
13
|
export function basicCommands() {
|
|
13
14
|
return [
|
|
@@ -94,7 +95,7 @@ export function basicCommands() {
|
|
|
94
95
|
await output(context, result + (parsed.flags.has("z") ? "\0" : "\n"));
|
|
95
96
|
}
|
|
96
97
|
return { exitCode: 0 };
|
|
97
|
-
}),
|
|
98
|
+
}, 1, 1),
|
|
98
99
|
define("dirname", async (context) => {
|
|
99
100
|
const parsed = options(context.args, "z", { zero: "z" });
|
|
100
101
|
requireOperands(parsed.operands);
|
|
@@ -106,7 +107,7 @@ export function basicCommands() {
|
|
|
106
107
|
await output(context, parent.slice(0, end) + (parsed.flags.has("z") ? "\0" : "\n"));
|
|
107
108
|
}
|
|
108
109
|
return { exitCode: 0 };
|
|
109
|
-
}),
|
|
110
|
+
}, 1, 1),
|
|
110
111
|
printfCommand,
|
|
111
112
|
].map(command => {
|
|
112
113
|
if (command.name === "echo")
|
|
@@ -355,6 +356,75 @@ export function tryFastPrintf(args) {
|
|
|
355
356
|
offset += 2;
|
|
356
357
|
continue;
|
|
357
358
|
}
|
|
359
|
+
if (next === 97) {
|
|
360
|
+
result += "\x07";
|
|
361
|
+
offset += 2;
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (next === 98) {
|
|
365
|
+
result += "\b";
|
|
366
|
+
offset += 2;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (next === 102) {
|
|
370
|
+
result += "\f";
|
|
371
|
+
offset += 2;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
if (next === 118) {
|
|
375
|
+
result += "\v";
|
|
376
|
+
offset += 2;
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
if (next === 101 || next === 69) {
|
|
380
|
+
result += "\x1b";
|
|
381
|
+
offset += 2;
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (next === 34) {
|
|
385
|
+
result += "\"";
|
|
386
|
+
offset += 2;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (next === 39) {
|
|
390
|
+
result += "'";
|
|
391
|
+
offset += 2;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (next >= 48 && next <= 55) {
|
|
395
|
+
let cur = offset + 1;
|
|
396
|
+
const end = Math.min(format.length, cur + 3);
|
|
397
|
+
let val = 0;
|
|
398
|
+
while (cur < end && format.charCodeAt(cur) >= 48 && format.charCodeAt(cur) <= 55) {
|
|
399
|
+
val = val * 8 + (format.charCodeAt(cur++) - 48);
|
|
400
|
+
}
|
|
401
|
+
const byte = val & 255;
|
|
402
|
+
if (byte === 0 || byte >= 128)
|
|
403
|
+
return undefined;
|
|
404
|
+
result += String.fromCharCode(byte);
|
|
405
|
+
offset = cur;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (next === 120) {
|
|
409
|
+
let cur = offset + 2;
|
|
410
|
+
const end = Math.min(format.length, cur + 2);
|
|
411
|
+
let val = 0;
|
|
412
|
+
let digits = 0;
|
|
413
|
+
while (cur < end) {
|
|
414
|
+
const d = format.charCodeAt(cur);
|
|
415
|
+
const n = d >= 48 && d <= 57 ? d - 48 : d >= 65 && d <= 70 ? d - 55 : d >= 97 && d <= 102 ? d - 87 : -1;
|
|
416
|
+
if (n < 0)
|
|
417
|
+
break;
|
|
418
|
+
val = val * 16 + n;
|
|
419
|
+
digits++;
|
|
420
|
+
cur++;
|
|
421
|
+
}
|
|
422
|
+
if (digits === 0 || val === 0 || val >= 128)
|
|
423
|
+
return undefined;
|
|
424
|
+
result += String.fromCharCode(val);
|
|
425
|
+
offset = cur;
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
358
428
|
return undefined;
|
|
359
429
|
}
|
|
360
430
|
if (ch !== 37) {
|
|
@@ -422,15 +492,31 @@ export function tryFastPrintf(args) {
|
|
|
422
492
|
const rawVal = args[argument++] ?? "";
|
|
423
493
|
if (rawVal.includes("\0"))
|
|
424
494
|
return undefined;
|
|
425
|
-
|
|
495
|
+
let val = rawVal;
|
|
496
|
+
let valByteLen = rawVal.length;
|
|
426
497
|
if (precision >= 0 || width > 0) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
498
|
+
let isAscii = true;
|
|
499
|
+
for (let i = 0; i < rawVal.length; i++) {
|
|
500
|
+
if (rawVal.charCodeAt(i) >= 128) {
|
|
501
|
+
isAscii = false;
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
if (isAscii) {
|
|
506
|
+
if (precision >= 0 && precision < rawVal.length) {
|
|
507
|
+
val = rawVal.slice(0, precision);
|
|
508
|
+
valByteLen = val.length;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
else if (precision < 0) {
|
|
512
|
+
valByteLen = utf8Encoder.encode(rawVal).byteLength;
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
return undefined;
|
|
516
|
+
}
|
|
430
517
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
const pad = " ".repeat(width - val.length);
|
|
518
|
+
if (width > valByteLen) {
|
|
519
|
+
const pad = " ".repeat(width - valByteLen);
|
|
434
520
|
result += leftAlign ? val + pad : pad + val;
|
|
435
521
|
}
|
|
436
522
|
else {
|
|
@@ -439,6 +525,24 @@ export function tryFastPrintf(args) {
|
|
|
439
525
|
offset = cur + 1;
|
|
440
526
|
continue;
|
|
441
527
|
}
|
|
528
|
+
if (conv === 99 && !zeroPad) {
|
|
529
|
+
const rawVal = args[argument++] ?? "";
|
|
530
|
+
if (rawVal.length === 0)
|
|
531
|
+
return undefined;
|
|
532
|
+
const c0 = rawVal.charCodeAt(0);
|
|
533
|
+
if (c0 === 0 || c0 >= 128)
|
|
534
|
+
return undefined;
|
|
535
|
+
const ch0 = rawVal[0];
|
|
536
|
+
if (width > 1) {
|
|
537
|
+
const pad = " ".repeat(width - 1);
|
|
538
|
+
result += leftAlign ? ch0 + pad : pad + ch0;
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
result += ch0;
|
|
542
|
+
}
|
|
543
|
+
offset = cur + 1;
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
442
546
|
if (conv === 100 || conv === 105) {
|
|
443
547
|
const rawVal = args[argument++] ?? "0";
|
|
444
548
|
const val = rawVal.length === 0 ? "0" : rawVal;
|
|
@@ -536,5 +640,128 @@ export function tryFastPrintf(args) {
|
|
|
536
640
|
} while (argument < args.length);
|
|
537
641
|
return result;
|
|
538
642
|
}
|
|
643
|
+
export function extractFastPrintfSpecifiers(format) {
|
|
644
|
+
if (format.length > 256)
|
|
645
|
+
return undefined;
|
|
646
|
+
const specs = [];
|
|
647
|
+
for (let offset = 0; offset < format.length;) {
|
|
648
|
+
const ch = format.charCodeAt(offset);
|
|
649
|
+
if (ch === 92) {
|
|
650
|
+
const next = format.charCodeAt(offset + 1);
|
|
651
|
+
if (next === 110 || next === 116 || next === 114 || next === 92 ||
|
|
652
|
+
next === 97 || next === 98 || next === 102 || next === 118 ||
|
|
653
|
+
next === 101 || next === 69 || next === 34 || next === 39) {
|
|
654
|
+
offset += 2;
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
if (next >= 48 && next <= 55) {
|
|
658
|
+
let cur = offset + 1;
|
|
659
|
+
const end = Math.min(format.length, cur + 3);
|
|
660
|
+
let val = 0;
|
|
661
|
+
while (cur < end && format.charCodeAt(cur) >= 48 && format.charCodeAt(cur) <= 55) {
|
|
662
|
+
val = val * 8 + (format.charCodeAt(cur++) - 48);
|
|
663
|
+
}
|
|
664
|
+
if ((val & 255) === 0 || (val & 255) >= 128)
|
|
665
|
+
return undefined;
|
|
666
|
+
offset = cur;
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
if (next === 120) {
|
|
670
|
+
let cur = offset + 2;
|
|
671
|
+
const end = Math.min(format.length, cur + 2);
|
|
672
|
+
let val = 0;
|
|
673
|
+
let digits = 0;
|
|
674
|
+
while (cur < end) {
|
|
675
|
+
const d = format.charCodeAt(cur);
|
|
676
|
+
const n = d >= 48 && d <= 57 ? d - 48 : d >= 65 && d <= 70 ? d - 55 : d >= 97 && d <= 102 ? d - 87 : -1;
|
|
677
|
+
if (n < 0)
|
|
678
|
+
break;
|
|
679
|
+
val = val * 16 + n;
|
|
680
|
+
digits++;
|
|
681
|
+
cur++;
|
|
682
|
+
}
|
|
683
|
+
if (digits === 0 || val === 0 || val >= 128)
|
|
684
|
+
return undefined;
|
|
685
|
+
offset = cur;
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
688
|
+
return undefined;
|
|
689
|
+
}
|
|
690
|
+
if (ch !== 37) {
|
|
691
|
+
offset++;
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
const spec = format.charCodeAt(offset + 1);
|
|
695
|
+
if (spec === 37) {
|
|
696
|
+
offset += 2;
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
let cur = offset + 1;
|
|
700
|
+
let leftAlign = false;
|
|
701
|
+
let zeroPad = false;
|
|
702
|
+
while (cur < format.length) {
|
|
703
|
+
const fc = format.charCodeAt(cur);
|
|
704
|
+
if (fc === 45) {
|
|
705
|
+
leftAlign = true;
|
|
706
|
+
cur++;
|
|
707
|
+
}
|
|
708
|
+
else if (fc === 48) {
|
|
709
|
+
zeroPad = true;
|
|
710
|
+
cur++;
|
|
711
|
+
}
|
|
712
|
+
else
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
if (leftAlign)
|
|
716
|
+
zeroPad = false;
|
|
717
|
+
let width = 0;
|
|
718
|
+
while (cur < format.length) {
|
|
719
|
+
const dc = format.charCodeAt(cur);
|
|
720
|
+
if (dc < 48 || dc > 57)
|
|
721
|
+
break;
|
|
722
|
+
width = width * 10 + (dc - 48);
|
|
723
|
+
if (width > 128)
|
|
724
|
+
return undefined;
|
|
725
|
+
cur++;
|
|
726
|
+
}
|
|
727
|
+
let precision = -1;
|
|
728
|
+
if (format.charCodeAt(cur) === 46) {
|
|
729
|
+
cur++;
|
|
730
|
+
precision = 0;
|
|
731
|
+
while (cur < format.length) {
|
|
732
|
+
const dc = format.charCodeAt(cur);
|
|
733
|
+
if (dc < 48 || dc > 57)
|
|
734
|
+
break;
|
|
735
|
+
precision = precision * 10 + (dc - 48);
|
|
736
|
+
if (precision > 128)
|
|
737
|
+
return undefined;
|
|
738
|
+
cur++;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
const conv = format.charCodeAt(cur);
|
|
742
|
+
if (conv === 115 && !zeroPad) {
|
|
743
|
+
specs.push(precision < 0 ? "s" : "s_prec");
|
|
744
|
+
offset = cur + 1;
|
|
745
|
+
continue;
|
|
746
|
+
}
|
|
747
|
+
if (conv === 99 && !zeroPad) {
|
|
748
|
+
specs.push("c");
|
|
749
|
+
offset = cur + 1;
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
if (conv === 100 || conv === 105) {
|
|
753
|
+
specs.push("d");
|
|
754
|
+
offset = cur + 1;
|
|
755
|
+
continue;
|
|
756
|
+
}
|
|
757
|
+
if (conv === 120 || conv === 88 || conv === 111 || conv === 117) {
|
|
758
|
+
specs.push("u");
|
|
759
|
+
offset = cur + 1;
|
|
760
|
+
continue;
|
|
761
|
+
}
|
|
762
|
+
return undefined;
|
|
763
|
+
}
|
|
764
|
+
return specs;
|
|
765
|
+
}
|
|
539
766
|
export const printfCommand = define("printf", formatPrintf, 1, 1);
|
|
540
767
|
//# sourceMappingURL=basic.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createPrCommand,
|
|
3
3
|
createPrCommands,
|
|
4
4
|
prCommands
|
|
5
|
-
} from "../../chunks/chunk-
|
|
5
|
+
} from "../../chunks/chunk-MUWJPSGN.js";
|
|
6
6
|
import "../../chunks/chunk-BI6JV62X.js";
|
|
7
7
|
import "../../chunks/chunk-2G2T5MEM.js";
|
|
8
8
|
import "../../chunks/chunk-JYGWVGEJ.js";
|
|
@@ -713,7 +713,7 @@ async function executeHeadTailSlow(name, maxTailFollowHandles, context) {
|
|
|
713
713
|
}
|
|
714
714
|
function headTail(name, maxTailFollowHandles = Infinity) {
|
|
715
715
|
return define(name, context => {
|
|
716
|
-
if (name === "head"
|
|
716
|
+
if (name === "head") {
|
|
717
717
|
const a = context.args;
|
|
718
718
|
let fastCount = -1;
|
|
719
719
|
if (a.length === 0) {
|
|
@@ -746,62 +746,15 @@ function headTail(name, maxTailFollowHandles = Infinity) {
|
|
|
746
746
|
fastCount = n;
|
|
747
747
|
}
|
|
748
748
|
if (fastCount >= 0) {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
return finishHeadTailPromise(context, p);
|
|
756
|
-
}
|
|
757
|
-
catch (error) {
|
|
758
|
-
return diagnostic(context, error).then(RETURN_EXIT_ONE);
|
|
759
|
-
}
|
|
749
|
+
assertCommandRequirements(context, inspectedInputRequirements, STDIN_REQUIREMENT_MODES);
|
|
750
|
+
try {
|
|
751
|
+
const p = prefixSyncOrAsync(context, input(context, "-"), fastCount, false, false, 10);
|
|
752
|
+
if (p === undefined)
|
|
753
|
+
return RESOLVED_EXIT_ZERO;
|
|
754
|
+
return finishHeadTailPromise(context, p);
|
|
760
755
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (!req) {
|
|
764
|
-
assertCommandRequirements(context, inspectedInputRequirements, STDIN_REQUIREMENT_MODES);
|
|
765
|
-
const iter = input(context, "-")[Symbol.asyncIterator]();
|
|
766
|
-
if (typeof iter.tryNextSync === "function") {
|
|
767
|
-
try {
|
|
768
|
-
const res1 = iter.tryNextSync();
|
|
769
|
-
if (res1 !== undefined) {
|
|
770
|
-
if (res1.done)
|
|
771
|
-
return RESOLVED_EXIT_ZERO;
|
|
772
|
-
const chunk = res1.value;
|
|
773
|
-
const res2 = iter.tryNextSync();
|
|
774
|
-
if (res2 !== undefined && res2.done && chunk.length <= bufferLimit) {
|
|
775
|
-
if (fastCount === 0 || chunk.length === 0)
|
|
776
|
-
return RESOLVED_EXIT_ZERO;
|
|
777
|
-
let pos = chunk[chunk.length - 1] === 10 ? chunk.length - 2 : chunk.length - 1;
|
|
778
|
-
let startIdx = 0;
|
|
779
|
-
for (let rem = fastCount; rem > 0; rem--) {
|
|
780
|
-
if (pos < 0) {
|
|
781
|
-
startIdx = 0;
|
|
782
|
-
break;
|
|
783
|
-
}
|
|
784
|
-
const nl = chunk.lastIndexOf(10, pos);
|
|
785
|
-
if (nl === -1) {
|
|
786
|
-
startIdx = 0;
|
|
787
|
-
break;
|
|
788
|
-
}
|
|
789
|
-
startIdx = nl + 1;
|
|
790
|
-
pos = nl - 1;
|
|
791
|
-
}
|
|
792
|
-
const slice = startIdx === 0 ? chunk : chunk.subarray(startIdx);
|
|
793
|
-
const p = output(context, slice);
|
|
794
|
-
if (isSyncResolved(p))
|
|
795
|
-
return RESOLVED_EXIT_ZERO;
|
|
796
|
-
return finishHeadTailPromise(context, p);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
catch (error) {
|
|
801
|
-
return diagnostic(context, error).then(RETURN_EXIT_ONE);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}
|
|
756
|
+
catch (error) {
|
|
757
|
+
return diagnostic(context, error).then(RETURN_EXIT_ONE);
|
|
805
758
|
}
|
|
806
759
|
}
|
|
807
760
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { builtInDirectContextExecutors } from "../internal.js";
|
|
1
2
|
import { createPasteCommand } from "./paste.js";
|
|
2
3
|
import { createCommCommand } from "./comm.js";
|
|
3
4
|
import { createJoinCommand } from "./join.js";
|
|
4
5
|
import { settings } from "./internal.js";
|
|
5
6
|
export function createTableTextCommands(options = {}) {
|
|
6
7
|
settings(options);
|
|
7
|
-
|
|
8
|
+
const defs = [createPasteCommand(options), createCommCommand(options), createJoinCommand(options)];
|
|
9
|
+
for (let i = 0; i < defs.length; i++)
|
|
10
|
+
builtInDirectContextExecutors.add(defs[i].execute);
|
|
11
|
+
return defs;
|
|
8
12
|
}
|
|
9
13
|
export function tableTextCommands(options = {}) {
|
|
10
14
|
const commands = createTableTextCommands(options);
|
|
@@ -2363,6 +2363,7 @@ async function executeUniqGeneral(context, preReadSource) {
|
|
|
2363
2363
|
const onlyRepeated = parsed.flags.has("d");
|
|
2364
2364
|
const onlyUnique = parsed.flags.has("u");
|
|
2365
2365
|
const identityKey = skipFields === 0 && skipCharacters === 0 && width === Infinity && !ignoreCase;
|
|
2366
|
+
const uniqDecoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
2366
2367
|
const key = (bytes) => {
|
|
2367
2368
|
if (identityKey)
|
|
2368
2369
|
return bytes;
|
|
@@ -2373,8 +2374,18 @@ async function executeUniqGeneral(context, preReadSource) {
|
|
|
2373
2374
|
while (offset < bytes.length && bytes[offset] !== 32 && bytes[offset] !== 9)
|
|
2374
2375
|
offset++;
|
|
2375
2376
|
}
|
|
2376
|
-
|
|
2377
|
-
|
|
2377
|
+
let result;
|
|
2378
|
+
try {
|
|
2379
|
+
const chars = Array.from(uniqDecoder.decode(bytes.subarray(offset)));
|
|
2380
|
+
result = encoder.encode((width === Infinity ? chars.slice(skipCharacters) : chars.slice(skipCharacters, skipCharacters + width)).join(""));
|
|
2381
|
+
}
|
|
2382
|
+
catch (error) {
|
|
2383
|
+
if (!(error instanceof TypeError))
|
|
2384
|
+
throw error;
|
|
2385
|
+
// Invalid UTF-8 records retain byte comparisons without replacement characters.
|
|
2386
|
+
offset += skipCharacters;
|
|
2387
|
+
result = bytes.subarray(offset, width === Infinity ? undefined : offset + width);
|
|
2388
|
+
}
|
|
2378
2389
|
return ignoreCase ? fold(result) : result;
|
|
2379
2390
|
};
|
|
2380
2391
|
const records = (async function* () {
|
|
@@ -8,8 +8,8 @@ export function settings(options) {
|
|
|
8
8
|
throw new RangeError(`Invalid time-env limit: ${name}`);
|
|
9
9
|
}
|
|
10
10
|
const maxTimerMilliseconds = options.maxTimerMilliseconds ?? 2147483647;
|
|
11
|
-
if (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647) {
|
|
12
|
-
throw new RangeError("maxTimerMilliseconds must be
|
|
11
|
+
if (maxTimerMilliseconds !== Infinity && (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647)) {
|
|
12
|
+
throw new RangeError("maxTimerMilliseconds must be between 1 and 2147483647 or Infinity");
|
|
13
13
|
}
|
|
14
14
|
const scheduler = options.scheduler ?? {
|
|
15
15
|
now: () => performance.now(),
|
|
@@ -96,7 +96,8 @@ function delay(milliseconds, signal, configuration) {
|
|
|
96
96
|
let handle;
|
|
97
97
|
let armed = false;
|
|
98
98
|
let settled = false;
|
|
99
|
-
let
|
|
99
|
+
let remaining = milliseconds;
|
|
100
|
+
let step = 0;
|
|
100
101
|
let previous;
|
|
101
102
|
const finish = (failed, reason) => {
|
|
102
103
|
if (settled)
|
|
@@ -128,14 +129,15 @@ function delay(milliseconds, signal, configuration) {
|
|
|
128
129
|
if (!Number.isFinite(now) || Math.abs(now) > Number.MAX_SAFE_INTEGER || (previous !== undefined && now < previous)) {
|
|
129
130
|
throw new RangeError("sleep scheduler must supply finite monotonic milliseconds");
|
|
130
131
|
}
|
|
131
|
-
|
|
132
|
+
if (previous !== undefined)
|
|
133
|
+
remaining -= Math.max(step, now - previous);
|
|
132
134
|
previous = now;
|
|
133
|
-
const remaining = milliseconds - (now - started);
|
|
134
135
|
if (remaining <= 0) {
|
|
135
136
|
finish(false);
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
+
step = Math.min(2147483647, configuration.maxTimerMilliseconds, Math.max(1, Math.ceil(remaining)));
|
|
140
|
+
const timer = scheduler.setTimeout(() => { armed = false; schedule(); }, step);
|
|
139
141
|
if (settled)
|
|
140
142
|
scheduler.clearTimeout(timer);
|
|
141
143
|
else {
|
|
@@ -4,7 +4,14 @@ export interface TimeoutScheduler {
|
|
|
4
4
|
setTimeout(callback: () => void, milliseconds: number): unknown;
|
|
5
5
|
clearTimeout(handle: unknown): void;
|
|
6
6
|
}
|
|
7
|
+
export interface TimeoutLimits {
|
|
8
|
+
readonly maxArguments: number;
|
|
9
|
+
readonly maxArgumentBytes: number;
|
|
10
|
+
/** Bytes emitted by timeout itself; child output uses the child's budgets. */
|
|
11
|
+
readonly maxOutputBytes: number;
|
|
12
|
+
}
|
|
7
13
|
export interface TimeoutCommandOptions {
|
|
14
|
+
readonly limits?: Partial<TimeoutLimits> | undefined;
|
|
8
15
|
/** Trusted host binding responsible for signalling, hard escalation and child cleanup. */
|
|
9
16
|
readonly killAfterPolicy?: KillAfterPolicy | undefined;
|
|
10
17
|
readonly invoke?: CommandInvoker | undefined;
|