@poe-platform/safe-bash 0.1.726 → 0.1.727
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-6VZX7ESE.js → chunk-26N7BLXE.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-ZZ7JQBPX.js → chunk-4A2OLEML.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-LTREB3HX.js → chunk-54MC6XF5.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-Z3CCN6Y2.js → chunk-6J5FUESH.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-YR5RZBWS.js → chunk-6TBFZ5JE.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-6HJNJ625.js → chunk-7MMYQG3P.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-WTZZX4LV.js → chunk-A4MB2KXV.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-EM2JW7ZH.js → chunk-ATYJKRBZ.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-VV24PRPB.js → chunk-AZQOEGP3.js} +1050 -101
- package/dist/safe-bash/chunks/chunk-AZQOEGP3.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-EFMXWUYE.js → chunk-B6JEJ6AT.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-JFGGQUYP.js → chunk-BFXGHT3R.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-RP5IZOOR.js → chunk-BJYV5J65.js} +1050 -101
- package/dist/safe-bash/chunks/chunk-BJYV5J65.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-HNHOPD3P.js → chunk-DIEFWGXO.js} +46 -26
- package/dist/safe-bash/chunks/{chunk-HNHOPD3P.js.map → chunk-DIEFWGXO.js.map} +2 -2
- package/dist/safe-bash/chunks/{chunk-SME47P4B.js → chunk-DV6EZOKM.js} +46 -26
- package/dist/safe-bash/chunks/{chunk-SME47P4B.js.map → chunk-DV6EZOKM.js.map} +2 -2
- package/dist/safe-bash/chunks/{chunk-646RTREQ.js → chunk-EEDOYIPC.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-OFAAHWL5.js → chunk-GCQ5A2T2.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-MJW4KSKV.js → chunk-GLPJEDLY.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-FOOJWH7J.js → chunk-GO5OKPBO.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-5JANWFJ3.js → chunk-GWYXCCGO.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-DPHRNHPT.js → chunk-H6KJ4L22.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-FLX2BZBF.js → chunk-HGBYIDAK.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-VGJIDLZM.js → chunk-KS5VSJYM.js} +15 -8
- package/dist/safe-bash/chunks/chunk-KS5VSJYM.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-PO3Z7W3A.js → chunk-MUHYGUFD.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-5DLGYPGJ.js → chunk-PDSTXORC.js} +126 -58
- package/dist/safe-bash/chunks/chunk-PDSTXORC.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-TIHMU25L.js → chunk-PQ37GDJF.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-OTM5RCWZ.js → chunk-QNEDWYC2.js} +15 -8
- package/dist/safe-bash/chunks/chunk-QNEDWYC2.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-LZ7FUN6K.js → chunk-RHHDOA67.js} +5 -5
- package/dist/safe-bash/chunks/{chunk-DSCL3VA2.js → chunk-SJ3B26XV.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-6JBTVWHH.js → chunk-SWACYEIT.js} +5 -5
- package/dist/safe-bash/chunks/{chunk-7UJW7TYR.js → chunk-TD6NWAUK.js} +126 -58
- package/dist/safe-bash/chunks/chunk-TD6NWAUK.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-Q4I754TV.js → chunk-THOBFD5C.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-XELW5O3R.js → chunk-U2STHT7S.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-5X4SOSTT.js → chunk-UJHE5PTK.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-B6YFFKYG.js → chunk-X4I3RHTC.js} +5 -1
- package/dist/safe-bash/chunks/chunk-X4I3RHTC.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-YOK5UHA7.js → chunk-XKXFX3RH.js} +5 -1
- package/dist/safe-bash/chunks/chunk-XKXFX3RH.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-PLCYP2E5.js → chunk-XV4K3UUF.js} +2 -2
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/factor/index.browser.js +2 -2
- package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
- package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
- package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
- package/dist/safe-bash/commands/internal.d.ts.map +1 -1
- package/dist/safe-bash/commands/internal.js +4 -3
- package/dist/safe-bash/commands/internal.js.map +1 -1
- package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/index.browser.js +4 -4
- package/dist/safe-bash/commands/network/index.browser.js +4 -4
- package/dist/safe-bash/commands/node/index.browser.js +4 -4
- package/dist/safe-bash/commands/pandoc/index.js.map +1 -1
- package/dist/safe-bash/commands/pr/index.browser.js +3 -3
- package/dist/safe-bash/commands/python/index.browser.js +2 -2
- package/dist/safe-bash/commands/record-buffer.d.ts.map +1 -1
- package/dist/safe-bash/commands/record-buffer.js +12 -4
- package/dist/safe-bash/commands/record-buffer.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/bounded-provider.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/bounded-provider.js +75 -8
- package/dist/safe-bash/commands/regex-execution/bounded-provider.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/limits.d.ts +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/limits.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/limits.js +6 -4
- package/dist/safe-bash/commands/regex-execution/ere/limits.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/portable.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/portable.js +7 -2
- package/dist/safe-bash/commands/regex-execution/portable.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/protocol.d.ts +2 -0
- package/dist/safe-bash/commands/regex-execution/protocol.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/protocol.js +26 -0
- package/dist/safe-bash/commands/regex-execution/protocol.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/utf8.d.ts +1 -1
- package/dist/safe-bash/commands/regex-execution/utf8.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/utf8.js +26 -2
- package/dist/safe-bash/commands/regex-execution/utf8.js.map +1 -1
- package/dist/safe-bash/commands/search/grep.d.ts.map +1 -1
- package/dist/safe-bash/commands/search/grep.js +109 -15
- package/dist/safe-bash/commands/search/grep.js.map +1 -1
- package/dist/safe-bash/commands/search/matcher.d.ts +1 -1
- package/dist/safe-bash/commands/search/matcher.d.ts.map +1 -1
- package/dist/safe-bash/commands/search/matcher.js +2 -0
- package/dist/safe-bash/commands/search/matcher.js.map +1 -1
- package/dist/safe-bash/commands/search/shared.d.ts.map +1 -1
- package/dist/safe-bash/commands/search/shared.js +23 -12
- package/dist/safe-bash/commands/search/shared.js.map +1 -1
- package/dist/safe-bash/commands/standard.d.ts.map +1 -1
- package/dist/safe-bash/commands/standard.js +22 -0
- package/dist/safe-bash/commands/standard.js.map +1 -1
- package/dist/safe-bash/commands/streams.d.ts.map +1 -1
- package/dist/safe-bash/commands/streams.js +54 -10
- package/dist/safe-bash/commands/streams.js.map +1 -1
- package/dist/safe-bash/commands/structured/input.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/input.js +484 -55
- package/dist/safe-bash/commands/structured/input.js.map +1 -1
- package/dist/safe-bash/commands/structured/interpreter.d.ts +3 -0
- package/dist/safe-bash/commands/structured/interpreter.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/interpreter.js +157 -1
- package/dist/safe-bash/commands/structured/interpreter.js.map +1 -1
- package/dist/safe-bash/commands/structured/jq.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/jq.js +50 -24
- package/dist/safe-bash/commands/structured/jq.js.map +1 -1
- package/dist/safe-bash/commands/structured/limits.d.ts +5 -0
- package/dist/safe-bash/commands/structured/limits.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/limits.js +51 -36
- package/dist/safe-bash/commands/structured/limits.js.map +1 -1
- package/dist/safe-bash/commands/structured/numbers.d.ts +1 -0
- package/dist/safe-bash/commands/structured/numbers.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/numbers.js +32 -0
- package/dist/safe-bash/commands/structured/numbers.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +1 -0
- package/dist/safe-bash/commands/text-programs/awk-reader.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-reader.js +41 -5
- package/dist/safe-bash/commands/text-programs/awk-reader.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +1 -0
- package/dist/safe-bash/commands/text-programs/awk-retention.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-retention.js +9 -0
- package/dist/safe-bash/commands/text-programs/awk-retention.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +13 -0
- package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-runtime.js +421 -83
- package/dist/safe-bash/commands/text-programs/awk-runtime.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-values.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-values.js +21 -0
- package/dist/safe-bash/commands/text-programs/awk-values.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/regex.d.ts +15 -2
- package/dist/safe-bash/commands/text-programs/regex.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/regex.js +501 -13
- package/dist/safe-bash/commands/text-programs/regex.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/sed.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/sed.js +242 -102
- package/dist/safe-bash/commands/text-programs/sed.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/shared.d.ts +2 -0
- package/dist/safe-bash/commands/text-programs/shared.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/shared.js +36 -0
- package/dist/safe-bash/commands/text-programs/shared.js.map +1 -1
- package/dist/safe-bash/commands/text.d.ts.map +1 -1
- package/dist/safe-bash/commands/text.js +136 -19
- package/dist/safe-bash/commands/text.js.map +1 -1
- package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
- package/dist/safe-bash/commands/xml/index.browser.js +5 -5
- package/dist/safe-bash/commands/yq/index.browser.js +5 -5
- package/dist/safe-bash/contracts/yield.d.ts +1 -0
- package/dist/safe-bash/contracts/yield.d.ts.map +1 -1
- package/dist/safe-bash/contracts/yield.js +3 -0
- package/dist/safe-bash/contracts/yield.js.map +1 -1
- package/dist/safe-bash/core.browser.js +1052 -256
- package/dist/safe-bash/core.browser.js.map +3 -3
- package/dist/safe-bash/plugins/composition.d.ts +1 -0
- package/dist/safe-bash/plugins/composition.d.ts.map +1 -1
- package/dist/safe-bash/plugins/composition.js +80 -2
- package/dist/safe-bash/plugins/composition.js.map +1 -1
- package/dist/safe-bash/plugins/index.d.ts.map +1 -1
- package/dist/safe-bash/plugins/index.js +2 -2
- package/dist/safe-bash/plugins/index.js.map +1 -1
- package/dist/safe-bash-command-fold/arguments.d.ts +1 -1
- package/dist/safe-bash-command-fold/contracts.d.ts +2 -1
- package/dist/safe-bash-command-fold/engine.d.ts +1 -1
- package/dist/safe-bash-command-fold/index.js +10 -8
- package/dist/safe-bash-command-fold/index.js.map +2 -2
- package/dist/safe-bash-command-sips/index.js +231 -67
- package/dist/safe-bash-command-sips/index.js.map +2 -2
- package/dist/safe-bash-command-unrtf/contracts.d.ts +5 -2
- package/dist/safe-bash-command-unrtf/index.js +6 -5
- package/dist/safe-bash-command-unrtf/index.js.map +2 -2
- package/dist/safe-playwright-cloudflare/browser-run-code.js +22 -6
- package/package.json +2 -2
- package/dist/safe-bash/chunks/chunk-5DLGYPGJ.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-7UJW7TYR.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-B6YFFKYG.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-OTM5RCWZ.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-RP5IZOOR.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-VGJIDLZM.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-VV24PRPB.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-YOK5UHA7.js.map +0 -7
- /package/dist/safe-bash/chunks/{chunk-6VZX7ESE.js.map → chunk-26N7BLXE.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-ZZ7JQBPX.js.map → chunk-4A2OLEML.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-LTREB3HX.js.map → chunk-54MC6XF5.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-Z3CCN6Y2.js.map → chunk-6J5FUESH.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-YR5RZBWS.js.map → chunk-6TBFZ5JE.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-6HJNJ625.js.map → chunk-7MMYQG3P.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-WTZZX4LV.js.map → chunk-A4MB2KXV.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-EM2JW7ZH.js.map → chunk-ATYJKRBZ.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-EFMXWUYE.js.map → chunk-B6JEJ6AT.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-JFGGQUYP.js.map → chunk-BFXGHT3R.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-646RTREQ.js.map → chunk-EEDOYIPC.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-OFAAHWL5.js.map → chunk-GCQ5A2T2.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-MJW4KSKV.js.map → chunk-GLPJEDLY.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-FOOJWH7J.js.map → chunk-GO5OKPBO.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-5JANWFJ3.js.map → chunk-GWYXCCGO.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-DPHRNHPT.js.map → chunk-H6KJ4L22.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-FLX2BZBF.js.map → chunk-HGBYIDAK.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-PO3Z7W3A.js.map → chunk-MUHYGUFD.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-TIHMU25L.js.map → chunk-PQ37GDJF.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-LZ7FUN6K.js.map → chunk-RHHDOA67.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-DSCL3VA2.js.map → chunk-SJ3B26XV.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-6JBTVWHH.js.map → chunk-SWACYEIT.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-Q4I754TV.js.map → chunk-THOBFD5C.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-XELW5O3R.js.map → chunk-U2STHT7S.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-5X4SOSTT.js.map → chunk-UJHE5PTK.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-PLCYP2E5.js.map → chunk-XV4K3UUF.js.map} +0 -0
|
@@ -2,35 +2,35 @@ import {
|
|
|
2
2
|
createGetoptCommand,
|
|
3
3
|
createGetoptCommands,
|
|
4
4
|
getoptCommands
|
|
5
|
-
} from "./chunks/chunk-
|
|
5
|
+
} from "./chunks/chunk-6TBFZ5JE.js";
|
|
6
6
|
import {
|
|
7
7
|
createHdCommand,
|
|
8
8
|
createHexdumpCommand,
|
|
9
9
|
createHexdumpCommands,
|
|
10
10
|
hexdumpCommands
|
|
11
|
-
} from "./chunks/chunk-
|
|
11
|
+
} from "./chunks/chunk-UJHE5PTK.js";
|
|
12
12
|
import {
|
|
13
13
|
createIconvCommand,
|
|
14
14
|
createIconvCommands,
|
|
15
15
|
iconvCommands
|
|
16
|
-
} from "./chunks/chunk-
|
|
16
|
+
} from "./chunks/chunk-H6KJ4L22.js";
|
|
17
17
|
import {
|
|
18
18
|
createDos2unixCommand,
|
|
19
19
|
createLineEndingCommands,
|
|
20
20
|
createUnix2dosCommand,
|
|
21
21
|
lineEndingCommands
|
|
22
|
-
} from "./chunks/chunk-
|
|
22
|
+
} from "./chunks/chunk-THOBFD5C.js";
|
|
23
23
|
import {
|
|
24
24
|
createXmlCommands,
|
|
25
25
|
defaultXmlQueryLimits,
|
|
26
26
|
jqCommand,
|
|
27
27
|
xmlCommands
|
|
28
|
-
} from "./chunks/chunk-
|
|
28
|
+
} from "./chunks/chunk-DV6EZOKM.js";
|
|
29
29
|
import {
|
|
30
30
|
createYqCommand,
|
|
31
31
|
createYqCommands,
|
|
32
32
|
yqCommands
|
|
33
|
-
} from "./chunks/chunk-
|
|
33
|
+
} from "./chunks/chunk-RHHDOA67.js";
|
|
34
34
|
import {
|
|
35
35
|
Budget,
|
|
36
36
|
Pattern,
|
|
@@ -42,15 +42,16 @@ import {
|
|
|
42
42
|
defaultJqLimits,
|
|
43
43
|
grepRequirements,
|
|
44
44
|
input as input2,
|
|
45
|
-
|
|
45
|
+
lineRecordBatches,
|
|
46
46
|
readProgram,
|
|
47
47
|
requiredFileInput,
|
|
48
48
|
searchRequirements,
|
|
49
49
|
sedRequirements,
|
|
50
50
|
substitute,
|
|
51
|
+
trySubstituteSync,
|
|
51
52
|
virtualPath,
|
|
52
53
|
write
|
|
53
|
-
} from "./chunks/chunk-
|
|
54
|
+
} from "./chunks/chunk-AZQOEGP3.js";
|
|
54
55
|
import {
|
|
55
56
|
CurlError,
|
|
56
57
|
cloudflareWorkerNetworkLimits,
|
|
@@ -63,7 +64,7 @@ import {
|
|
|
63
64
|
curlCommands,
|
|
64
65
|
defaultNetworkLimits,
|
|
65
66
|
networkCommands
|
|
66
|
-
} from "./chunks/chunk-
|
|
67
|
+
} from "./chunks/chunk-GO5OKPBO.js";
|
|
67
68
|
import {
|
|
68
69
|
SafeJsCommandLimitError,
|
|
69
70
|
createSafeJsNodeCommand,
|
|
@@ -74,9 +75,8 @@ import {
|
|
|
74
75
|
safeJsNodeCommands,
|
|
75
76
|
stringValue,
|
|
76
77
|
withSignal
|
|
77
|
-
} from "./chunks/chunk-
|
|
78
|
+
} from "./chunks/chunk-MUHYGUFD.js";
|
|
78
79
|
import {
|
|
79
|
-
AvailableRecords,
|
|
80
80
|
EreLedger,
|
|
81
81
|
EreProfileLimitError,
|
|
82
82
|
EreSyntaxError,
|
|
@@ -95,8 +95,9 @@ import {
|
|
|
95
95
|
exprMatchCeilings,
|
|
96
96
|
matchEre,
|
|
97
97
|
reverseEmacsSteps,
|
|
98
|
+
trustedInputRows,
|
|
98
99
|
withRegexSession
|
|
99
|
-
} from "./chunks/chunk-
|
|
100
|
+
} from "./chunks/chunk-TD6NWAUK.js";
|
|
100
101
|
import {
|
|
101
102
|
openFileOutput,
|
|
102
103
|
writeFileOutput
|
|
@@ -115,17 +116,17 @@ import {
|
|
|
115
116
|
parseDate,
|
|
116
117
|
prCommands,
|
|
117
118
|
settings
|
|
118
|
-
} from "./chunks/chunk-
|
|
119
|
+
} from "./chunks/chunk-26N7BLXE.js";
|
|
119
120
|
import {
|
|
120
121
|
createTsortCommand,
|
|
121
122
|
createTsortCommands,
|
|
122
123
|
tsortCommands
|
|
123
|
-
} from "./chunks/chunk-
|
|
124
|
+
} from "./chunks/chunk-6J5FUESH.js";
|
|
124
125
|
import {
|
|
125
126
|
createFactorCommand,
|
|
126
127
|
createFactorCommands,
|
|
127
128
|
factorCommands
|
|
128
|
-
} from "./chunks/chunk-
|
|
129
|
+
} from "./chunks/chunk-7MMYQG3P.js";
|
|
129
130
|
import {
|
|
130
131
|
shellValueByteLength,
|
|
131
132
|
value_exports
|
|
@@ -179,7 +180,7 @@ import {
|
|
|
179
180
|
swap32IfBE,
|
|
180
181
|
swap8IfBE,
|
|
181
182
|
u32
|
|
182
|
-
} from "./chunks/chunk-
|
|
183
|
+
} from "./chunks/chunk-EEDOYIPC.js";
|
|
183
184
|
import {
|
|
184
185
|
bindFileOutputBudget,
|
|
185
186
|
openCommandFile
|
|
@@ -191,7 +192,7 @@ import {
|
|
|
191
192
|
import {
|
|
192
193
|
createLlmCommands,
|
|
193
194
|
llmCommands
|
|
194
|
-
} from "./chunks/chunk-
|
|
195
|
+
} from "./chunks/chunk-54MC6XF5.js";
|
|
195
196
|
import {
|
|
196
197
|
RecordBuffer,
|
|
197
198
|
UsageError,
|
|
@@ -220,24 +221,25 @@ import {
|
|
|
220
221
|
requireOperands,
|
|
221
222
|
textOutputRequirements,
|
|
222
223
|
value
|
|
223
|
-
} from "./chunks/chunk-
|
|
224
|
+
} from "./chunks/chunk-QNEDWYC2.js";
|
|
224
225
|
import {
|
|
225
226
|
escapeText,
|
|
226
227
|
quoteShellOperand,
|
|
227
228
|
writeDiagnostic
|
|
228
|
-
} from "./chunks/chunk-
|
|
229
|
+
} from "./chunks/chunk-4A2OLEML.js";
|
|
229
230
|
import {
|
|
230
231
|
PublicDiagnostic,
|
|
231
232
|
publicDiagnosticMessage
|
|
232
233
|
} from "./chunks/chunk-ITX6SBN6.js";
|
|
233
234
|
import {
|
|
234
235
|
cancelTurn,
|
|
236
|
+
hasYieldCheckpoint,
|
|
235
237
|
inheritYieldCheckpoint,
|
|
236
238
|
monotonicNow,
|
|
237
239
|
registerYieldCheckpoint,
|
|
238
240
|
scheduleTurn,
|
|
239
241
|
yieldTurn
|
|
240
|
-
} from "./chunks/chunk-
|
|
242
|
+
} from "./chunks/chunk-XKXFX3RH.js";
|
|
241
243
|
import {
|
|
242
244
|
command_requirements_exports,
|
|
243
245
|
contracts_exports,
|
|
@@ -285,7 +287,7 @@ __export(core_browser_exports, {
|
|
|
285
287
|
EreSyntaxError: () => EreSyntaxError,
|
|
286
288
|
EreUnsupportedError: () => EreUnsupportedError,
|
|
287
289
|
EreUsageUnknownError: () => EreUsageUnknownError,
|
|
288
|
-
FsError: () =>
|
|
290
|
+
FsError: () => FsError62,
|
|
289
291
|
MemoryFileSystem: () => MemoryFileSystem,
|
|
290
292
|
MountFileSystem: () => MountFileSystem,
|
|
291
293
|
OverlayFileSystem: () => OverlayFileSystem,
|
|
@@ -5791,10 +5793,10 @@ async function suffix(context2, source2, count2, bytes3, omit, delimiter) {
|
|
|
5791
5793
|
let pendingLines = [];
|
|
5792
5794
|
let start2 = 0;
|
|
5793
5795
|
let size2 = 0;
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
const lineLength =
|
|
5797
|
-
pendingLines.push(
|
|
5796
|
+
const pending2 = new RecordBuffer(bufferLimit);
|
|
5797
|
+
const pushLine = async (lineBytes, terminated) => {
|
|
5798
|
+
const lineLength = lineBytes.length + (terminated ? 1 : 0);
|
|
5799
|
+
pendingLines.push({ bytes: lineBytes, terminated });
|
|
5798
5800
|
size2 += lineLength;
|
|
5799
5801
|
while (pendingLines.length - start2 > count2) {
|
|
5800
5802
|
const first = pendingLines[start2++];
|
|
@@ -5806,6 +5808,23 @@ async function suffix(context2, source2, count2, bytes3, omit, delimiter) {
|
|
|
5806
5808
|
pendingLines = pendingLines.slice(start2);
|
|
5807
5809
|
start2 = 0;
|
|
5808
5810
|
}
|
|
5811
|
+
};
|
|
5812
|
+
try {
|
|
5813
|
+
for await (const chunk of source2) {
|
|
5814
|
+
context2.signal.throwIfAborted();
|
|
5815
|
+
let lineStart = 0;
|
|
5816
|
+
for (let offset = chunk.indexOf(delimiter); offset !== -1; offset = chunk.indexOf(delimiter, lineStart)) {
|
|
5817
|
+
await pushLine(pending2.finish(void 0, chunk, lineStart, offset), true);
|
|
5818
|
+
lineStart = offset + 1;
|
|
5819
|
+
}
|
|
5820
|
+
if (lineStart < chunk.length) pending2.append(chunk, lineStart);
|
|
5821
|
+
}
|
|
5822
|
+
if (pending2.size) {
|
|
5823
|
+
context2.signal.throwIfAborted();
|
|
5824
|
+
await pushLine(pending2.finish(), false);
|
|
5825
|
+
}
|
|
5826
|
+
} finally {
|
|
5827
|
+
pending2.clear();
|
|
5809
5828
|
}
|
|
5810
5829
|
if (!omit) {
|
|
5811
5830
|
for (let index = start2; index < pendingLines.length; index++) {
|
|
@@ -6235,6 +6254,8 @@ Concatenate FILEs to standard output. With no FILE, or FILE -, read standard inp
|
|
|
6235
6254
|
inWord = true;
|
|
6236
6255
|
}
|
|
6237
6256
|
};
|
|
6257
|
+
const needsText = parsed.flags.has("w") || parsed.flags.has("m") || parsed.flags.has("L");
|
|
6258
|
+
const needsLines = parsed.flags.has("l");
|
|
6238
6259
|
const utf82 = wcUtf8((point) => {
|
|
6239
6260
|
if (point !== void 0) counts.m++;
|
|
6240
6261
|
word(point !== void 0 && wcSpace(point, posix), point !== void 0 && point >= 32 && !(point >= 127 && point < 160));
|
|
@@ -6244,6 +6265,12 @@ Concatenate FILEs to standard output. With no FILE, or FILE -, read standard inp
|
|
|
6244
6265
|
for await (const chunk of input(context2, name2)) {
|
|
6245
6266
|
context2.signal.throwIfAborted();
|
|
6246
6267
|
counts.c += chunk.length;
|
|
6268
|
+
if (!needsText) {
|
|
6269
|
+
if (needsLines) {
|
|
6270
|
+
for (let pos = chunk.indexOf(10); pos !== -1; pos = chunk.indexOf(10, pos + 1)) counts.l++;
|
|
6271
|
+
}
|
|
6272
|
+
continue;
|
|
6273
|
+
}
|
|
6247
6274
|
for (const byte of chunk) {
|
|
6248
6275
|
if (byte === 10) counts.l++;
|
|
6249
6276
|
if (singleByte) word(byte === 32 || byte >= 9 && byte <= 13, byte >= 32 && byte < 127);
|
|
@@ -6252,7 +6279,7 @@ Concatenate FILEs to standard output. With no FILE, or FILE -, read standard inp
|
|
|
6252
6279
|
if (singleByte) counts.m += chunk.length;
|
|
6253
6280
|
else utf82.write(chunk);
|
|
6254
6281
|
}
|
|
6255
|
-
if (!singleByte) utf82.finish();
|
|
6282
|
+
if (needsText && !singleByte) utf82.finish();
|
|
6256
6283
|
counts.L = Math.max(counts.L, columns);
|
|
6257
6284
|
for (const field2 of ["l", "w", "m", "c"]) totals[field2] += counts[field2];
|
|
6258
6285
|
totals.L = Math.max(totals.L, counts.L);
|
|
@@ -6353,21 +6380,29 @@ Concatenate FILEs to standard output. With no FILE, or FILE -, read standard inp
|
|
|
6353
6380
|
const second = parsed.operands[1] === void 0 ? [] : characterSet(parsed.operands[1], translating ? first.length : 0);
|
|
6354
6381
|
if (translating && parsed.flags.has("t")) first = first.slice(0, second.length);
|
|
6355
6382
|
if (translating && !second.length && !parsed.flags.has("t")) throw new UsageError("second character set must not be empty");
|
|
6356
|
-
const mapping =
|
|
6383
|
+
const mapping = new Uint8Array(256);
|
|
6384
|
+
for (let offset = 0; offset < 256; offset++) mapping[offset] = offset;
|
|
6357
6385
|
if (translating) first.forEach((byte, index) => {
|
|
6358
6386
|
mapping[byte] = second[Math.min(index, second.length - 1)];
|
|
6359
6387
|
});
|
|
6360
|
-
const removed = new
|
|
6361
|
-
|
|
6388
|
+
const removed = new Uint8Array(256);
|
|
6389
|
+
if (deleting) for (const byte of first) removed[byte] = 1;
|
|
6390
|
+
const squeezed = new Uint8Array(256);
|
|
6391
|
+
if (squeezing) for (const byte of parsed.operands.length === 2 ? second : first) squeezed[byte] = 1;
|
|
6362
6392
|
let previous = -1;
|
|
6363
6393
|
for await (const chunk of input(context2)) {
|
|
6364
6394
|
context2.signal.throwIfAborted();
|
|
6365
6395
|
const transformed = new Uint8Array(chunk.length);
|
|
6396
|
+
if (!deleting && !squeezing) {
|
|
6397
|
+
for (let index = 0; index < chunk.length; index++) transformed[index] = mapping[chunk[index]];
|
|
6398
|
+
if (chunk.length) await output(context2, transformed);
|
|
6399
|
+
continue;
|
|
6400
|
+
}
|
|
6366
6401
|
let count2 = 0;
|
|
6367
6402
|
for (const byte of chunk) {
|
|
6368
|
-
if (removed
|
|
6403
|
+
if (removed[byte]) continue;
|
|
6369
6404
|
const translated = mapping[byte];
|
|
6370
|
-
if (translated === previous && squeezed
|
|
6405
|
+
if (translated === previous && squeezed[translated]) continue;
|
|
6371
6406
|
transformed[count2++] = translated;
|
|
6372
6407
|
previous = translated;
|
|
6373
6408
|
}
|
|
@@ -6511,7 +6546,16 @@ var CutOutput = class {
|
|
|
6511
6546
|
work;
|
|
6512
6547
|
#buffer = new Uint8Array(64 * 1024);
|
|
6513
6548
|
#used = 0;
|
|
6514
|
-
|
|
6549
|
+
write(bytes3) {
|
|
6550
|
+
if (bytes3.length <= 4096 && this.#used + bytes3.length < this.#buffer.length) {
|
|
6551
|
+
const checkpoint = this.work.charge(bytes3.length);
|
|
6552
|
+
this.#buffer.set(bytes3, this.#used);
|
|
6553
|
+
this.#used += bytes3.length;
|
|
6554
|
+
return checkpoint;
|
|
6555
|
+
}
|
|
6556
|
+
return this.#writeSlow(bytes3);
|
|
6557
|
+
}
|
|
6558
|
+
async #writeSlow(bytes3) {
|
|
6515
6559
|
for (let offset = 0; offset < bytes3.length; ) {
|
|
6516
6560
|
const length = Math.min(4096, bytes3.length - offset, this.#buffer.length - this.#used);
|
|
6517
6561
|
const checkpoint = this.work.charge(length);
|
|
@@ -6538,7 +6582,16 @@ var CutOutput = class {
|
|
|
6538
6582
|
await output(this.context, bytes3);
|
|
6539
6583
|
}
|
|
6540
6584
|
};
|
|
6541
|
-
|
|
6585
|
+
function cutFieldBoundary(record3, separator, start, work) {
|
|
6586
|
+
if (record3.length - start <= 4096) {
|
|
6587
|
+
const found = separator.length === 1 ? record3.indexOf(separator[0], start) : record3.indexOf(separator, start);
|
|
6588
|
+
const charged = found < 0 ? record3.length - start : found - start + separator.length;
|
|
6589
|
+
const checkpoint = work.charge(charged);
|
|
6590
|
+
return checkpoint ? checkpoint.then(() => found) : found;
|
|
6591
|
+
}
|
|
6592
|
+
return cutFieldBoundarySlow(record3, separator, start, work);
|
|
6593
|
+
}
|
|
6594
|
+
async function cutFieldBoundarySlow(record3, separator, start, work) {
|
|
6542
6595
|
for (let offset = start; offset < record3.length; offset += 4096) {
|
|
6543
6596
|
const window = record3.subarray(offset, Math.min(record3.length, offset + 4096 + separator.length - 1));
|
|
6544
6597
|
const found = window.indexOf(separator);
|
|
@@ -6595,13 +6648,35 @@ function fold(bytes3) {
|
|
|
6595
6648
|
return bytes3.map((byte) => byte >= 97 && byte <= 122 ? byte - 32 : byte);
|
|
6596
6649
|
}
|
|
6597
6650
|
function parseNumericSync(bytes3, human = false) {
|
|
6598
|
-
const
|
|
6599
|
-
const
|
|
6600
|
-
|
|
6651
|
+
const buf = import_buffer.Buffer.from(bytes3);
|
|
6652
|
+
const len = bytes3.length;
|
|
6653
|
+
let i = 0;
|
|
6654
|
+
while (i < len && (bytes3[i] === 32 || bytes3[i] === 9)) i++;
|
|
6655
|
+
let neg = false;
|
|
6656
|
+
if (i < len && bytes3[i] === 45) {
|
|
6657
|
+
neg = true;
|
|
6658
|
+
i++;
|
|
6659
|
+
}
|
|
6660
|
+
let wholeStart = i;
|
|
6661
|
+
while (wholeStart < len && bytes3[wholeStart] === 48) wholeStart++;
|
|
6662
|
+
let wholeEnd = wholeStart;
|
|
6663
|
+
while (wholeEnd < len && bytes3[wholeEnd] >= 48 && bytes3[wholeEnd] <= 57) wholeEnd++;
|
|
6664
|
+
i = wholeEnd;
|
|
6665
|
+
let fracStart = 0;
|
|
6666
|
+
let fracEnd = 0;
|
|
6667
|
+
if (i < len && bytes3[i] === 46) {
|
|
6668
|
+
i++;
|
|
6669
|
+
fracStart = i;
|
|
6670
|
+
while (i < len && bytes3[i] >= 48 && bytes3[i] <= 57) i++;
|
|
6671
|
+
fracEnd = i;
|
|
6672
|
+
while (fracEnd > fracStart && bytes3[fracEnd - 1] === 48) fracEnd--;
|
|
6673
|
+
}
|
|
6674
|
+
const whole = wholeEnd > wholeStart ? buf.toString("latin1", wholeStart, wholeEnd) : "0";
|
|
6675
|
+
const fraction = fracEnd > fracStart ? buf.toString("latin1", fracStart, fracEnd) : "";
|
|
6601
6676
|
const nonzero = whole !== "0" || fraction !== "";
|
|
6602
|
-
const suffix2 = bytes3[
|
|
6677
|
+
const suffix2 = bytes3[i];
|
|
6603
6678
|
const suffixRank = human && nonzero ? "KMGTPEZYRQ".indexOf(String.fromCharCode(suffix2 === 107 ? 75 : suffix2 ?? 0)) + 1 : 0;
|
|
6604
|
-
return { whole, fraction, negative:
|
|
6679
|
+
return { whole, fraction, negative: neg && nonzero, suffixRank };
|
|
6605
6680
|
}
|
|
6606
6681
|
function parseNumeric(bytes3, work, human = false) {
|
|
6607
6682
|
const checkpoint = work.charge(bytes3.length);
|
|
@@ -6853,6 +6928,45 @@ async function mergeSortRuns(runs, compare6, work) {
|
|
|
6853
6928
|
}
|
|
6854
6929
|
return runs[0] ?? [];
|
|
6855
6930
|
}
|
|
6931
|
+
function keyBytesSync(line, key, separator, blanks, work) {
|
|
6932
|
+
if (line.length > 1024) return keyBytes(line, key, separator, blanks, work);
|
|
6933
|
+
const fields4 = [];
|
|
6934
|
+
if (separator !== void 0) {
|
|
6935
|
+
let start2 = 0;
|
|
6936
|
+
for (let offset = 0; offset <= line.length; offset++) {
|
|
6937
|
+
if (offset === line.length || line[offset] === separator) {
|
|
6938
|
+
fields4.push({ start: start2, end: offset });
|
|
6939
|
+
start2 = offset + 1;
|
|
6940
|
+
}
|
|
6941
|
+
}
|
|
6942
|
+
} else {
|
|
6943
|
+
let offset = 0;
|
|
6944
|
+
while (offset < line.length) {
|
|
6945
|
+
const leading = offset;
|
|
6946
|
+
while (offset < line.length && (line[offset] === 32 || line[offset] === 9)) offset++;
|
|
6947
|
+
const start2 = leading;
|
|
6948
|
+
if (offset === line.length) break;
|
|
6949
|
+
while (offset < line.length && line[offset] !== 32 && line[offset] !== 9) offset++;
|
|
6950
|
+
fields4.push({ start: start2, end: offset });
|
|
6951
|
+
}
|
|
6952
|
+
}
|
|
6953
|
+
let extraCharge = line.length;
|
|
6954
|
+
const fieldStart = (field2, skipBlanks) => {
|
|
6955
|
+
let offset = field2?.start ?? line.length;
|
|
6956
|
+
if (skipBlanks) while (offset < (field2?.end ?? line.length) && (line[offset] === 32 || line[offset] === 9)) {
|
|
6957
|
+
extraCharge++;
|
|
6958
|
+
offset++;
|
|
6959
|
+
}
|
|
6960
|
+
return offset;
|
|
6961
|
+
};
|
|
6962
|
+
const inheritBlanks = key.flags.size === 0 && blanks;
|
|
6963
|
+
const start = fieldStart(fields4[key.start - 1], key.startBlanks || inheritBlanks) + key.startCharacter - 1;
|
|
6964
|
+
const last = key.end === void 0 ? void 0 : fields4[key.end - 1];
|
|
6965
|
+
const end = key.end === void 0 ? line.length : last === void 0 ? line.length : key.endCharacter === void 0 ? last.end : Math.min(line.length, fieldStart(last, key.endBlanks || inheritBlanks) + key.endCharacter);
|
|
6966
|
+
const result = line.subarray(Math.min(start, line.length), Math.max(start, end));
|
|
6967
|
+
const checkpoint = work.charge(extraCharge);
|
|
6968
|
+
return checkpoint ? checkpoint.then(() => result) : result;
|
|
6969
|
+
}
|
|
6856
6970
|
async function keyBytes(line, key, separator, blanks, work) {
|
|
6857
6971
|
const fields4 = [];
|
|
6858
6972
|
if (separator !== void 0) {
|
|
@@ -6924,8 +7038,9 @@ async function collectSortRecords(source2, delimiter, budget, signal, accept) {
|
|
|
6924
7038
|
try {
|
|
6925
7039
|
for await (const chunk of source2) {
|
|
6926
7040
|
let start = 0;
|
|
6927
|
-
|
|
6928
|
-
|
|
7041
|
+
while (start < chunk.length) {
|
|
7042
|
+
const offset = chunk.indexOf(delimiter, start);
|
|
7043
|
+
if (offset < 0) break;
|
|
6929
7044
|
const accepted = accept(pending.finish(admit2, chunk, start, offset));
|
|
6930
7045
|
if ((accepted instanceof Promise ? await accepted : accepted) === false) return false;
|
|
6931
7046
|
start = offset + 1;
|
|
@@ -7039,8 +7154,20 @@ function textCommands() {
|
|
|
7039
7154
|
const cached = keyedNumericValues.get(record3);
|
|
7040
7155
|
if (cached !== void 0) return cached;
|
|
7041
7156
|
context2.signal.throwIfAborted();
|
|
7157
|
+
const bytesOrPromise = keyBytesSync(record3, numericKey, separator, false, work);
|
|
7158
|
+
if (!(bytesOrPromise instanceof Promise)) {
|
|
7159
|
+
const charge2 = 6 * bytesOrPromise.length + 10;
|
|
7160
|
+
const parsedOrPromise = parseNumeric(bytesOrPromise, work, numericKeyFlags.has("h"));
|
|
7161
|
+
if (!(parsedOrPromise instanceof Promise)) {
|
|
7162
|
+
if (keyedNumericValues.size < 16384 && charge2 <= 1048576 - retainedKeyBytes) {
|
|
7163
|
+
keyedNumericValues.set(record3, parsedOrPromise);
|
|
7164
|
+
retainedKeyBytes += charge2;
|
|
7165
|
+
}
|
|
7166
|
+
return parsedOrPromise;
|
|
7167
|
+
}
|
|
7168
|
+
}
|
|
7042
7169
|
return (async () => {
|
|
7043
|
-
const bytes3 = await
|
|
7170
|
+
const bytes3 = await bytesOrPromise;
|
|
7044
7171
|
const charge2 = 6 * bytes3.length + 10;
|
|
7045
7172
|
if (keyedNumericValues.size >= 16384 || charge2 > 1048576 - retainedKeyBytes) return await parseNumeric(bytes3, work, numericKeyFlags.has("h"));
|
|
7046
7173
|
const parsedValue = await parseNumeric(bytes3, work, numericKeyFlags.has("h"));
|
|
@@ -7273,10 +7400,12 @@ function textCommands() {
|
|
|
7273
7400
|
};
|
|
7274
7401
|
if (mode === "f") {
|
|
7275
7402
|
const record3 = import_buffer.Buffer.from(line.bytes.buffer, line.bytes.byteOffset, line.bytes.byteLength);
|
|
7276
|
-
|
|
7403
|
+
const b0 = cutFieldBoundary(record3, separator, 0, work);
|
|
7404
|
+
let boundary = typeof b0 === "number" ? b0 : await b0;
|
|
7277
7405
|
if (boundary < 0) {
|
|
7278
7406
|
if (parsed.flags.has("s")) continue;
|
|
7279
|
-
|
|
7407
|
+
const w = writer.write(line.bytes);
|
|
7408
|
+
if (w) await w;
|
|
7280
7409
|
} else {
|
|
7281
7410
|
let field2 = 1;
|
|
7282
7411
|
let start = 0;
|
|
@@ -7285,13 +7414,18 @@ function textCommands() {
|
|
|
7285
7414
|
const checkpoint = work.charge();
|
|
7286
7415
|
if (checkpoint) await checkpoint;
|
|
7287
7416
|
if (selected2(field2++) >= 0) {
|
|
7288
|
-
if (emitted)
|
|
7289
|
-
|
|
7417
|
+
if (emitted) {
|
|
7418
|
+
const w1 = writer.write(outputDelimiterBytes);
|
|
7419
|
+
if (w1) await w1;
|
|
7420
|
+
}
|
|
7421
|
+
const w2 = writer.write(record3.subarray(start, boundary < 0 ? record3.length : boundary));
|
|
7422
|
+
if (w2) await w2;
|
|
7290
7423
|
emitted = true;
|
|
7291
7424
|
}
|
|
7292
|
-
if (boundary < 0) break;
|
|
7425
|
+
if (boundary < 0 || !complement && cursor >= ranges2.length) break;
|
|
7293
7426
|
start = boundary + separator.length;
|
|
7294
|
-
|
|
7427
|
+
const bn = cutFieldBoundary(record3, separator, start, work);
|
|
7428
|
+
boundary = typeof bn === "number" ? bn : await bn;
|
|
7295
7429
|
}
|
|
7296
7430
|
}
|
|
7297
7431
|
} else if (byteSelection) {
|
|
@@ -7348,7 +7482,8 @@ function textCommands() {
|
|
|
7348
7482
|
if (start >= 0) await writer.text(text3.slice(start));
|
|
7349
7483
|
}
|
|
7350
7484
|
}
|
|
7351
|
-
|
|
7485
|
+
const wd = writer.write(recordDelimiterBytes);
|
|
7486
|
+
if (wd) await wd;
|
|
7352
7487
|
}
|
|
7353
7488
|
} finally {
|
|
7354
7489
|
await writer.flush();
|
|
@@ -14120,6 +14255,8 @@ ${error.extra}${error.help ? "Try 'numfmt --help' for more information.\n" : ""}
|
|
|
14120
14255
|
}
|
|
14121
14256
|
|
|
14122
14257
|
// packages/safe-bash/src/commands/standard.ts
|
|
14258
|
+
var defaultBaseStandardCommands;
|
|
14259
|
+
var defaultTailStandardCommands;
|
|
14123
14260
|
function createStandardCommandsWithGrep(options2, grep) {
|
|
14124
14261
|
const commands = [];
|
|
14125
14262
|
const execute3 = directExecutor(options2.execute ?? (async (context2) => {
|
|
@@ -14128,6 +14265,29 @@ function createStandardCommandsWithGrep(options2, grep) {
|
|
|
14128
14265
|
await diagnostic(context2, new PublicDiagnostic("command not found"));
|
|
14129
14266
|
return { exitCode: 127 };
|
|
14130
14267
|
}));
|
|
14268
|
+
if (options2.maxDirectoryEntries === void 0 && options2.maxTeeTargets === void 0 && options2.maxTailFollowHandles === void 0 && options2.predicateIdentity === void 0) {
|
|
14269
|
+
defaultBaseStandardCommands ??= Object.freeze([
|
|
14270
|
+
...basicCommands(),
|
|
14271
|
+
...filesystemCommands(void 0),
|
|
14272
|
+
...streamCommands(void 0, void 0),
|
|
14273
|
+
...textCommands()
|
|
14274
|
+
]);
|
|
14275
|
+
defaultTailStandardCommands ??= Object.freeze([
|
|
14276
|
+
...predicateCommands(void 0),
|
|
14277
|
+
cmpCommand(),
|
|
14278
|
+
fmtCommand(),
|
|
14279
|
+
shufCommand(),
|
|
14280
|
+
numfmtCommand()
|
|
14281
|
+
]);
|
|
14282
|
+
commands.push(
|
|
14283
|
+
...defaultBaseStandardCommands,
|
|
14284
|
+
...grep,
|
|
14285
|
+
...defaultTailStandardCommands,
|
|
14286
|
+
...executionCommands(execute3, options2.execution),
|
|
14287
|
+
...findCommands(execute3, void 0)
|
|
14288
|
+
);
|
|
14289
|
+
return commands;
|
|
14290
|
+
}
|
|
14131
14291
|
commands.push(...basicCommands(), ...filesystemCommands(options2.maxDirectoryEntries), ...streamCommands(options2.maxTeeTargets, options2.maxTailFollowHandles), ...textCommands(), ...grep, ...predicateCommands(options2.predicateIdentity), ...executionCommands(execute3, options2.execution), ...findCommands(execute3, options2.maxDirectoryEntries));
|
|
14132
14292
|
commands.push(cmpCommand(), fmtCommand(), shufCommand(), numfmtCommand());
|
|
14133
14293
|
return commands;
|
|
@@ -14460,30 +14620,90 @@ async function* nullRecords(context2, files, budget) {
|
|
|
14460
14620
|
}
|
|
14461
14621
|
}
|
|
14462
14622
|
async function execute(program, context2, files, quiet, budget, separator, outputState, lineLength) {
|
|
14463
|
-
const
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14623
|
+
const useBatches = separator !== "\0";
|
|
14624
|
+
const batchSource = useBatches ? lineRecordBatches(context2, files, budget) : void 0;
|
|
14625
|
+
const singleSource = useBatches ? void 0 : nullRecords(context2, files, budget);
|
|
14626
|
+
let currentBatch = [];
|
|
14627
|
+
let batchIndex = 0;
|
|
14628
|
+
let currentRecord;
|
|
14629
|
+
let followingRecord;
|
|
14630
|
+
if (batchSource) {
|
|
14631
|
+
const firstBatch = await batchSource.next();
|
|
14632
|
+
if (!firstBatch.done && firstBatch.value.length > 0) {
|
|
14633
|
+
currentBatch = firstBatch.value;
|
|
14634
|
+
currentRecord = currentBatch[0];
|
|
14635
|
+
batchIndex = 1;
|
|
14636
|
+
}
|
|
14637
|
+
} else {
|
|
14638
|
+
const first = await singleSource.next();
|
|
14639
|
+
if (!first.done) currentRecord = first.value;
|
|
14640
|
+
}
|
|
14641
|
+
const peekNextRecord = async () => {
|
|
14642
|
+
if (followingRecord !== void 0) return followingRecord ?? void 0;
|
|
14643
|
+
if (batchSource) {
|
|
14644
|
+
if (batchIndex < currentBatch.length) {
|
|
14645
|
+
followingRecord = currentBatch[batchIndex];
|
|
14646
|
+
return followingRecord;
|
|
14647
|
+
}
|
|
14648
|
+
const nextBatch = await batchSource.next();
|
|
14649
|
+
if (nextBatch.done || nextBatch.value.length === 0) {
|
|
14650
|
+
followingRecord = null;
|
|
14651
|
+
return void 0;
|
|
14652
|
+
}
|
|
14653
|
+
currentBatch = nextBatch.value;
|
|
14654
|
+
batchIndex = 0;
|
|
14655
|
+
followingRecord = currentBatch[0];
|
|
14656
|
+
return followingRecord;
|
|
14657
|
+
}
|
|
14658
|
+
const next = await singleSource.next();
|
|
14659
|
+
followingRecord = next.done ? null : next.value;
|
|
14660
|
+
return followingRecord ?? void 0;
|
|
14661
|
+
};
|
|
14662
|
+
const readNextRecord = async () => {
|
|
14663
|
+
if (followingRecord !== void 0) {
|
|
14664
|
+
const next2 = followingRecord ?? void 0;
|
|
14665
|
+
followingRecord = void 0;
|
|
14666
|
+
if (batchSource && next2 !== void 0 && batchIndex < currentBatch.length && currentBatch[batchIndex] === next2) {
|
|
14667
|
+
batchIndex++;
|
|
14668
|
+
}
|
|
14669
|
+
return next2;
|
|
14670
|
+
}
|
|
14671
|
+
if (batchSource) {
|
|
14672
|
+
if (batchIndex < currentBatch.length) return currentBatch[batchIndex++];
|
|
14673
|
+
const nextBatch = await batchSource.next();
|
|
14674
|
+
if (nextBatch.done || nextBatch.value.length === 0) return void 0;
|
|
14675
|
+
currentBatch = nextBatch.value;
|
|
14676
|
+
batchIndex = 1;
|
|
14677
|
+
return currentBatch[0];
|
|
14678
|
+
}
|
|
14679
|
+
const next = await singleSource.next();
|
|
14680
|
+
return next.done ? void 0 : next.value;
|
|
14471
14681
|
};
|
|
14472
|
-
const prepareRecord = async (
|
|
14473
|
-
if (
|
|
14474
|
-
const next = await
|
|
14475
|
-
return
|
|
14682
|
+
const prepareRecord = async (record4) => {
|
|
14683
|
+
if (record4.terminated || files.length < 2) return record4;
|
|
14684
|
+
const next = await peekNextRecord();
|
|
14685
|
+
return next !== void 0 && next.fileIndex !== record4.fileIndex ? { ...record4, terminated: true } : record4;
|
|
14476
14686
|
};
|
|
14477
14687
|
let number6 = 0;
|
|
14478
14688
|
let hold = "";
|
|
14479
14689
|
let holdTerminated = true;
|
|
14690
|
+
let stdoutBuffer = "";
|
|
14691
|
+
const flushStdout = async () => {
|
|
14692
|
+
if (stdoutBuffer.length > 0) {
|
|
14693
|
+
const chunk = stdoutBuffer;
|
|
14694
|
+
stdoutBuffer = "";
|
|
14695
|
+
await write(context2, chunk);
|
|
14696
|
+
}
|
|
14697
|
+
};
|
|
14480
14698
|
const joinSpace = (left, right) => {
|
|
14481
14699
|
if (left.length + separator.length + right.length > budget.maxBufferBytes) throw new ProgramError("text buffer limit exceeded");
|
|
14482
14700
|
return left + separator + right;
|
|
14483
14701
|
};
|
|
14484
|
-
const emit2 =
|
|
14485
|
-
|
|
14702
|
+
const emit2 = (text3, terminated = true) => {
|
|
14703
|
+
stdoutBuffer += (outputState.stdoutUnterminated ? separator : "") + text3;
|
|
14486
14704
|
outputState.stdoutUnterminated = !terminated;
|
|
14705
|
+
if (stdoutBuffer.length >= 16384) return flushStdout();
|
|
14706
|
+
return void 0;
|
|
14487
14707
|
};
|
|
14488
14708
|
let lastPattern;
|
|
14489
14709
|
const active = /* @__PURE__ */ new Set();
|
|
@@ -14491,69 +14711,101 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
|
|
|
14491
14711
|
const first = program[pc].first;
|
|
14492
14712
|
if (first?.kind === "number" && first.number === 0) active.add(pc);
|
|
14493
14713
|
}
|
|
14494
|
-
const getPattern = (
|
|
14495
|
-
if (
|
|
14714
|
+
const getPattern = (pattern2) => {
|
|
14715
|
+
if (pattern2) lastPattern = pattern2;
|
|
14496
14716
|
if (!lastPattern) throw new ProgramError("no previous regular expression");
|
|
14497
14717
|
return lastPattern;
|
|
14498
14718
|
};
|
|
14719
|
+
const appended = [];
|
|
14720
|
+
let appendedSize = 0;
|
|
14721
|
+
const append = (item) => {
|
|
14722
|
+
appendedSize += (item.text ?? item.file ?? "").length + 32;
|
|
14723
|
+
if (appendedSize > budget.maxBufferBytes) throw new ProgramError("append queue buffer limit exceeded");
|
|
14724
|
+
appended.push(item);
|
|
14725
|
+
};
|
|
14726
|
+
let record3;
|
|
14727
|
+
let pattern = "";
|
|
14728
|
+
let substituted = false;
|
|
14729
|
+
let deleted = false;
|
|
14730
|
+
let quit = false;
|
|
14731
|
+
let status2 = 0;
|
|
14732
|
+
const print = () => emit2(pattern + (record3.terminated ? separator : ""), record3.terminated);
|
|
14733
|
+
const flushSlow = async (printPattern) => {
|
|
14734
|
+
if (appended.length > 0) {
|
|
14735
|
+
await assertPathRequirements(context2, sedRequirements, ["script-read"], appended.flatMap((item) => item.file === void 0 ? [] : [item.file]));
|
|
14736
|
+
}
|
|
14737
|
+
if (printPattern && !quiet && !deleted) {
|
|
14738
|
+
const p = print();
|
|
14739
|
+
if (p) await p;
|
|
14740
|
+
}
|
|
14741
|
+
if (outputState.stdoutUnterminated && (appended.length || quit)) {
|
|
14742
|
+
stdoutBuffer += separator;
|
|
14743
|
+
if (stdoutBuffer.length >= 16384) await flushStdout();
|
|
14744
|
+
outputState.stdoutUnterminated = false;
|
|
14745
|
+
}
|
|
14746
|
+
for (const item of appended) {
|
|
14747
|
+
if (item.text !== void 0) {
|
|
14748
|
+
stdoutBuffer += item.text;
|
|
14749
|
+
if (stdoutBuffer.length >= 16384) await flushStdout();
|
|
14750
|
+
continue;
|
|
14751
|
+
}
|
|
14752
|
+
await flushStdout();
|
|
14753
|
+
const path = virtualPath(context2, item.file);
|
|
14754
|
+
try {
|
|
14755
|
+
for await (const chunk of requiredFileInput(context2, sedRequirements, "script-read", path, budget.maxBufferBytes)) {
|
|
14756
|
+
budget.step();
|
|
14757
|
+
const pendingCheck = budget.checkpointSync();
|
|
14758
|
+
if (pendingCheck) await pendingCheck;
|
|
14759
|
+
if (chunk.byteLength > budget.maxBufferBytes) throw new ProgramError("read buffer limit exceeded");
|
|
14760
|
+
await (0, contracts_exports.writeBytes)(context2.stdout, chunk, context2.signal);
|
|
14761
|
+
}
|
|
14762
|
+
} catch (error) {
|
|
14763
|
+
context2.signal.throwIfAborted();
|
|
14764
|
+
if (!(error instanceof contracts_exports.FsError) || !["ENOENT", "EACCES", "EPERM", "EISDIR", "ENOTDIR"].includes(error.code)) throw error;
|
|
14765
|
+
}
|
|
14766
|
+
}
|
|
14767
|
+
appended.length = 0;
|
|
14768
|
+
appendedSize = 0;
|
|
14769
|
+
};
|
|
14770
|
+
const flush = (printPattern = true) => {
|
|
14771
|
+
if (appended.length === 0 && (!outputState.stdoutUnterminated || !quit)) {
|
|
14772
|
+
if (printPattern && !quiet && !deleted) return print();
|
|
14773
|
+
return void 0;
|
|
14774
|
+
}
|
|
14775
|
+
return flushSlow(printPattern);
|
|
14776
|
+
};
|
|
14777
|
+
const writeFile = async (file) => {
|
|
14778
|
+
const path = virtualPath(context2, file);
|
|
14779
|
+
const terminated = record3.terminated || separator === "\n";
|
|
14780
|
+
const text3 = (outputState.unterminatedFiles.has(path) ? separator : "") + pattern + (terminated ? separator : "");
|
|
14781
|
+
await writeFileOutput(context2, bytes(text3), (chunk) => context2.fs.appendFile(path, chunk, { signal: context2.signal }));
|
|
14782
|
+
if (terminated) outputState.unterminatedFiles.delete(path);
|
|
14783
|
+
else outputState.unterminatedFiles.add(path);
|
|
14784
|
+
};
|
|
14785
|
+
const matches2 = (address) => {
|
|
14786
|
+
if (address.kind === "number") return number6 === address.number;
|
|
14787
|
+
if (address.kind === "last") {
|
|
14788
|
+
if (batchSource && batchIndex < currentBatch.length) return false;
|
|
14789
|
+
return peekNextRecord().then((next) => next === void 0);
|
|
14790
|
+
}
|
|
14791
|
+
const found = getPattern(address.pattern).tryFindSync(pattern, budget);
|
|
14792
|
+
if (found instanceof Promise) return found.then((res) => res !== void 0);
|
|
14793
|
+
return found !== void 0;
|
|
14794
|
+
};
|
|
14499
14795
|
try {
|
|
14500
|
-
while (
|
|
14796
|
+
while (currentRecord !== void 0) {
|
|
14501
14797
|
budget.step();
|
|
14502
14798
|
number6++;
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
|
|
14509
|
-
if (appendedSize > budget.maxBufferBytes) throw new ProgramError("append queue buffer limit exceeded");
|
|
14510
|
-
appended.push(item);
|
|
14511
|
-
};
|
|
14512
|
-
let substituted = false;
|
|
14513
|
-
let deleted = false;
|
|
14514
|
-
let quit = false;
|
|
14515
|
-
let status2 = 0;
|
|
14516
|
-
const print = () => emit2(pattern + (record3.terminated ? separator : ""), record3.terminated);
|
|
14517
|
-
const flush = async (printPattern = true) => {
|
|
14518
|
-
await assertPathRequirements(context2, sedRequirements, ["script-read"], appended.flatMap((item) => item.file === void 0 ? [] : [item.file]));
|
|
14519
|
-
if (printPattern && !quiet && !deleted) await print();
|
|
14520
|
-
if (outputState.stdoutUnterminated && (appended.length || quit)) {
|
|
14521
|
-
await write(context2, separator);
|
|
14522
|
-
outputState.stdoutUnterminated = false;
|
|
14523
|
-
}
|
|
14524
|
-
for (const item of appended) {
|
|
14525
|
-
if (item.text !== void 0) {
|
|
14526
|
-
await write(context2, item.text);
|
|
14527
|
-
continue;
|
|
14528
|
-
}
|
|
14529
|
-
const path = virtualPath(context2, item.file);
|
|
14530
|
-
try {
|
|
14531
|
-
for await (const chunk of requiredFileInput(context2, sedRequirements, "script-read", path, budget.maxBufferBytes)) {
|
|
14532
|
-
budget.step();
|
|
14533
|
-
await budget.checkpoint();
|
|
14534
|
-
if (chunk.byteLength > budget.maxBufferBytes) throw new ProgramError("read buffer limit exceeded");
|
|
14535
|
-
await (0, contracts_exports.writeBytes)(context2.stdout, chunk, context2.signal);
|
|
14536
|
-
}
|
|
14537
|
-
} catch (error) {
|
|
14538
|
-
context2.signal.throwIfAborted();
|
|
14539
|
-
if (!(error instanceof contracts_exports.FsError) || !["ENOENT", "EACCES", "EPERM", "EISDIR", "ENOTDIR"].includes(error.code)) throw error;
|
|
14540
|
-
}
|
|
14541
|
-
}
|
|
14542
|
-
appended.length = 0;
|
|
14543
|
-
appendedSize = 0;
|
|
14544
|
-
};
|
|
14545
|
-
const writeFile = async (file) => {
|
|
14546
|
-
const path = virtualPath(context2, file);
|
|
14547
|
-
const terminated = record3.terminated || separator === "\n";
|
|
14548
|
-
const text3 = (outputState.unterminatedFiles.has(path) ? separator : "") + pattern + (terminated ? separator : "");
|
|
14549
|
-
await writeFileOutput(context2, bytes(text3), (chunk) => context2.fs.appendFile(path, chunk, { signal: context2.signal }));
|
|
14550
|
-
if (terminated) outputState.unterminatedFiles.delete(path);
|
|
14551
|
-
else outputState.unterminatedFiles.add(path);
|
|
14552
|
-
};
|
|
14553
|
-
const matches2 = async (address) => address.kind === "number" ? number6 === address.number : address.kind === "last" ? (await peekNext()).done === true : await getPattern(address.pattern).find(pattern, budget) !== void 0;
|
|
14799
|
+
record3 = currentRecord.terminated || files.length < 2 ? currentRecord : await prepareRecord(currentRecord);
|
|
14800
|
+
pattern = record3.text;
|
|
14801
|
+
substituted = false;
|
|
14802
|
+
deleted = false;
|
|
14803
|
+
quit = false;
|
|
14804
|
+
status2 = 0;
|
|
14554
14805
|
for (let pc = 0; pc < program.length; ) {
|
|
14555
14806
|
budget.step();
|
|
14556
|
-
|
|
14807
|
+
const pendingCheck = budget.checkpointSync();
|
|
14808
|
+
if (pendingCheck) await pendingCheck;
|
|
14557
14809
|
const instruction = program[pc];
|
|
14558
14810
|
let selected2 = true;
|
|
14559
14811
|
let ending = false;
|
|
@@ -14561,16 +14813,21 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
|
|
|
14561
14813
|
if (instruction.second) {
|
|
14562
14814
|
if (active.has(pc)) {
|
|
14563
14815
|
if (instruction.second.kind === "number" && number6 > instruction.second.number) selected2 = false;
|
|
14564
|
-
|
|
14816
|
+
const endMatch = instruction.second.kind === "number" ? number6 >= instruction.second.number : matches2(instruction.second);
|
|
14817
|
+
ending = endMatch instanceof Promise ? await endMatch : endMatch;
|
|
14565
14818
|
if (ending) active.delete(pc);
|
|
14566
14819
|
} else {
|
|
14567
|
-
|
|
14820
|
+
const firstMatch = matches2(instruction.first);
|
|
14821
|
+
selected2 = firstMatch instanceof Promise ? await firstMatch : firstMatch;
|
|
14568
14822
|
if (selected2) {
|
|
14569
|
-
ending = instruction.second.kind === "number" && number6 >= instruction.second.number || instruction.second.kind === "last" &&
|
|
14823
|
+
ending = instruction.second.kind === "number" && number6 >= instruction.second.number || instruction.second.kind === "last" && await peekNextRecord() === void 0;
|
|
14570
14824
|
if (!ending) active.add(pc);
|
|
14571
14825
|
}
|
|
14572
14826
|
}
|
|
14573
|
-
} else
|
|
14827
|
+
} else {
|
|
14828
|
+
const firstMatch = matches2(instruction.first);
|
|
14829
|
+
selected2 = firstMatch instanceof Promise ? await firstMatch : firstMatch;
|
|
14830
|
+
}
|
|
14574
14831
|
}
|
|
14575
14832
|
if (instruction.negate) selected2 = !selected2;
|
|
14576
14833
|
if (!selected2) {
|
|
@@ -14578,23 +14835,28 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
|
|
|
14578
14835
|
continue;
|
|
14579
14836
|
}
|
|
14580
14837
|
switch (instruction.kind) {
|
|
14581
|
-
case "p":
|
|
14582
|
-
|
|
14838
|
+
case "p": {
|
|
14839
|
+
const p = print();
|
|
14840
|
+
if (p) await p;
|
|
14583
14841
|
break;
|
|
14842
|
+
}
|
|
14584
14843
|
case "P": {
|
|
14585
14844
|
const end = pattern.indexOf(separator);
|
|
14586
|
-
|
|
14845
|
+
const p = emit2(end < 0 ? pattern + (record3.terminated ? separator : "") : pattern.slice(0, end + 1), end >= 0 || record3.terminated);
|
|
14846
|
+
if (p) await p;
|
|
14587
14847
|
break;
|
|
14588
14848
|
}
|
|
14589
|
-
case "=":
|
|
14590
|
-
|
|
14849
|
+
case "=": {
|
|
14850
|
+
const p = emit2(`${number6}${separator}`);
|
|
14851
|
+
if (p) await p;
|
|
14591
14852
|
break;
|
|
14853
|
+
}
|
|
14592
14854
|
case "l": {
|
|
14593
14855
|
const escapes2 = { "\x07": "\\a", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", " ": "\\t", "\v": "\\v", "\\": "\\\\" };
|
|
14594
14856
|
let line = "";
|
|
14595
14857
|
for (let offset = 0; offset <= pattern.length; offset++) {
|
|
14596
14858
|
budget.step();
|
|
14597
|
-
await budget.
|
|
14859
|
+
await budget.checkpointSync();
|
|
14598
14860
|
const character = pattern[offset];
|
|
14599
14861
|
const lineEnd = character === "\n" && separator === "\n";
|
|
14600
14862
|
const token = character === void 0 || lineEnd ? "$" : escapes2[character] ?? (character.charCodeAt(0) < 32 || character.charCodeAt(0) >= 127 ? `\\${character.charCodeAt(0).toString(8).padStart(3, "0")}` : character);
|
|
@@ -14644,7 +14906,7 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
|
|
|
14644
14906
|
await emit2(instruction.text);
|
|
14645
14907
|
break;
|
|
14646
14908
|
case "c":
|
|
14647
|
-
if (!instruction.second || ending || instruction.negate ||
|
|
14909
|
+
if (!instruction.second || ending || instruction.negate || await peekNextRecord() === void 0) await emit2(instruction.text);
|
|
14648
14910
|
deleted = true;
|
|
14649
14911
|
pc = program.length;
|
|
14650
14912
|
continue;
|
|
@@ -14674,11 +14936,15 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
|
|
|
14674
14936
|
case "s": {
|
|
14675
14937
|
const expression = getPattern(instruction.pattern);
|
|
14676
14938
|
if (instruction.replacementGroupCount > expression.groupCount) throw new ProgramError("replacement references an undefined capture group");
|
|
14677
|
-
const
|
|
14939
|
+
const changedOrPromise = trySubstituteSync(pattern, expression, instruction.replacement, budget, instruction.global ?? false, instruction.occurrence ?? 1);
|
|
14940
|
+
const changed = changedOrPromise instanceof Promise ? await changedOrPromise : changedOrPromise;
|
|
14678
14941
|
pattern = changed.text;
|
|
14679
14942
|
if (changed.count) {
|
|
14680
14943
|
substituted = true;
|
|
14681
|
-
if (instruction.print)
|
|
14944
|
+
if (instruction.print) {
|
|
14945
|
+
const p = print();
|
|
14946
|
+
if (p) await p;
|
|
14947
|
+
}
|
|
14682
14948
|
if (instruction.file) await writeFile(instruction.file);
|
|
14683
14949
|
}
|
|
14684
14950
|
break;
|
|
@@ -14687,7 +14953,7 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
|
|
|
14687
14953
|
budget.step(pattern.length);
|
|
14688
14954
|
const translated = import_buffer.Buffer.allocUnsafe(pattern.length);
|
|
14689
14955
|
for (let index = 0; index < pattern.length; index++) {
|
|
14690
|
-
if (index % 256 === 0) await budget.
|
|
14956
|
+
if (index % 256 === 0) await budget.checkpointSync();
|
|
14691
14957
|
translated[index] = (instruction.translation.get(pattern[index]) ?? pattern[index]).charCodeAt(0);
|
|
14692
14958
|
}
|
|
14693
14959
|
pattern = translated.toString("latin1");
|
|
@@ -14708,14 +14974,22 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
|
|
|
14708
14974
|
}
|
|
14709
14975
|
case "n":
|
|
14710
14976
|
case "N": {
|
|
14711
|
-
if (instruction.kind === "n")
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
if (
|
|
14715
|
-
|
|
14977
|
+
if (instruction.kind === "n") {
|
|
14978
|
+
const p = flush();
|
|
14979
|
+
if (p) await p;
|
|
14980
|
+
} else if (separator === "\0" && await peekNextRecord() !== void 0) {
|
|
14981
|
+
const p = flush(false);
|
|
14982
|
+
if (p) await p;
|
|
14983
|
+
}
|
|
14984
|
+
const next = await readNextRecord();
|
|
14985
|
+
if (next === void 0) {
|
|
14986
|
+
if (instruction.kind === "N") {
|
|
14987
|
+
const p = flush();
|
|
14988
|
+
if (p) await p;
|
|
14989
|
+
}
|
|
14716
14990
|
return { status: 0, quit: false };
|
|
14717
14991
|
}
|
|
14718
|
-
record3 = await prepareRecord(next
|
|
14992
|
+
record3 = next.terminated || files.length < 2 ? next : await prepareRecord(next);
|
|
14719
14993
|
number6++;
|
|
14720
14994
|
pattern = instruction.kind === "N" ? joinSpace(pattern, record3.text) : record3.text;
|
|
14721
14995
|
substituted = false;
|
|
@@ -14724,13 +14998,16 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
|
|
|
14724
14998
|
}
|
|
14725
14999
|
pc++;
|
|
14726
15000
|
}
|
|
14727
|
-
|
|
15001
|
+
const flushPending = flush();
|
|
15002
|
+
if (flushPending) await flushPending;
|
|
14728
15003
|
if (quit) return { status: status2, quit: true };
|
|
14729
|
-
|
|
15004
|
+
currentRecord = followingRecord === void 0 && batchSource && batchIndex < currentBatch.length ? currentBatch[batchIndex++] : await readNextRecord();
|
|
14730
15005
|
}
|
|
14731
15006
|
return { status: 0, quit: false };
|
|
14732
15007
|
} finally {
|
|
14733
|
-
|
|
15008
|
+
if (stdoutBuffer.length > 0) await flushStdout();
|
|
15009
|
+
if (batchSource) await batchSource.return(void 0);
|
|
15010
|
+
else if (singleSource) await singleSource.return(void 0);
|
|
14734
15011
|
}
|
|
14735
15012
|
}
|
|
14736
15013
|
function sedCommand(options2 = {}) {
|
|
@@ -14881,6 +15158,25 @@ var unset = Object.freeze({ kind: "unset" });
|
|
|
14881
15158
|
var numeric2 = (number6) => ({ kind: "number", number: number6 });
|
|
14882
15159
|
var string = (text3) => ({ kind: "string", text: text3 });
|
|
14883
15160
|
function inputValue(text3) {
|
|
15161
|
+
const len = text3.length;
|
|
15162
|
+
if (len === 0) return string(text3);
|
|
15163
|
+
const first = text3.charCodeAt(0);
|
|
15164
|
+
if (first >= 48 && first <= 57 && len <= 15) {
|
|
15165
|
+
let num = first - 48;
|
|
15166
|
+
let allDigits = true;
|
|
15167
|
+
for (let i = 1; i < len; i++) {
|
|
15168
|
+
const c = text3.charCodeAt(i);
|
|
15169
|
+
if (c < 48 || c > 57) {
|
|
15170
|
+
allDigits = false;
|
|
15171
|
+
break;
|
|
15172
|
+
}
|
|
15173
|
+
num = num * 10 + (c - 48);
|
|
15174
|
+
}
|
|
15175
|
+
if (allDigits) return { kind: "numeric", text: text3, number: num };
|
|
15176
|
+
}
|
|
15177
|
+
if (first > 57 || first < 48 && first !== 32 && first !== 9 && first !== 10 && first !== 13 && first !== 43 && first !== 45 && first !== 46) {
|
|
15178
|
+
return string(text3);
|
|
15179
|
+
}
|
|
14884
15180
|
return /^[ \t\r\n]*[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?[ \t\r\n]*$/u.test(text3) ? { kind: "numeric", text: text3, number: Number(text3) } : string(text3);
|
|
14885
15181
|
}
|
|
14886
15182
|
function scalar(value2) {
|
|
@@ -15646,6 +15942,12 @@ var AwkRetention = class {
|
|
|
15646
15942
|
get retainedBytes() {
|
|
15647
15943
|
return this.retained;
|
|
15648
15944
|
}
|
|
15945
|
+
admit(previousBytes, nextBytes) {
|
|
15946
|
+
this.signal?.throwIfAborted();
|
|
15947
|
+
if (!Number.isSafeInteger(previousBytes) || previousBytes < 0 || previousBytes > this.retained || !Number.isSafeInteger(nextBytes) || nextBytes < 0) throw new ProgramError("invalid retained text accounting");
|
|
15948
|
+
if (nextBytes > this.capacity - this.retained + previousBytes) throw new ProgramError("awk retained text limit exceeded");
|
|
15949
|
+
this.retained += nextBytes - previousBytes;
|
|
15950
|
+
}
|
|
15649
15951
|
replace(previousBytes, nextBytes, create) {
|
|
15650
15952
|
this.signal?.throwIfAborted();
|
|
15651
15953
|
if (!Number.isSafeInteger(previousBytes) || previousBytes < 0 || previousBytes > this.retained || !Number.isSafeInteger(nextBytes) || nextBytes < 0) throw new ProgramError("invalid retained text accounting");
|
|
@@ -15692,7 +15994,7 @@ var Reader = class {
|
|
|
15692
15994
|
if (length > this.budget.maxBufferBytes - this.buffered) throw new ProgramError("text buffer limit exceeded");
|
|
15693
15995
|
if (length === 0) return;
|
|
15694
15996
|
const block = this.retention.replace(0, length, () => {
|
|
15695
|
-
const owned =
|
|
15997
|
+
const owned = import_buffer.Buffer.allocUnsafe(length);
|
|
15696
15998
|
owned.set(next.value);
|
|
15697
15999
|
return owned;
|
|
15698
16000
|
});
|
|
@@ -15729,7 +16031,13 @@ var Reader = class {
|
|
|
15729
16031
|
}
|
|
15730
16032
|
}
|
|
15731
16033
|
finish(length, consumed) {
|
|
15732
|
-
const
|
|
16034
|
+
const firstBlock = this.blocks[this.head];
|
|
16035
|
+
if (length <= firstBlock.length - this.offset) {
|
|
16036
|
+
const record4 = firstBlock.toString("latin1", this.offset, this.offset + length);
|
|
16037
|
+
this.consume(consumed);
|
|
16038
|
+
return record4;
|
|
16039
|
+
}
|
|
16040
|
+
const bytes3 = import_buffer.Buffer.allocUnsafe(length);
|
|
15733
16041
|
let written = 0;
|
|
15734
16042
|
for (let index = this.head; written < length; index++) {
|
|
15735
16043
|
const block = this.blocks[index];
|
|
@@ -15738,7 +16046,7 @@ var Reader = class {
|
|
|
15738
16046
|
bytes3.set(block.subarray(start, start + count2), written);
|
|
15739
16047
|
written += count2;
|
|
15740
16048
|
}
|
|
15741
|
-
const record3 =
|
|
16049
|
+
const record3 = bytes3.toString("latin1");
|
|
15742
16050
|
this.consume(consumed);
|
|
15743
16051
|
return record3;
|
|
15744
16052
|
}
|
|
@@ -15775,9 +16083,34 @@ var Reader = class {
|
|
|
15775
16083
|
}
|
|
15776
16084
|
return void 0;
|
|
15777
16085
|
}
|
|
16086
|
+
readSync(separator) {
|
|
16087
|
+
this.budget.context.signal.throwIfAborted();
|
|
16088
|
+
if (separator.length > 1) throw new ProgramError("RS must be one byte or empty for paragraph records");
|
|
16089
|
+
if (separator.length === 1 && !this.closed && this.head < this.blocks.length) {
|
|
16090
|
+
const headBlock = this.blocks[this.head];
|
|
16091
|
+
const idx = headBlock.indexOf(separator.charCodeAt(0), this.offset);
|
|
16092
|
+
if (idx >= 0 && idx - this.offset < 4096) {
|
|
16093
|
+
this.budget.step();
|
|
16094
|
+
const record3 = headBlock.toString("latin1", this.offset, idx);
|
|
16095
|
+
this.consume(idx - this.offset + 1);
|
|
16096
|
+
return record3;
|
|
16097
|
+
}
|
|
16098
|
+
}
|
|
16099
|
+
return this.read(separator);
|
|
16100
|
+
}
|
|
15778
16101
|
async read(separator) {
|
|
15779
16102
|
this.budget.context.signal.throwIfAborted();
|
|
15780
16103
|
if (separator.length > 1) throw new ProgramError("RS must be one byte or empty for paragraph records");
|
|
16104
|
+
if (separator.length === 1 && !this.closed && this.head < this.blocks.length) {
|
|
16105
|
+
const headBlock = this.blocks[this.head];
|
|
16106
|
+
const idx = headBlock.indexOf(separator.charCodeAt(0), this.offset);
|
|
16107
|
+
if (idx >= 0 && idx - this.offset < 4096) {
|
|
16108
|
+
this.budget.step();
|
|
16109
|
+
const record3 = headBlock.toString("latin1", this.offset, idx);
|
|
16110
|
+
this.consume(idx - this.offset + 1);
|
|
16111
|
+
return record3;
|
|
16112
|
+
}
|
|
16113
|
+
}
|
|
15781
16114
|
if (separator === "") {
|
|
15782
16115
|
while (!this.closed) {
|
|
15783
16116
|
this.budget.step();
|
|
@@ -15786,7 +16119,8 @@ var Reader = class {
|
|
|
15786
16119
|
if (this.ended) return void 0;
|
|
15787
16120
|
await this.fill();
|
|
15788
16121
|
}
|
|
15789
|
-
|
|
16122
|
+
const pendingCheck = this.budget.checkpointSync();
|
|
16123
|
+
if (pendingCheck) await pendingCheck;
|
|
15790
16124
|
}
|
|
15791
16125
|
}
|
|
15792
16126
|
const state = { block: this.head, offset: this.offset, bytes: 0, newline: -1, paragraphEnd: -1 };
|
|
@@ -15803,7 +16137,8 @@ var Reader = class {
|
|
|
15803
16137
|
}
|
|
15804
16138
|
await this.fill();
|
|
15805
16139
|
}
|
|
15806
|
-
|
|
16140
|
+
const pendingCheck = this.budget.checkpointSync();
|
|
16141
|
+
if (pendingCheck) await pendingCheck;
|
|
15807
16142
|
}
|
|
15808
16143
|
}
|
|
15809
16144
|
close() {
|
|
@@ -15826,7 +16161,7 @@ function textSize(value2) {
|
|
|
15826
16161
|
return value2 && !(value2 instanceof AwkArray) && (value2.kind === "string" || value2.kind === "numeric") ? value2.text.length : 0;
|
|
15827
16162
|
}
|
|
15828
16163
|
function ownScalar(value2) {
|
|
15829
|
-
return value2.kind === "string" || value2.kind === "numeric" ? { ...value2, text: import_buffer.Buffer.from(value2.text, "latin1").toString("latin1") } : value2;
|
|
16164
|
+
return value2.kind === "string" || value2.kind === "numeric" ? { ...value2, text: value2.text.length < 13 ? value2.text : import_buffer.Buffer.from(value2.text, "latin1").toString("latin1") } : value2;
|
|
15830
16165
|
}
|
|
15831
16166
|
var Flow = class {
|
|
15832
16167
|
constructor(kind, value2 = unset) {
|
|
@@ -15896,6 +16231,8 @@ var AwkRuntime = class {
|
|
|
15896
16231
|
return scalar(this.get(name2));
|
|
15897
16232
|
}
|
|
15898
16233
|
asText(value2) {
|
|
16234
|
+
if (value2.kind === "string" || value2.kind === "numeric") return value2.text;
|
|
16235
|
+
if (value2.kind === "unset") return "";
|
|
15899
16236
|
return text(value2, text(this.getScalar("CONVFMT"), void 0, this.budget), this.budget);
|
|
15900
16237
|
}
|
|
15901
16238
|
varText(name2) {
|
|
@@ -15907,8 +16244,8 @@ var AwkRuntime = class {
|
|
|
15907
16244
|
}
|
|
15908
16245
|
storeScalar(store, name2, value2) {
|
|
15909
16246
|
if (value2.kind === "string" || value2.kind === "numeric") this.budget.check(value2.text);
|
|
15910
|
-
|
|
15911
|
-
store.set(name2,
|
|
16247
|
+
this.retention.admit(textSize(store.get(name2)), textSize(value2));
|
|
16248
|
+
store.set(name2, ownScalar(value2));
|
|
15912
16249
|
}
|
|
15913
16250
|
bindArray(store, name2, array) {
|
|
15914
16251
|
let allocation = this.arrays.get(array);
|
|
@@ -15955,14 +16292,13 @@ var AwkRuntime = class {
|
|
|
15955
16292
|
arraySet(array, key, value2) {
|
|
15956
16293
|
this.budget.check(key);
|
|
15957
16294
|
if (value2.kind === "string" || value2.kind === "numeric") this.budget.check(value2.text);
|
|
15958
|
-
const
|
|
16295
|
+
const existingValue = array.entries.get(key);
|
|
16296
|
+
const existing2 = existingValue !== void 0 || array.entries.has(key);
|
|
15959
16297
|
if (!existing2 && this.entries >= (this.budget.options.maxArrayEntries ?? Infinity)) throw new ProgramError("array entry limit exceeded");
|
|
15960
|
-
const previous = textSize(
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
}));
|
|
15965
|
-
array.entries.set(owned.key, owned.value);
|
|
16298
|
+
const previous = textSize(existingValue), next = textSize(value2) + (existing2 ? 0 : key.length);
|
|
16299
|
+
this.retention.admit(previous, next);
|
|
16300
|
+
const ownedKey = existing2 || key.length < 13 ? key : import_buffer.Buffer.from(key, "latin1").toString("latin1");
|
|
16301
|
+
array.entries.set(ownedKey, ownScalar(value2));
|
|
15966
16302
|
this.arrays.get(array).bytes += next - previous;
|
|
15967
16303
|
if (!existing2) this.entries++;
|
|
15968
16304
|
}
|
|
@@ -15978,6 +16314,44 @@ var AwkRuntime = class {
|
|
|
15978
16314
|
async regex(expression) {
|
|
15979
16315
|
return expression.kind === "regex" ? expression.pattern : this.pattern(this.asText(await this.scalarExpression(expression)));
|
|
15980
16316
|
}
|
|
16317
|
+
splitSync(value2, separator, paragraph) {
|
|
16318
|
+
if (!paragraph && value2.length < 256 && (separator === " " || separator.length === 1)) {
|
|
16319
|
+
this.budget.step(value2.length);
|
|
16320
|
+
const maxFields = this.budget.options.maxFields ?? Infinity;
|
|
16321
|
+
const parts = [];
|
|
16322
|
+
if (separator === " ") {
|
|
16323
|
+
let start = -1;
|
|
16324
|
+
for (let index = 0; index < value2.length; index++) {
|
|
16325
|
+
const ch = value2.charCodeAt(index);
|
|
16326
|
+
if (ch === 32 || ch === 9 || ch === 10) {
|
|
16327
|
+
if (start >= 0) {
|
|
16328
|
+
if (parts.length >= maxFields) throw new ProgramError("field count limit exceeded");
|
|
16329
|
+
parts.push(inputValue(value2.slice(start, index)));
|
|
16330
|
+
start = -1;
|
|
16331
|
+
}
|
|
16332
|
+
} else if (start < 0) start = index;
|
|
16333
|
+
}
|
|
16334
|
+
if (start >= 0) {
|
|
16335
|
+
if (parts.length >= maxFields) throw new ProgramError("field count limit exceeded");
|
|
16336
|
+
parts.push(inputValue(value2.slice(start, value2.length)));
|
|
16337
|
+
}
|
|
16338
|
+
return parts;
|
|
16339
|
+
}
|
|
16340
|
+
if (value2 !== "") {
|
|
16341
|
+
let start = 0;
|
|
16342
|
+
let idx;
|
|
16343
|
+
while ((idx = value2.indexOf(separator, start)) >= 0) {
|
|
16344
|
+
if (parts.length >= maxFields) throw new ProgramError("field count limit exceeded");
|
|
16345
|
+
parts.push(inputValue(value2.slice(start, idx)));
|
|
16346
|
+
start = idx + 1;
|
|
16347
|
+
}
|
|
16348
|
+
if (parts.length >= maxFields) throw new ProgramError("field count limit exceeded");
|
|
16349
|
+
parts.push(inputValue(value2.slice(start, value2.length)));
|
|
16350
|
+
}
|
|
16351
|
+
return parts;
|
|
16352
|
+
}
|
|
16353
|
+
return this.split(value2, separator, paragraph);
|
|
16354
|
+
}
|
|
15981
16355
|
async split(value2, separator, paragraph = false) {
|
|
15982
16356
|
this.budget.step(value2.length);
|
|
15983
16357
|
const parts = [];
|
|
@@ -15988,7 +16362,7 @@ var AwkRuntime = class {
|
|
|
15988
16362
|
if (separator === " ") {
|
|
15989
16363
|
let start = -1;
|
|
15990
16364
|
for (let index = 0; index < value2.length; index++) {
|
|
15991
|
-
if (index % 256 === 0) await this.budget.
|
|
16365
|
+
if (index % 256 === 0) await this.budget.checkpointSync();
|
|
15992
16366
|
if (" \n".includes(value2[index])) {
|
|
15993
16367
|
if (start >= 0) {
|
|
15994
16368
|
append(start, index);
|
|
@@ -16000,13 +16374,28 @@ var AwkRuntime = class {
|
|
|
16000
16374
|
} else if (separator === "") {
|
|
16001
16375
|
if (value2.length > (this.budget.options.maxFields ?? Infinity)) throw new ProgramError("field count limit exceeded");
|
|
16002
16376
|
for (let index = 0; index < value2.length; index++) {
|
|
16003
|
-
if (index % 256 === 0) await this.budget.
|
|
16377
|
+
if (index % 256 === 0) await this.budget.checkpointSync();
|
|
16004
16378
|
append(index, index + 1);
|
|
16005
16379
|
}
|
|
16006
16380
|
} else if (typeof separator === "string" && separator.length === 1) {
|
|
16381
|
+
if (!paragraph && value2.length < 256) {
|
|
16382
|
+
if (value2 !== "") {
|
|
16383
|
+
let start2 = 0;
|
|
16384
|
+
let idx;
|
|
16385
|
+
while ((idx = value2.indexOf(separator, start2)) >= 0) {
|
|
16386
|
+
append(start2, idx);
|
|
16387
|
+
start2 = idx + 1;
|
|
16388
|
+
}
|
|
16389
|
+
append(start2, value2.length);
|
|
16390
|
+
}
|
|
16391
|
+
return parts;
|
|
16392
|
+
}
|
|
16007
16393
|
let start = 0;
|
|
16008
16394
|
for (let index = 0; index < value2.length; index++) {
|
|
16009
|
-
if (index % 256 === 0)
|
|
16395
|
+
if (index > 0 && index % 256 === 0) {
|
|
16396
|
+
const p = this.budget.checkpointSync();
|
|
16397
|
+
if (p) await p;
|
|
16398
|
+
}
|
|
16010
16399
|
if (value2[index] === separator || paragraph && value2[index] === "\n") {
|
|
16011
16400
|
append(start, index);
|
|
16012
16401
|
start = index + 1;
|
|
@@ -16017,7 +16406,7 @@ var AwkRuntime = class {
|
|
|
16017
16406
|
const matcher = typeof separator === "string" ? this.pattern(separator) : separator;
|
|
16018
16407
|
const segment2 = async (start, end) => {
|
|
16019
16408
|
if (paragraph) for (let index = start; index < end; index++) {
|
|
16020
|
-
if (index % 256 === 0) await this.budget.
|
|
16409
|
+
if (index % 256 === 0) await this.budget.checkpointSync();
|
|
16021
16410
|
if (value2[index] === "\n") {
|
|
16022
16411
|
append(start, index);
|
|
16023
16412
|
start = index + 1;
|
|
@@ -16028,7 +16417,7 @@ var AwkRuntime = class {
|
|
|
16028
16417
|
let consumed = 0;
|
|
16029
16418
|
let search = 0;
|
|
16030
16419
|
while (search <= value2.length) {
|
|
16031
|
-
await this.budget.
|
|
16420
|
+
await this.budget.checkpointSync();
|
|
16032
16421
|
const match = await matcher.find(value2, this.budget, search);
|
|
16033
16422
|
if (!match) break;
|
|
16034
16423
|
if (match.start === match.end) {
|
|
@@ -16043,10 +16432,19 @@ var AwkRuntime = class {
|
|
|
16043
16432
|
}
|
|
16044
16433
|
return parts;
|
|
16045
16434
|
}
|
|
16046
|
-
|
|
16435
|
+
setRecordSync(record3, value2 = inputValue(record3)) {
|
|
16047
16436
|
this.budget.check(record3);
|
|
16048
|
-
const fields4 =
|
|
16049
|
-
|
|
16437
|
+
const fields4 = this.splitSync(record3, this.varText("FS"), this.varText("RS") === "");
|
|
16438
|
+
if (!(fields4 instanceof Promise)) {
|
|
16439
|
+
this.replaceRecord(record3, fields4, value2);
|
|
16440
|
+
return;
|
|
16441
|
+
}
|
|
16442
|
+
return fields4.then((resolved) => {
|
|
16443
|
+
this.replaceRecord(record3, resolved, value2);
|
|
16444
|
+
});
|
|
16445
|
+
}
|
|
16446
|
+
async setRecord(record3, value2 = inputValue(record3)) {
|
|
16447
|
+
await this.setRecordSync(record3, value2);
|
|
16050
16448
|
}
|
|
16051
16449
|
replaceRecord(record3, fields4, value2 = string(record3)) {
|
|
16052
16450
|
let fieldBytes = 0;
|
|
@@ -16054,12 +16452,9 @@ var AwkRuntime = class {
|
|
|
16054
16452
|
if (field2.kind === "string" || field2.kind === "numeric") this.budget.check(field2.text);
|
|
16055
16453
|
fieldBytes += textSize(field2);
|
|
16056
16454
|
}
|
|
16057
|
-
|
|
16058
|
-
|
|
16059
|
-
|
|
16060
|
-
}));
|
|
16061
|
-
this.record = owned.record;
|
|
16062
|
-
this.fields = owned.fields;
|
|
16455
|
+
this.retention.admit(this.record.length + this.fieldBytes, record3.length + fieldBytes);
|
|
16456
|
+
this.record = record3;
|
|
16457
|
+
this.fields = fields4;
|
|
16063
16458
|
this.fieldBytes = fieldBytes;
|
|
16064
16459
|
this.recordValue = value2.kind === "string" || value2.kind === "numeric" ? { ...value2, text: this.record } : value2;
|
|
16065
16460
|
this.variables.set("NF", numeric2(fields4.length));
|
|
@@ -16084,7 +16479,20 @@ var AwkRuntime = class {
|
|
|
16084
16479
|
const record3 = this.join(fields4.map((value2) => this.asText(value2)), this.varText("OFS"));
|
|
16085
16480
|
this.replaceRecord(record3, fields4);
|
|
16086
16481
|
}
|
|
16087
|
-
|
|
16482
|
+
key(items) {
|
|
16483
|
+
if (items.length === 1) {
|
|
16484
|
+
const first = this.scalarExpression(items[0]);
|
|
16485
|
+
if (!(first instanceof Promise)) {
|
|
16486
|
+
const k = this.asText(first);
|
|
16487
|
+
this.budget.step(2);
|
|
16488
|
+
if (k.length > this.budget.maxBufferBytes) throw new ProgramError("text buffer limit exceeded");
|
|
16489
|
+
this.budget.step(k.length);
|
|
16490
|
+
return k;
|
|
16491
|
+
}
|
|
16492
|
+
}
|
|
16493
|
+
return this.keySlow(items);
|
|
16494
|
+
}
|
|
16495
|
+
async keySlow(items) {
|
|
16088
16496
|
const pieces = [];
|
|
16089
16497
|
for (const item of items) pieces.push(this.asText(await this.scalarExpression(item)));
|
|
16090
16498
|
return this.join(pieces, this.varText("SUBSEP"));
|
|
@@ -16121,10 +16529,11 @@ var AwkRuntime = class {
|
|
|
16121
16529
|
if (!Number.isFinite(result)) throw new ProgramError("non-finite arithmetic result");
|
|
16122
16530
|
return result;
|
|
16123
16531
|
}
|
|
16124
|
-
|
|
16125
|
-
|
|
16532
|
+
scalarExpression(expression) {
|
|
16533
|
+
const val = this.evaluate(expression);
|
|
16534
|
+
return val instanceof Promise ? val.then(scalar) : scalar(val);
|
|
16126
16535
|
}
|
|
16127
|
-
|
|
16536
|
+
evaluate(expression) {
|
|
16128
16537
|
this.budget.step();
|
|
16129
16538
|
switch (expression.kind) {
|
|
16130
16539
|
case "number":
|
|
@@ -16132,71 +16541,220 @@ var AwkRuntime = class {
|
|
|
16132
16541
|
case "string":
|
|
16133
16542
|
return string(expression.value);
|
|
16134
16543
|
case "regex":
|
|
16135
|
-
return
|
|
16544
|
+
return expression.pattern.find(this.record, this.budget).then((m) => numeric2(m ? 1 : 0));
|
|
16136
16545
|
case "variable":
|
|
16137
16546
|
return this.get(expression.name);
|
|
16138
|
-
case "field":
|
|
16139
|
-
|
|
16140
|
-
|
|
16547
|
+
case "field": {
|
|
16548
|
+
const idxVal = this.scalarExpression(expression.index);
|
|
16549
|
+
if (!(idxVal instanceof Promise)) {
|
|
16550
|
+
const index = Math.trunc(number(idxVal));
|
|
16551
|
+
if (!Number.isSafeInteger(index) || index < 0 || index > (this.budget.options.maxFields ?? Infinity)) throw new ProgramError("invalid or excessive field index");
|
|
16552
|
+
return index === 0 ? this.recordValue : this.fields[index - 1] ?? unset;
|
|
16553
|
+
}
|
|
16554
|
+
return idxVal.then((resolved) => {
|
|
16555
|
+
const index = Math.trunc(number(resolved));
|
|
16556
|
+
if (!Number.isSafeInteger(index) || index < 0 || index > (this.budget.options.maxFields ?? Infinity)) throw new ProgramError("invalid or excessive field index");
|
|
16557
|
+
return index === 0 ? this.recordValue : this.fields[index - 1] ?? unset;
|
|
16558
|
+
});
|
|
16559
|
+
}
|
|
16560
|
+
case "array": {
|
|
16561
|
+
const array = this.array(expression.name);
|
|
16562
|
+
const k = this.key(expression.indexes);
|
|
16563
|
+
if (!(k instanceof Promise)) {
|
|
16564
|
+
let existing2 = array.entries.get(k);
|
|
16565
|
+
if (existing2 === void 0 && !array.entries.has(k)) {
|
|
16566
|
+
this.arraySet(array, k, unset);
|
|
16567
|
+
existing2 = unset;
|
|
16568
|
+
}
|
|
16569
|
+
return existing2;
|
|
16570
|
+
}
|
|
16571
|
+
return k.then((resolvedKey) => {
|
|
16572
|
+
let existing2 = array.entries.get(resolvedKey);
|
|
16573
|
+
if (existing2 === void 0 && !array.entries.has(resolvedKey)) {
|
|
16574
|
+
this.arraySet(array, resolvedKey, unset);
|
|
16575
|
+
existing2 = unset;
|
|
16576
|
+
}
|
|
16577
|
+
return existing2;
|
|
16578
|
+
});
|
|
16579
|
+
}
|
|
16141
16580
|
case "getline":
|
|
16142
16581
|
return this.getline(expression);
|
|
16143
16582
|
case "tuple":
|
|
16144
16583
|
throw new ProgramError("tuple is only valid as an array membership key");
|
|
16145
|
-
case "conditional":
|
|
16146
|
-
|
|
16584
|
+
case "conditional": {
|
|
16585
|
+
const cond = this.scalarExpression(expression.condition);
|
|
16586
|
+
return cond instanceof Promise ? cond.then((c) => this.evaluate(truth(c) ? expression.yes : expression.no)) : this.evaluate(truth(cond) ? expression.yes : expression.no);
|
|
16587
|
+
}
|
|
16147
16588
|
case "unary": {
|
|
16148
16589
|
if (expression.operator === "++" || expression.operator === "--") {
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16590
|
+
if (expression.operand.kind === "variable") {
|
|
16591
|
+
const name2 = expression.operand.name;
|
|
16592
|
+
const previous = number(scalar(this.get(name2)));
|
|
16593
|
+
const next = previous + (expression.operator === "++" ? 1 : -1);
|
|
16594
|
+
this.set(name2, numeric2(next));
|
|
16595
|
+
return numeric2(expression.postfix ? previous : next);
|
|
16596
|
+
}
|
|
16597
|
+
if (expression.operand.kind === "array") {
|
|
16598
|
+
const array = this.array(expression.operand.name);
|
|
16599
|
+
const k = this.key(expression.operand.indexes);
|
|
16600
|
+
if (!(k instanceof Promise)) {
|
|
16601
|
+
let current = array.entries.get(k);
|
|
16602
|
+
if (current === void 0 && !array.entries.has(k)) {
|
|
16603
|
+
this.arraySet(array, k, unset);
|
|
16604
|
+
current = unset;
|
|
16605
|
+
}
|
|
16606
|
+
const previous = number(scalar(current));
|
|
16607
|
+
const next = previous + (expression.operator === "++" ? 1 : -1);
|
|
16608
|
+
this.arraySet(array, k, numeric2(next));
|
|
16609
|
+
return numeric2(expression.postfix ? previous : next);
|
|
16610
|
+
}
|
|
16611
|
+
return k.then((resolvedKey) => {
|
|
16612
|
+
let current = array.entries.get(resolvedKey);
|
|
16613
|
+
if (current === void 0 && !array.entries.has(resolvedKey)) {
|
|
16614
|
+
this.arraySet(array, resolvedKey, unset);
|
|
16615
|
+
current = unset;
|
|
16616
|
+
}
|
|
16617
|
+
const previous = number(scalar(current));
|
|
16618
|
+
const next = previous + (expression.operator === "++" ? 1 : -1);
|
|
16619
|
+
this.arraySet(array, resolvedKey, numeric2(next));
|
|
16620
|
+
return numeric2(expression.postfix ? previous : next);
|
|
16621
|
+
});
|
|
16622
|
+
}
|
|
16623
|
+
return this.evaluateUnarySlow(expression);
|
|
16624
|
+
}
|
|
16625
|
+
const operand = this.scalarExpression(expression.operand);
|
|
16626
|
+
if (!(operand instanceof Promise)) {
|
|
16627
|
+
return numeric2(expression.operator === "!" ? truth(operand) ? 0 : 1 : expression.operator === "-" ? -number(operand) : number(operand));
|
|
16154
16628
|
}
|
|
16155
|
-
|
|
16156
|
-
return numeric2(expression.operator === "!" ? truth(operand) ? 0 : 1 : expression.operator === "-" ? -number(operand) : number(operand));
|
|
16629
|
+
return operand.then((op) => numeric2(expression.operator === "!" ? truth(op) ? 0 : 1 : expression.operator === "-" ? -number(op) : number(op)));
|
|
16157
16630
|
}
|
|
16158
16631
|
case "binary": {
|
|
16159
16632
|
const operator = expression.operator;
|
|
16160
|
-
if (
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
|
|
16170
|
-
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16633
|
+
if (operator === "=" || operator === "+=" || operator === "-=" || operator === "*=" || operator === "/=" || operator === "%=" || operator === "^=") {
|
|
16634
|
+
if (expression.left.kind === "variable") {
|
|
16635
|
+
const name2 = expression.left.name;
|
|
16636
|
+
const previous = operator === "=" ? unset : scalar(this.get(name2));
|
|
16637
|
+
const rightVal = this.scalarExpression(expression.right);
|
|
16638
|
+
if (!(rightVal instanceof Promise)) {
|
|
16639
|
+
const value2 = operator === "=" ? rightVal : numeric2(this.arithmetic(operator[0], number(previous), number(rightVal)));
|
|
16640
|
+
this.set(name2, value2);
|
|
16641
|
+
return value2;
|
|
16642
|
+
}
|
|
16643
|
+
return rightVal.then((resolved) => {
|
|
16644
|
+
const value2 = operator === "=" ? resolved : numeric2(this.arithmetic(operator[0], number(previous), number(resolved)));
|
|
16645
|
+
this.set(name2, value2);
|
|
16646
|
+
return value2;
|
|
16647
|
+
});
|
|
16648
|
+
} else if (expression.left.kind === "array") {
|
|
16649
|
+
const array = this.array(expression.left.name);
|
|
16650
|
+
const k = this.key(expression.left.indexes);
|
|
16651
|
+
if (!(k instanceof Promise)) {
|
|
16652
|
+
let current = operator === "=" ? unset : array.entries.get(k);
|
|
16653
|
+
if (operator !== "=" && current === void 0 && !array.entries.has(k)) {
|
|
16654
|
+
this.arraySet(array, k, unset);
|
|
16655
|
+
current = unset;
|
|
16656
|
+
}
|
|
16657
|
+
const previous = scalar(current);
|
|
16658
|
+
const rightVal = this.scalarExpression(expression.right);
|
|
16659
|
+
if (!(rightVal instanceof Promise)) {
|
|
16660
|
+
const value2 = operator === "=" ? rightVal : numeric2(this.arithmetic(operator[0], number(previous), number(rightVal)));
|
|
16661
|
+
this.arraySet(array, k, value2);
|
|
16662
|
+
return value2;
|
|
16663
|
+
}
|
|
16664
|
+
return rightVal.then((resolved) => {
|
|
16665
|
+
const value2 = operator === "=" ? resolved : numeric2(this.arithmetic(operator[0], number(previous), number(resolved)));
|
|
16666
|
+
this.arraySet(array, k, value2);
|
|
16667
|
+
return value2;
|
|
16668
|
+
});
|
|
16669
|
+
}
|
|
16670
|
+
return k.then(async (resolvedKey) => {
|
|
16671
|
+
let current = operator === "=" ? unset : array.entries.get(resolvedKey);
|
|
16672
|
+
if (operator !== "=" && current === void 0 && !array.entries.has(resolvedKey)) {
|
|
16673
|
+
this.arraySet(array, resolvedKey, unset);
|
|
16674
|
+
current = unset;
|
|
16675
|
+
}
|
|
16676
|
+
const previous = scalar(current);
|
|
16677
|
+
const resolved = await this.scalarExpression(expression.right);
|
|
16678
|
+
const value2 = operator === "=" ? resolved : numeric2(this.arithmetic(operator[0], number(previous), number(resolved)));
|
|
16679
|
+
this.arraySet(array, resolvedKey, value2);
|
|
16680
|
+
return value2;
|
|
16681
|
+
});
|
|
16682
|
+
}
|
|
16683
|
+
return this.evaluateBinarySlow(expression);
|
|
16684
|
+
}
|
|
16685
|
+
if (operator === "in" || operator === "~" || operator === "!~") {
|
|
16686
|
+
return this.evaluateBinarySlow(expression);
|
|
16687
|
+
}
|
|
16688
|
+
const left = this.scalarExpression(expression.left);
|
|
16689
|
+
if (left instanceof Promise) return this.evaluateBinaryWithLeftPromise(expression, left);
|
|
16174
16690
|
if (operator === "&&" && !truth(left)) return numeric2(0);
|
|
16175
16691
|
if (operator === "||" && truth(left)) return numeric2(1);
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
}
|
|
16180
|
-
const right = await this.scalarExpression(expression.right);
|
|
16181
|
-
if (operator === "&&" || operator === "||") return numeric2(truth(right) ? 1 : 0);
|
|
16182
|
-
if (operator === "concat") {
|
|
16183
|
-
const leftText = this.asText(left);
|
|
16184
|
-
const rightText = this.asText(right);
|
|
16185
|
-
this.budget.step(0);
|
|
16186
|
-
if (rightText.length > this.budget.maxBufferBytes - leftText.length) throw new ProgramError("text buffer limit exceeded");
|
|
16187
|
-
this.budget.step(leftText.length + rightText.length);
|
|
16188
|
-
return string(leftText + rightText);
|
|
16189
|
-
}
|
|
16190
|
-
if (["==", "!=", "<", "<=", ">", ">="].includes(operator)) {
|
|
16191
|
-
const order = compare3(left, right, this.varText("CONVFMT"), this.budget);
|
|
16192
|
-
return numeric2((operator === "==" ? order === 0 : operator === "!=" ? order !== 0 : operator === "<" ? order < 0 : operator === "<=" ? order <= 0 : operator === ">" ? order > 0 : order >= 0) ? 1 : 0);
|
|
16193
|
-
}
|
|
16194
|
-
return numeric2(this.arithmetic(operator, number(left), number(right)));
|
|
16692
|
+
const right = this.scalarExpression(expression.right);
|
|
16693
|
+
if (right instanceof Promise) return right.then((r) => this.evaluateBinarySyncOperands(operator, left, r));
|
|
16694
|
+
return this.evaluateBinarySyncOperands(operator, left, right);
|
|
16195
16695
|
}
|
|
16196
16696
|
case "call":
|
|
16197
16697
|
return this.call(expression.name, expression.args);
|
|
16198
16698
|
}
|
|
16199
16699
|
}
|
|
16700
|
+
evaluateBinarySyncOperands(operator, left, right) {
|
|
16701
|
+
if (operator === "&&" || operator === "||") return numeric2(truth(right) ? 1 : 0);
|
|
16702
|
+
if (operator === "concat") {
|
|
16703
|
+
const leftText = this.asText(left);
|
|
16704
|
+
const rightText = this.asText(right);
|
|
16705
|
+
this.budget.step(0);
|
|
16706
|
+
if (rightText.length > this.budget.maxBufferBytes - leftText.length) throw new ProgramError("text buffer limit exceeded");
|
|
16707
|
+
this.budget.step(leftText.length + rightText.length);
|
|
16708
|
+
return string(leftText + rightText);
|
|
16709
|
+
}
|
|
16710
|
+
if (operator === "==" || operator === "!=" || operator === "<" || operator === "<=" || operator === ">" || operator === ">=") {
|
|
16711
|
+
const order = compare3(left, right, this.varText("CONVFMT"), this.budget);
|
|
16712
|
+
return numeric2((operator === "==" ? order === 0 : operator === "!=" ? order !== 0 : operator === "<" ? order < 0 : operator === "<=" ? order <= 0 : operator === ">" ? order > 0 : order >= 0) ? 1 : 0);
|
|
16713
|
+
}
|
|
16714
|
+
return numeric2(this.arithmetic(operator, number(left), number(right)));
|
|
16715
|
+
}
|
|
16716
|
+
async evaluateBinaryWithLeftPromise(expression, leftPromise) {
|
|
16717
|
+
const operator = expression.operator;
|
|
16718
|
+
const left = await leftPromise;
|
|
16719
|
+
if (operator === "&&" && !truth(left)) return numeric2(0);
|
|
16720
|
+
if (operator === "||" && truth(left)) return numeric2(1);
|
|
16721
|
+
const right = await this.scalarExpression(expression.right);
|
|
16722
|
+
return this.evaluateBinarySyncOperands(operator, left, right);
|
|
16723
|
+
}
|
|
16724
|
+
async evaluateUnarySlow(expression) {
|
|
16725
|
+
if (expression.operator === "++" || expression.operator === "--") {
|
|
16726
|
+
const reference = await this.reference(expression.operand);
|
|
16727
|
+
const previous = number(scalar(reference.get()));
|
|
16728
|
+
const next = previous + (expression.operator === "++" ? 1 : -1);
|
|
16729
|
+
await reference.set(numeric2(next));
|
|
16730
|
+
return numeric2(expression.postfix ? previous : next);
|
|
16731
|
+
}
|
|
16732
|
+
const operand = await this.scalarExpression(expression.operand);
|
|
16733
|
+
return numeric2(expression.operator === "!" ? truth(operand) ? 0 : 1 : expression.operator === "-" ? -number(operand) : number(operand));
|
|
16734
|
+
}
|
|
16735
|
+
async evaluateBinarySlow(expression) {
|
|
16736
|
+
const operator = expression.operator;
|
|
16737
|
+
if (["=", "+=", "-=", "*=", "/=", "%=", "^="].includes(operator)) {
|
|
16738
|
+
const reference = await this.reference(expression.left);
|
|
16739
|
+
const previous = operator === "=" ? unset : scalar(reference.get());
|
|
16740
|
+
let value2 = await this.scalarExpression(expression.right);
|
|
16741
|
+
if (operator !== "=") value2 = numeric2(this.arithmetic(operator[0], number(previous), number(value2)));
|
|
16742
|
+
await reference.set(value2);
|
|
16743
|
+
return value2;
|
|
16744
|
+
}
|
|
16745
|
+
if (operator === "in") {
|
|
16746
|
+
const array = this.array(expression.right.name);
|
|
16747
|
+
const key = expression.left.kind === "tuple" ? await this.key(expression.left.items) : this.asText(await this.scalarExpression(expression.left));
|
|
16748
|
+
return numeric2(array.entries.has(key) ? 1 : 0);
|
|
16749
|
+
}
|
|
16750
|
+
const left = await this.scalarExpression(expression.left);
|
|
16751
|
+
if (operator === "~" || operator === "!~") {
|
|
16752
|
+
const matched = await (await this.regex(expression.right)).find(this.asText(left), this.budget) !== void 0;
|
|
16753
|
+
return numeric2((operator === "~" ? matched : !matched) ? 1 : 0);
|
|
16754
|
+
}
|
|
16755
|
+
const right = await this.scalarExpression(expression.right);
|
|
16756
|
+
return this.evaluateBinarySyncOperands(operator, left, right);
|
|
16757
|
+
}
|
|
16200
16758
|
async getline(expression) {
|
|
16201
16759
|
if (!expression.file) {
|
|
16202
16760
|
const record4 = await this.readMainRecord();
|
|
@@ -16227,7 +16785,7 @@ var AwkRuntime = class {
|
|
|
16227
16785
|
if (useStdin) yield* context2.stdin;
|
|
16228
16786
|
else {
|
|
16229
16787
|
budget.step();
|
|
16230
|
-
await budget.
|
|
16788
|
+
await budget.checkpointSync();
|
|
16231
16789
|
const capabilities = await context2.fs.capabilitiesFor?.(name2, { signal: context2.signal }) ?? context2.fs.capabilities;
|
|
16232
16790
|
context2.signal.throwIfAborted();
|
|
16233
16791
|
if (context2.fs.readStream && capabilities.streamingRead !== false) yield* context2.fs.readStream(name2, { signal: context2.signal });
|
|
@@ -16377,10 +16935,49 @@ var AwkRuntime = class {
|
|
|
16377
16935
|
if (!Number.isFinite(result)) throw new ProgramError(`invalid mathematical result in '${name2}'`);
|
|
16378
16936
|
return numeric2(result);
|
|
16379
16937
|
}
|
|
16938
|
+
executeSync(statement) {
|
|
16939
|
+
if (!this.inspection) {
|
|
16940
|
+
const p = this.budget.checkpointSync();
|
|
16941
|
+
if (!p) {
|
|
16942
|
+
if (statement.kind === "expression") {
|
|
16943
|
+
this.budget.step();
|
|
16944
|
+
const val = this.evaluate(statement.expression);
|
|
16945
|
+
return val instanceof Promise ? val.then(() => void 0) : void 0;
|
|
16946
|
+
}
|
|
16947
|
+
if (statement.kind === "block") {
|
|
16948
|
+
this.budget.step();
|
|
16949
|
+
for (let i = 0; i < statement.body.length; i++) {
|
|
16950
|
+
const res = this.executeSync(statement.body[i]);
|
|
16951
|
+
if (res instanceof Promise) {
|
|
16952
|
+
return this.executeBlockRemainder(statement.body, i + 1, res);
|
|
16953
|
+
}
|
|
16954
|
+
}
|
|
16955
|
+
return void 0;
|
|
16956
|
+
}
|
|
16957
|
+
if (statement.kind === "if") {
|
|
16958
|
+
this.budget.step();
|
|
16959
|
+
const cond = this.scalarExpression(statement.condition);
|
|
16960
|
+
if (!(cond instanceof Promise)) {
|
|
16961
|
+
const branch = truth(cond) ? statement.yes : statement.no;
|
|
16962
|
+
return branch ? this.executeSync(branch) : void 0;
|
|
16963
|
+
}
|
|
16964
|
+
}
|
|
16965
|
+
}
|
|
16966
|
+
}
|
|
16967
|
+
return this.execute(statement);
|
|
16968
|
+
}
|
|
16969
|
+
async executeBlockRemainder(body, startIndex2, current) {
|
|
16970
|
+
await current;
|
|
16971
|
+
for (let i = startIndex2; i < body.length; i++) {
|
|
16972
|
+
const res = this.executeSync(body[i]);
|
|
16973
|
+
if (res instanceof Promise) await res;
|
|
16974
|
+
}
|
|
16975
|
+
}
|
|
16380
16976
|
async execute(statement) {
|
|
16381
16977
|
this.budget.step();
|
|
16382
16978
|
if (this.inspection) await this.inspection.observe(statement, this.phase);
|
|
16383
|
-
|
|
16979
|
+
const p = this.budget.checkpointSync();
|
|
16980
|
+
if (p) await p;
|
|
16384
16981
|
switch (statement.kind) {
|
|
16385
16982
|
case "block":
|
|
16386
16983
|
for (const child of statement.body) await this.execute(child);
|
|
@@ -16521,6 +17118,47 @@ var AwkRuntime = class {
|
|
|
16521
17118
|
return status2;
|
|
16522
17119
|
}
|
|
16523
17120
|
async readMainRecord() {
|
|
17121
|
+
const syncRes = this.readMainRecordSync();
|
|
17122
|
+
return syncRes instanceof Promise ? await syncRes : syncRes;
|
|
17123
|
+
}
|
|
17124
|
+
incrementCounter(name2) {
|
|
17125
|
+
const current = this.variables.get(name2);
|
|
17126
|
+
if (current && !(current instanceof AwkArray) && current.kind === "number" && !this.frames.at(-1)?.has(name2)) {
|
|
17127
|
+
this.retention.admit(0, 0);
|
|
17128
|
+
this.variables.set(name2, numeric2(current.number + 1));
|
|
17129
|
+
return;
|
|
17130
|
+
}
|
|
17131
|
+
this.set(name2, numeric2(number(this.getScalar(name2)) + 1));
|
|
17132
|
+
}
|
|
17133
|
+
readMainRecordSync() {
|
|
17134
|
+
if (this.mainReader) {
|
|
17135
|
+
this.budget.step();
|
|
17136
|
+
const record3 = this.mainReader.readSync(this.varText("RS"));
|
|
17137
|
+
if (typeof record3 === "string") {
|
|
17138
|
+
this.incrementCounter("NR");
|
|
17139
|
+
this.incrementCounter("FNR");
|
|
17140
|
+
return record3;
|
|
17141
|
+
}
|
|
17142
|
+
if (record3 instanceof Promise) {
|
|
17143
|
+
return record3.then((resolved) => {
|
|
17144
|
+
if (resolved !== void 0) {
|
|
17145
|
+
this.incrementCounter("NR");
|
|
17146
|
+
this.incrementCounter("FNR");
|
|
17147
|
+
return resolved;
|
|
17148
|
+
}
|
|
17149
|
+
return this.readMainRecordSlowAfterEof();
|
|
17150
|
+
});
|
|
17151
|
+
}
|
|
17152
|
+
return this.readMainRecordSlowAfterEof();
|
|
17153
|
+
}
|
|
17154
|
+
return this.readMainRecordSlow();
|
|
17155
|
+
}
|
|
17156
|
+
async readMainRecordSlowAfterEof() {
|
|
17157
|
+
await this.mainReader?.close();
|
|
17158
|
+
this.mainReader = void 0;
|
|
17159
|
+
return this.readMainRecordSlow();
|
|
17160
|
+
}
|
|
17161
|
+
async readMainRecordSlow() {
|
|
16524
17162
|
while (true) {
|
|
16525
17163
|
this.budget.step();
|
|
16526
17164
|
if (!this.mainReader) {
|
|
@@ -16529,7 +17167,8 @@ var AwkRuntime = class {
|
|
|
16529
17167
|
this.budget.step();
|
|
16530
17168
|
const argumentOptions = this.budget.options;
|
|
16531
17169
|
if (this.argument > (argumentOptions?.maxArguments ?? Infinity)) throw new ProgramError("argument count limit exceeded");
|
|
16532
|
-
|
|
17170
|
+
const p = this.budget.checkpointSync();
|
|
17171
|
+
if (p) await p;
|
|
16533
17172
|
const next = this.asText(this.array("ARGV").entries.get(String(this.argument++)) ?? unset);
|
|
16534
17173
|
if (!next) continue;
|
|
16535
17174
|
if (this.operandAssignments && /^[A-Za-z_][A-Za-z0-9_]*=/u.test(next)) {
|
|
@@ -16555,8 +17194,8 @@ var AwkRuntime = class {
|
|
|
16555
17194
|
this.mainReader = void 0;
|
|
16556
17195
|
continue;
|
|
16557
17196
|
}
|
|
16558
|
-
this.
|
|
16559
|
-
this.
|
|
17197
|
+
this.incrementCounter("NR");
|
|
17198
|
+
this.incrementCounter("FNR");
|
|
16560
17199
|
return record3;
|
|
16561
17200
|
}
|
|
16562
17201
|
}
|
|
@@ -16574,19 +17213,27 @@ var AwkRuntime = class {
|
|
|
16574
17213
|
const ranges2 = /* @__PURE__ */ new Set();
|
|
16575
17214
|
if (!stopped && (this.program.rules.length || this.program.end.length)) while (true) {
|
|
16576
17215
|
this.budget.step();
|
|
16577
|
-
const
|
|
17216
|
+
const recOrPromise = this.readMainRecordSync();
|
|
17217
|
+
const record3 = recOrPromise instanceof Promise ? await recOrPromise : recOrPromise;
|
|
16578
17218
|
if (record3 === void 0) break;
|
|
16579
|
-
|
|
17219
|
+
const setRecPromise = this.setRecordSync(record3);
|
|
17220
|
+
if (setRecPromise instanceof Promise) await setRecPromise;
|
|
16580
17221
|
try {
|
|
16581
17222
|
for (let index = 0; index < this.program.rules.length; index++) {
|
|
16582
17223
|
const rule = this.program.rules[index];
|
|
16583
|
-
|
|
17224
|
+
let selected2 = !rule.pattern || ranges2.has(index);
|
|
17225
|
+
if (!selected2) {
|
|
17226
|
+
const patVal = this.scalarExpression(rule.pattern);
|
|
17227
|
+
selected2 = truth(patVal instanceof Promise ? await patVal : patVal);
|
|
17228
|
+
}
|
|
16584
17229
|
if (!selected2) continue;
|
|
16585
17230
|
if (rule.end) {
|
|
16586
|
-
|
|
17231
|
+
const endVal = this.scalarExpression(rule.end);
|
|
17232
|
+
if (truth(endVal instanceof Promise ? await endVal : endVal)) ranges2.delete(index);
|
|
16587
17233
|
else ranges2.add(index);
|
|
16588
17234
|
}
|
|
16589
|
-
|
|
17235
|
+
const execRes = this.executeSync(rule.action);
|
|
17236
|
+
if (execRes instanceof Promise) await execRes;
|
|
16590
17237
|
}
|
|
16591
17238
|
} catch (error) {
|
|
16592
17239
|
if (!(error instanceof Flow)) throw error;
|
|
@@ -17666,6 +18313,7 @@ var Matcher = class {
|
|
|
17666
18313
|
session;
|
|
17667
18314
|
descriptor;
|
|
17668
18315
|
async batch(rows2) {
|
|
18316
|
+
trustedInputRows.add(rows2);
|
|
17669
18317
|
try {
|
|
17670
18318
|
return await this.session.run(this.descriptor, rows2);
|
|
17671
18319
|
} catch (error) {
|
|
@@ -17716,7 +18364,8 @@ var Limits = class {
|
|
|
17716
18364
|
signal;
|
|
17717
18365
|
tick() {
|
|
17718
18366
|
this.context.signal.throwIfAborted();
|
|
17719
|
-
|
|
18367
|
+
const interval = hasYieldCheckpoint(this.context.signal) ? 128 : 2048;
|
|
18368
|
+
if (++this.ticks % interval === 0) return yieldTurn(this.context.signal);
|
|
17720
18369
|
return void 0;
|
|
17721
18370
|
}
|
|
17722
18371
|
async write(chunk) {
|
|
@@ -17766,8 +18415,14 @@ async function* lineBatches(source2, limits, state, binary3, nullData, maxRecord
|
|
|
17766
18415
|
return;
|
|
17767
18416
|
}
|
|
17768
18417
|
let start = 0;
|
|
17769
|
-
|
|
17770
|
-
|
|
18418
|
+
let next = extraDelimiter === -1 ? chunk.indexOf(delimiter, 0) : (() => {
|
|
18419
|
+
for (let scan = 0; scan < chunk.length; scan++) {
|
|
18420
|
+
if (chunk[scan] === delimiter || chunk[scan] === extraDelimiter) return scan;
|
|
18421
|
+
}
|
|
18422
|
+
return -1;
|
|
18423
|
+
})();
|
|
18424
|
+
while (next >= 0) {
|
|
18425
|
+
const end = next;
|
|
17771
18426
|
if (pending.length + end - start > limits.maxLineBytes) throw new SearchError("line byte limit exceeded");
|
|
17772
18427
|
let content;
|
|
17773
18428
|
let bytes3;
|
|
@@ -17784,13 +18439,12 @@ async function* lineBatches(source2, limits, state, binary3, nullData, maxRecord
|
|
|
17784
18439
|
offset += bytes3.length;
|
|
17785
18440
|
pending = emptyBuffer;
|
|
17786
18441
|
start = end + 1;
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
next = scan;
|
|
17791
|
-
break;
|
|
18442
|
+
next = extraDelimiter === -1 ? chunk.indexOf(delimiter, start) : (() => {
|
|
18443
|
+
for (let scan = start; scan < chunk.length; scan++) {
|
|
18444
|
+
if (chunk[scan] === delimiter || chunk[scan] === extraDelimiter) return scan;
|
|
17792
18445
|
}
|
|
17793
|
-
|
|
18446
|
+
return -1;
|
|
18447
|
+
})();
|
|
17794
18448
|
if (batch.length >= maxRecords() || batchBytes >= 64 * 1024 || next < 0 || batchBytes + next - start > 64 * 1024 || next - start > limits.maxLineBytes) {
|
|
17795
18449
|
yield batch;
|
|
17796
18450
|
batch = [];
|
|
@@ -18561,6 +19215,54 @@ async function* grepFiles(context2, parsed, filters, report2) {
|
|
|
18561
19215
|
}
|
|
18562
19216
|
|
|
18563
19217
|
// packages/safe-bash/src/commands/search/grep.ts
|
|
19218
|
+
async function* grepLineBatches(source2, separator, maxLineBytes, maxRecords) {
|
|
19219
|
+
const pending = new RecordBuffer(bufferLimit);
|
|
19220
|
+
let batch = [];
|
|
19221
|
+
let bytes3 = 0;
|
|
19222
|
+
try {
|
|
19223
|
+
for await (const rawChunk of source2) {
|
|
19224
|
+
const chunk = Uint8Array.from(rawChunk);
|
|
19225
|
+
let start = 0;
|
|
19226
|
+
while (start < chunk.length) {
|
|
19227
|
+
const end = chunk.indexOf(separator, start);
|
|
19228
|
+
if (end < 0) break;
|
|
19229
|
+
let line;
|
|
19230
|
+
if (pending.size === 0) {
|
|
19231
|
+
const tailLength = end - start;
|
|
19232
|
+
if (tailLength > bufferLimit) {
|
|
19233
|
+
throw new contracts_exports.FsError("EFBIG", { message: "line buffer limit exceeded" });
|
|
19234
|
+
}
|
|
19235
|
+
line = {
|
|
19236
|
+
bytes: chunk.subarray(start, end),
|
|
19237
|
+
raw: chunk.subarray(start, end + 1),
|
|
19238
|
+
terminated: true
|
|
19239
|
+
};
|
|
19240
|
+
} else {
|
|
19241
|
+
line = {
|
|
19242
|
+
bytes: pending.finish(void 0, chunk, start, end),
|
|
19243
|
+
terminated: true
|
|
19244
|
+
};
|
|
19245
|
+
}
|
|
19246
|
+
start = end + 1;
|
|
19247
|
+
batch.push(line);
|
|
19248
|
+
bytes3 += line.bytes.length;
|
|
19249
|
+
const next = chunk.indexOf(separator, start);
|
|
19250
|
+
if (batch.length >= maxRecords() || bytes3 >= 64 * 1024 || next < 0 || bytes3 + next - start > 64 * 1024 || next - start > maxLineBytes) {
|
|
19251
|
+
yield batch;
|
|
19252
|
+
batch = [];
|
|
19253
|
+
bytes3 = 0;
|
|
19254
|
+
}
|
|
19255
|
+
}
|
|
19256
|
+
pending.append(chunk, start);
|
|
19257
|
+
}
|
|
19258
|
+
if (pending.size) {
|
|
19259
|
+
batch.push({ bytes: pending.finish(), terminated: false });
|
|
19260
|
+
}
|
|
19261
|
+
if (batch.length) yield batch;
|
|
19262
|
+
} finally {
|
|
19263
|
+
pending.clear();
|
|
19264
|
+
}
|
|
19265
|
+
}
|
|
18564
19266
|
function createGrepCommands(executor, limits = {}) {
|
|
18565
19267
|
for (const value2 of Object.values(limits)) {
|
|
18566
19268
|
if (!Number.isSafeInteger(value2) || value2 < 1) throw new RangeError("grep limits must be positive safe integers");
|
|
@@ -18714,6 +19416,31 @@ inspect the resulting state before repeating the action.
|
|
|
18714
19416
|
const maxCount = value(parsed, "m") === void 0 ? Infinity : integer(value(parsed, "m"));
|
|
18715
19417
|
const batchSize = Number.isFinite(maxCount) || parsed.flags.has("q") || parsed.flags.has("l") || parsed.flags.has("L") ? 1 : 128;
|
|
18716
19418
|
const delimiter = parsed.flags.has("z") ? "\0" : "\n";
|
|
19419
|
+
const delimiterBytes = encoder.encode(delimiter);
|
|
19420
|
+
const lineBuffered = parsed.flags.has("line-buffered");
|
|
19421
|
+
let outBuffer;
|
|
19422
|
+
let outUsed = 0;
|
|
19423
|
+
const flushOut = async () => {
|
|
19424
|
+
if (!outBuffer || outUsed === 0) return;
|
|
19425
|
+
const view = outBuffer.subarray(0, outUsed);
|
|
19426
|
+
outUsed = 0;
|
|
19427
|
+
await output(context2, view);
|
|
19428
|
+
};
|
|
19429
|
+
const writeOut = async (chunk) => {
|
|
19430
|
+
const bytes3 = typeof chunk === "string" ? chunk.length === 0 ? void 0 : encoder.encode(chunk) : chunk.length === 0 ? void 0 : chunk;
|
|
19431
|
+
if (!bytes3) return;
|
|
19432
|
+
if (lineBuffered || bytes3.length > 64 * 1024) {
|
|
19433
|
+
await flushOut();
|
|
19434
|
+
await output(context2, bytes3);
|
|
19435
|
+
return;
|
|
19436
|
+
}
|
|
19437
|
+
outBuffer ??= new Uint8Array(64 * 1024);
|
|
19438
|
+
if (outUsed + bytes3.length > outBuffer.length) {
|
|
19439
|
+
await flushOut();
|
|
19440
|
+
}
|
|
19441
|
+
outBuffer.set(bytes3, outUsed);
|
|
19442
|
+
outUsed += bytes3.length;
|
|
19443
|
+
};
|
|
18717
19444
|
const extractMatches = parsed.flags.has("o") && !["c", "q", "l", "L", "v"].some((flag) => parsed.flags.has(flag));
|
|
18718
19445
|
const displayLines = !["c", "q", "l", "L"].some((flag) => parsed.flags.has(flag));
|
|
18719
19446
|
const withContext = [...contextLengths.values()].some((length) => length > 0) && displayLines && !(parsed.flags.has("o") && parsed.flags.has("v"));
|
|
@@ -18737,17 +19464,18 @@ inspect the resulting state before repeating the action.
|
|
|
18737
19464
|
const prefix3 = (lineNumber = false, position = number6, separator = ":", offset = byteOffset) => `${!parsed.flags.has("h") && (parsed.flags.has("H") || multipleFiles || nested) ? `${named2}${parsed.flags.has("Z") ? "\0" : separator}` : ""}${lineNumber && parsed.flags.has("n") ? `${position}${separator}` : ""}${lineNumber && parsed.flags.has("b") ? `${offset}${separator}` : ""}${lineNumber && parsed.flags.has("initial-tab") && (parsed.flags.has("n") || parsed.flags.has("b") || !parsed.flags.has("h") && (parsed.flags.has("H") || multipleFiles || nested)) ? " " : ""}`;
|
|
18738
19465
|
const emitContext = async (line, position, offset = byteOffset) => {
|
|
18739
19466
|
if (!parsed.flags.has("o")) {
|
|
18740
|
-
await
|
|
18741
|
-
await
|
|
18742
|
-
await
|
|
19467
|
+
await writeOut(prefix3(true, position, "-", offset));
|
|
19468
|
+
await writeOut(line.bytes);
|
|
19469
|
+
await writeOut(delimiterBytes);
|
|
18743
19470
|
}
|
|
18744
19471
|
lastCovered = position;
|
|
18745
19472
|
};
|
|
18746
19473
|
try {
|
|
18747
|
-
const available2 = new AvailableRecords(parsed.flags.has("z") ? 0 : 10, limits.maxLineBytes ?? Infinity);
|
|
18748
19474
|
const source2 = name2 === "-" ? input(context2) : requiredFileInput(context2, grepRequirements, "file", name2, limits.maxFileBytes ?? Infinity);
|
|
18749
|
-
records: if (maxCount > 0) for await (const batch of
|
|
18750
|
-
const
|
|
19475
|
+
records: if (maxCount > 0) for await (const batch of grepLineBatches(source2, parsed.flags.has("z") ? 0 : 10, limits.maxLineBytes ?? Infinity, () => batchSize)) {
|
|
19476
|
+
const rows2 = batch.map((line) => ({ bytes: line.bytes, all: extractMatches, terminated: line.terminated }));
|
|
19477
|
+
trustedInputRows.add(rows2);
|
|
19478
|
+
const results = await session.run(descriptor, rows2);
|
|
18751
19479
|
for (let index = 0; index < batch.length; index++) {
|
|
18752
19480
|
const line = batch[index];
|
|
18753
19481
|
context2.signal.throwIfAborted();
|
|
@@ -18781,7 +19509,7 @@ inspect the resulting state before repeating the action.
|
|
|
18781
19509
|
if (!parsed.flags.has("c")) {
|
|
18782
19510
|
if (withContext) {
|
|
18783
19511
|
const first = pending.keys().next().value ?? number6;
|
|
18784
|
-
if (!parsed.flags.has("no-group-separator") && emittedGroup && (lastCovered === 0 || first > lastCovered + 1)) await
|
|
19512
|
+
if (!parsed.flags.has("no-group-separator") && emittedGroup && (lastCovered === 0 || first > lastCovered + 1)) await writeOut((value(parsed, "group-separator") ?? "--") + delimiter);
|
|
18785
19513
|
for (const [position, previous] of pending) await emitContext(previous, position, previous.offset);
|
|
18786
19514
|
pending.clear();
|
|
18787
19515
|
pendingBytes = 0;
|
|
@@ -18794,26 +19522,32 @@ inspect the resulting state before repeating the action.
|
|
|
18794
19522
|
let end = -1;
|
|
18795
19523
|
for (const match of found) {
|
|
18796
19524
|
if (match.start === match.end || match.start < end) continue;
|
|
18797
|
-
await
|
|
18798
|
-
await
|
|
18799
|
-
await
|
|
19525
|
+
await writeOut(prefix3(true, number6, ":", byteOffset + match.start));
|
|
19526
|
+
await writeOut(line.bytes.subarray(match.start, match.end));
|
|
19527
|
+
await writeOut(delimiterBytes);
|
|
18800
19528
|
end = match.end;
|
|
18801
19529
|
}
|
|
18802
19530
|
}
|
|
18803
19531
|
} else {
|
|
18804
|
-
|
|
18805
|
-
await
|
|
18806
|
-
await
|
|
19532
|
+
const p = prefix3(true);
|
|
19533
|
+
if (p) await writeOut(p);
|
|
19534
|
+
if (line.raw) await writeOut(line.raw);
|
|
19535
|
+
else {
|
|
19536
|
+
await writeOut(line.bytes);
|
|
19537
|
+
await writeOut(delimiterBytes);
|
|
19538
|
+
}
|
|
18807
19539
|
}
|
|
18808
19540
|
}
|
|
18809
19541
|
if (count2 >= maxCount && remainingAfter === 0) break records;
|
|
18810
19542
|
}
|
|
18811
19543
|
}
|
|
19544
|
+
await flushOut();
|
|
18812
19545
|
if (parsed.flags.has("q")) continue;
|
|
18813
19546
|
if (parsed.flags.has("l") && count2 > 0 || parsed.flags.has("L") && count2 === 0) {
|
|
18814
19547
|
await output(context2, named2 + (parsed.flags.has("Z") ? "\0" : "\n"));
|
|
18815
19548
|
} else if (parsed.flags.has("c") && !parsed.flags.has("l") && !parsed.flags.has("L")) await output(context2, prefix3() + count2 + delimiter);
|
|
18816
19549
|
} catch (error) {
|
|
19550
|
+
await flushOut();
|
|
18817
19551
|
context2.signal.throwIfAborted();
|
|
18818
19552
|
if (error instanceof RegexExecutionError) throw error;
|
|
18819
19553
|
failed = true;
|
|
@@ -47067,11 +47801,70 @@ function commandExecutor(lookup) {
|
|
|
47067
47801
|
return { exitCode: 127 };
|
|
47068
47802
|
};
|
|
47069
47803
|
}
|
|
47070
|
-
|
|
47804
|
+
var cachedDefaultStatelessFamilies;
|
|
47805
|
+
function getDefaultStatelessFamilies() {
|
|
47806
|
+
return cachedDefaultStatelessFamilies ??= {
|
|
47807
|
+
beforeAliases: Object.freeze([
|
|
47808
|
+
...createTextProgramCommands({}),
|
|
47809
|
+
...createStructuredCommands({}),
|
|
47810
|
+
...createByteCommands(void 0),
|
|
47811
|
+
...createDiffPatchCommands({}),
|
|
47812
|
+
...createMetadataCommands({}),
|
|
47813
|
+
...createArchiveCommands({}),
|
|
47814
|
+
...createTableTextCommands({}),
|
|
47815
|
+
...createStreamInspectionCommands({}),
|
|
47816
|
+
...createStreamFormatCommands({}),
|
|
47817
|
+
...createSplitCommands({}),
|
|
47818
|
+
...createTimeEnvCommands({}),
|
|
47819
|
+
...createTreeCommands({}),
|
|
47820
|
+
...createFileCommands({})
|
|
47821
|
+
]),
|
|
47822
|
+
beforeExpr: Object.freeze([
|
|
47823
|
+
...createColumnCommands({}),
|
|
47824
|
+
...createHtmlToMarkdownCommands({}),
|
|
47825
|
+
...createDuCommands({})
|
|
47826
|
+
]),
|
|
47827
|
+
beforeCsplit: Object.freeze([
|
|
47828
|
+
...createWhichCommands({}),
|
|
47829
|
+
...createTimeoutCommands(void 0),
|
|
47830
|
+
...createApplyPatchCommands({}),
|
|
47831
|
+
...createXmlCommands({})
|
|
47832
|
+
]),
|
|
47833
|
+
afterCsplit: Object.freeze([
|
|
47834
|
+
...createPrCommands({}),
|
|
47835
|
+
...createTsortCommands({}),
|
|
47836
|
+
...createFactorCommands({}),
|
|
47837
|
+
...createGetoptCommands({}),
|
|
47838
|
+
...createHexdumpCommands({}),
|
|
47839
|
+
...createIconvCommands({}),
|
|
47840
|
+
...createLineEndingCommands({})
|
|
47841
|
+
])
|
|
47842
|
+
};
|
|
47843
|
+
}
|
|
47844
|
+
function hasCustomFamilyOptions(options2) {
|
|
47845
|
+
return options2.text !== void 0 || options2.structured !== void 0 || options2.bytes !== void 0 || options2.diffPatch !== void 0 || options2.metadata !== void 0 || options2.archive !== void 0 || options2.tableText !== void 0 || options2.streamInspection !== void 0 || options2.streamFormat !== void 0 || options2.split !== void 0 || options2.timeEnv !== void 0 || options2.tree !== void 0 || options2.file !== void 0 || options2.column !== void 0 || options2.htmlToMarkdown !== void 0 || options2.du !== void 0 || options2.which !== void 0 || options2.timeout !== void 0 || options2.applyPatch !== void 0 || options2.xml !== void 0 || options2.pr !== void 0 || options2.tsort !== void 0 || options2.factor !== void 0 || options2.getopt !== void 0 || options2.hexdump !== void 0 || options2.iconv !== void 0 || options2.lineEndings !== void 0;
|
|
47846
|
+
}
|
|
47847
|
+
function composeRawAgentCommands(options2, executors) {
|
|
47071
47848
|
const commands = [];
|
|
47072
47849
|
const grep = createGrepCommands(executors.grep);
|
|
47073
47850
|
const exprLimits = options2.expr?.limits;
|
|
47074
47851
|
const csplitLimits = options2.csplit?.limits;
|
|
47852
|
+
if (!hasCustomFamilyOptions(options2)) {
|
|
47853
|
+
const defaults = getDefaultStatelessFamilies();
|
|
47854
|
+
const aliasesGrep = executors.aliases === executors.grep ? grep[0] : createGrepCommands(executors.aliases)[0];
|
|
47855
|
+
commands.push(
|
|
47856
|
+
...createStandardCommandsWithGrep({ execute: options2.execute ?? commandExecutor((name2) => commands.find((command7) => command7.name === name2)), ...options2.execution === void 0 ? {} : { execution: options2.execution }, ...options2.regex === void 0 ? {} : { regex: options2.regex }, ...options2.maxDirectoryEntries === void 0 ? {} : { maxDirectoryEntries: options2.maxDirectoryEntries }, ...options2.maxTeeTargets === void 0 ? {} : { maxTeeTargets: options2.maxTeeTargets }, ...options2.maxTailFollowHandles === void 0 ? {} : { maxTailFollowHandles: options2.maxTailFollowHandles } }, grep),
|
|
47857
|
+
...defaults.beforeAliases,
|
|
47858
|
+
createRgCommand(executors.search, options2.search),
|
|
47859
|
+
...createGrepAliases(aliasesGrep),
|
|
47860
|
+
...defaults.beforeExpr,
|
|
47861
|
+
createExprCommandWithExecutor(executors.expr, exprLimits === void 0 ? {} : { limits: exprLimits }),
|
|
47862
|
+
...defaults.beforeCsplit,
|
|
47863
|
+
createCsplitCommandWithExecutor(executors.csplit, csplitLimits === void 0 ? {} : { limits: csplitLimits }),
|
|
47864
|
+
...defaults.afterCsplit
|
|
47865
|
+
);
|
|
47866
|
+
return commands;
|
|
47867
|
+
}
|
|
47075
47868
|
const prOptions = options2.pr;
|
|
47076
47869
|
const prLimits = prOptions?.limits;
|
|
47077
47870
|
const prClock = prOptions?.clock;
|
|
@@ -47124,7 +47917,10 @@ function composeAgentCommands(options2, executors) {
|
|
|
47124
47917
|
...createIconvCommands(iconvLimits === void 0 ? {} : { limits: iconvLimits }),
|
|
47125
47918
|
...createLineEndingCommands(lineEndingLimits === void 0 ? {} : { limits: lineEndingLimits })
|
|
47126
47919
|
);
|
|
47127
|
-
return
|
|
47920
|
+
return commands;
|
|
47921
|
+
}
|
|
47922
|
+
function composeAgentCommands(options2, executors) {
|
|
47923
|
+
return new contracts_exports.CommandRegistry(composeRawAgentCommands(options2, executors)).list();
|
|
47128
47924
|
}
|
|
47129
47925
|
|
|
47130
47926
|
// packages/safe-bash/src/plugins/index.ts
|
|
@@ -47146,7 +47942,7 @@ function agentCommands(options2 = {}) {
|
|
|
47146
47942
|
setup(host2) {
|
|
47147
47943
|
if (disposal) throw new Error("Agent commands are disposed");
|
|
47148
47944
|
host2.provideCapabilities?.({ regex: { executor: executors.grep.provider, limits: regex } });
|
|
47149
|
-
const definitions =
|
|
47945
|
+
const definitions = composeRawAgentCommands({ ...options2, execute: options2.execute ?? commandExecutor((name2) => host2.commands.get(name2)) }, executors);
|
|
47150
47946
|
if (!options2.replace) for (const definition3 of definitions) {
|
|
47151
47947
|
if (host2.commands.has(definition3.name)) throw new Error(`Command already registered: ${definition3.name}`);
|
|
47152
47948
|
}
|
|
@@ -67225,7 +68021,7 @@ function makeSafeJsShellModule(executor, options2) {
|
|
|
67225
68021
|
__reExport(core_browser_exports, core_exports);
|
|
67226
68022
|
import { CommandArgumentIdentityError, createCommandArguments as createCommandArguments5, getCommandArguments as getCommandArguments16, commandRuntimeIdentity as commandRuntimeIdentity3, CommandRegistry as CommandRegistry3, validateExitCode as validateExitCode2 } from "../safe-bash-contracts/command.js";
|
|
67227
68023
|
import { evaluateCommandSupport, assertCommandRequirements as assertCommandRequirements11 } from "../safe-bash-contracts/command-requirements.js";
|
|
67228
|
-
import { isErrnoCode, isFsError as isFsError10, toFsError, FsError as
|
|
68024
|
+
import { isErrnoCode, isFsError as isFsError10, toFsError, FsError as FsError62 } from "../safe-bash-contracts/errors.js";
|
|
67229
68025
|
import { ACCESS_MODES as ACCESS_MODES3 } from "../safe-bash-contracts/filesystem.js";
|
|
67230
68026
|
import { collectBytes as collectBytes11, readBytes as readBytes33, toByteSource as toByteSource8, outputFailure as outputFailure3, createBytePipe as createBytePipe2, writeText as writeText4, writeBytes as writeBytes32, pipeBytes as pipeBytes2, collectText } from "../safe-bash-contracts/io.js";
|
|
67231
68027
|
import { createOutputOperation as createOutputOperation11 } from "../safe-bash-contracts/output.js";
|
|
@@ -67241,7 +68037,7 @@ export {
|
|
|
67241
68037
|
EreSyntaxError,
|
|
67242
68038
|
EreUnsupportedError,
|
|
67243
68039
|
EreUsageUnknownError,
|
|
67244
|
-
|
|
68040
|
+
FsError62 as FsError,
|
|
67245
68041
|
MemoryFileSystem,
|
|
67246
68042
|
MountFileSystem,
|
|
67247
68043
|
OverlayFileSystem,
|