just-bash 3.2.0 → 3.3.0

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +47 -0
  3. package/dist/ast/types.d.ts +4 -1
  4. package/dist/bin/chunks/{chunk-QF7PPON7.js → chunk-5SR55TXB.js} +10 -10
  5. package/dist/bin/{shell/chunks/chunk-TL4JI2SL.js → chunks/chunk-6UK23ZFT.js} +17 -18
  6. package/dist/bin/chunks/{chunk-XBB73LFB.js → chunk-CMTQFWZK.js} +2 -2
  7. package/dist/bin/chunks/{chunk-YMELOXDK.js → chunk-D5G3L4PR.js} +8 -8
  8. package/dist/bin/chunks/{chunk-PRKSLEHG.js → chunk-DKIOFM35.js} +1 -1
  9. package/dist/bin/chunks/chunk-IJIJAQBT.js +12 -0
  10. package/dist/bin/{shell/chunks/chunk-NQQ3X7MZ.js → chunks/chunk-KXWWWQZK.js} +1 -1
  11. package/dist/bin/chunks/{chunk-3HUI54BW.js → chunk-TROO33BG.js} +1 -1
  12. package/dist/bin/chunks/chunk-USMDLXMM.js +21 -0
  13. package/dist/bin/{shell/chunks/chunk-JQER3HUP.js → chunks/chunk-XAVWLYZR.js} +1 -1
  14. package/dist/bin/chunks/{echo-4OUEL7QB.js → echo-NYDCCFWB.js} +1 -1
  15. package/dist/bin/chunks/{flag-coverage-WGSE667D.js → flag-coverage-EB3DK32J.js} +1 -1
  16. package/dist/bin/chunks/{grep-CMT2H2S7.js → grep-73YHJEX4.js} +1 -1
  17. package/dist/bin/{shell/chunks/jq-ACCMBTSD.js → chunks/jq-AO5GTPN4.js} +1 -1
  18. package/dist/bin/chunks/js-exec-worker.js +56 -20
  19. package/dist/bin/{shell/chunks/printf-F2KOCULO.js → chunks/printf-CNXNRQ3I.js} +1 -1
  20. package/dist/bin/chunks/python3-N252MJV6.js +14 -0
  21. package/dist/bin/{shell/chunks/rg-JRKJ6I4X.js → chunks/rg-OGGL3RIE.js} +1 -1
  22. package/dist/bin/chunks/{sqlite3-ZXF6BGDW.js → sqlite3-FEUFATVW.js} +1 -1
  23. package/dist/bin/chunks/worker.js +17 -1
  24. package/dist/bin/chunks/{xan-D6US4ZGL.js → xan-Q52EBQYW.js} +1 -1
  25. package/dist/bin/chunks/{yq-EYV7HLKK.js → yq-UA5NX5RT.js} +1 -1
  26. package/dist/bin/just-bash.js +391 -389
  27. package/dist/bin/shell/chunks/{chunk-QF7PPON7.js → chunk-5SR55TXB.js} +10 -10
  28. package/dist/bin/{chunks/chunk-TL4JI2SL.js → shell/chunks/chunk-6UK23ZFT.js} +17 -18
  29. package/dist/bin/shell/chunks/{chunk-XBB73LFB.js → chunk-CMTQFWZK.js} +2 -2
  30. package/dist/bin/shell/chunks/{chunk-YMELOXDK.js → chunk-D5G3L4PR.js} +8 -8
  31. package/dist/bin/shell/chunks/{chunk-PRKSLEHG.js → chunk-DKIOFM35.js} +1 -1
  32. package/dist/bin/shell/chunks/chunk-IJIJAQBT.js +12 -0
  33. package/dist/bin/{chunks/chunk-NQQ3X7MZ.js → shell/chunks/chunk-KXWWWQZK.js} +1 -1
  34. package/dist/bin/shell/chunks/{chunk-3HUI54BW.js → chunk-TROO33BG.js} +1 -1
  35. package/dist/bin/shell/chunks/chunk-USMDLXMM.js +21 -0
  36. package/dist/bin/{chunks/chunk-JQER3HUP.js → shell/chunks/chunk-XAVWLYZR.js} +1 -1
  37. package/dist/bin/shell/chunks/{echo-4OUEL7QB.js → echo-NYDCCFWB.js} +1 -1
  38. package/dist/bin/shell/chunks/{flag-coverage-WGSE667D.js → flag-coverage-EB3DK32J.js} +1 -1
  39. package/dist/bin/shell/chunks/{grep-CMT2H2S7.js → grep-73YHJEX4.js} +1 -1
  40. package/dist/bin/{chunks/jq-ACCMBTSD.js → shell/chunks/jq-AO5GTPN4.js} +1 -1
  41. package/dist/bin/{chunks/printf-F2KOCULO.js → shell/chunks/printf-CNXNRQ3I.js} +1 -1
  42. package/dist/bin/shell/chunks/python3-N252MJV6.js +14 -0
  43. package/dist/bin/{chunks/rg-JRKJ6I4X.js → shell/chunks/rg-OGGL3RIE.js} +1 -1
  44. package/dist/bin/shell/chunks/{sqlite3-ZXF6BGDW.js → sqlite3-FEUFATVW.js} +1 -1
  45. package/dist/bin/shell/chunks/{xan-D6US4ZGL.js → xan-Q52EBQYW.js} +1 -1
  46. package/dist/bin/shell/chunks/{yq-EYV7HLKK.js → yq-UA5NX5RT.js} +1 -1
  47. package/dist/bin/shell/shell.js +396 -394
  48. package/dist/bundle/browser.js +836 -823
  49. package/dist/bundle/chunks/{chunk-RAHPENCM.js → chunk-3ZBJCAAR.js} +1 -1
  50. package/dist/bundle/chunks/{chunk-AMLHAS2N.js → chunk-4AKAIZPW.js} +9 -9
  51. package/dist/bundle/chunks/{chunk-6SHYIICL.js → chunk-AGH5UJJI.js} +2 -2
  52. package/dist/bundle/chunks/{chunk-NOPXHH6G.js → chunk-EZDB7TGH.js} +1 -1
  53. package/dist/bundle/chunks/chunk-FC5NW7U4.js +11 -0
  54. package/dist/bundle/chunks/{chunk-5KGKXQF6.js → chunk-FHFPWM4W.js} +1 -1
  55. package/dist/bundle/chunks/chunk-H3PXMIY3.js +20 -0
  56. package/dist/bundle/chunks/{chunk-EWWPEE2G.js → chunk-IHGFM3FN.js} +17 -18
  57. package/dist/bundle/chunks/{chunk-65Z4QURM.js → chunk-J5G3ZBEK.js} +8 -8
  58. package/dist/bundle/chunks/{chunk-WENIVVEE.js → chunk-LTCWFMCI.js} +1 -1
  59. package/dist/bundle/chunks/{echo-HZOVZAPR.js → echo-PLLZYM2L.js} +1 -1
  60. package/dist/bundle/chunks/{flag-coverage-THYQHOT3.js → flag-coverage-UV7GI2DF.js} +1 -1
  61. package/dist/bundle/chunks/{grep-S6SNTIHZ.js → grep-UDCQDUQK.js} +1 -1
  62. package/dist/bundle/chunks/{jq-D6N4QCAJ.js → jq-B5324QOX.js} +1 -1
  63. package/dist/bundle/chunks/js-exec-worker.js +56 -20
  64. package/dist/bundle/chunks/{printf-QHD2JRWQ.js → printf-V42QCPHL.js} +1 -1
  65. package/dist/bundle/chunks/python3-ETPBGJP3.js +13 -0
  66. package/dist/bundle/chunks/{rg-OUJZ5DH6.js → rg-XCX2J2RF.js} +1 -1
  67. package/dist/bundle/chunks/{sqlite3-WWZJZW37.js → sqlite3-ZTQJIC3G.js} +1 -1
  68. package/dist/bundle/chunks/worker.js +17 -1
  69. package/dist/bundle/chunks/{xan-KKPV2TJ3.js → xan-EGU5VRRP.js} +1 -1
  70. package/dist/bundle/chunks/{yq-ZGB3W46S.js → yq-FMWLA3S2.js} +1 -1
  71. package/dist/bundle/index.cjs +1026 -1014
  72. package/dist/bundle/index.js +391 -389
  73. package/dist/commands/python3/worker.d.ts +1 -0
  74. package/dist/commands/query-engine/evaluator.d.ts +8 -0
  75. package/dist/fs/read-write-fs/read-write-fs.d.ts +42 -1
  76. package/dist/interpreter/builtin-dispatch.d.ts +9 -2
  77. package/dist/interpreter/builtins/eval.d.ts +7 -1
  78. package/dist/interpreter/control-flow.d.ts +1 -1
  79. package/dist/interpreter/fd-table.d.ts +130 -0
  80. package/dist/interpreter/functions.d.ts +3 -1
  81. package/dist/interpreter/helpers/word-matching.d.ts +0 -10
  82. package/dist/interpreter/interpreter.d.ts +7 -0
  83. package/dist/interpreter/numeric-fd-redirects.d.ts +8 -0
  84. package/dist/interpreter/process-substitution.d.ts +62 -0
  85. package/dist/interpreter/redirections.d.ts +33 -37
  86. package/dist/interpreter/subshell-group.d.ts +10 -2
  87. package/dist/interpreter/types.d.ts +38 -1
  88. package/dist/network/dns-pin.d.ts +11 -0
  89. package/dist/parser/expansion-parser.d.ts +3 -1
  90. package/dist/parser/lexer.d.ts +7 -9
  91. package/dist/parser/parser-substitution.d.ts +13 -4
  92. package/dist/parser/parser.d.ts +18 -4
  93. package/dist/parser/types.d.ts +6 -0
  94. package/dist/parser/word-parser.d.ts +2 -0
  95. package/dist/types.d.ts +6 -0
  96. package/package.json +1 -1
  97. package/dist/bin/chunks/chunk-P6NPCASY.js +0 -11
  98. package/dist/bin/chunks/chunk-WYTPLN2M.js +0 -11
  99. package/dist/bin/chunks/python3-AYUQQRCR.js +0 -14
  100. package/dist/bin/shell/chunks/chunk-P6NPCASY.js +0 -11
  101. package/dist/bin/shell/chunks/chunk-WYTPLN2M.js +0 -11
  102. package/dist/bin/shell/chunks/python3-AYUQQRCR.js +0 -14
  103. package/dist/bundle/chunks/chunk-VECGTAPW.js +0 -10
  104. package/dist/bundle/chunks/chunk-YOUUMJLJ.js +0 -10
  105. package/dist/bundle/chunks/python3-QDNG2UXX.js +0 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # just-bash
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#291](https://github.com/vercel-labs/just-bash/pull/291) [`47f604a`](https://github.com/vercel-labs/just-bash/commit/47f604a7f1e12730318e4c88c7872a5a35383056) Thanks [@trieloff](https://github.com/trieloff)! - jq: add external-argument flags (`--arg`, `--argjson`, `--rawfile`, `--slurpfile`, `--args`, `--jsonargs`) and the `$ARGS` object (`$ARGS.named` / `$ARGS.positional`), matching real jq 1.7.1 behavior including exit codes, error messages, and prototype-sensitive key handling.
8
+
9
+ - [#336](https://github.com/vercel-labs/just-bash/pull/336) [`d97425d`](https://github.com/vercel-labs/just-bash/commit/d97425dff8f51cfd773d22bc009561a09235cd1b) Thanks [@trieloff](https://github.com/trieloff)! - Support user file descriptors (fd >= 3). `exec 3< file`, `N< file` / `N> file` / `N>> file` on any command, `read -u N`, `read <&N`, `>&N`, `N<&M`, and `N<&-` now go through a real descriptor table: a descriptor carries one shared read position, `exec` keeps it open until it is closed, and every other construct — including `done N< file` on a loop — gets it only for the duration of that command.
10
+
11
+ - [#331](https://github.com/vercel-labs/just-bash/pull/331) [`6680247`](https://github.com/vercel-labs/just-bash/commit/66802470837cfac3a58a09e00d37b2070387ba7b) Thanks [@trieloff](https://github.com/trieloff)! - Treat a `-` FILE operand in `grep` as standard input, matching GNU. `grep PATTERN -` now reads stdin instead of failing with "No such file or directory", stdin is labelled `(standard input)` in the multi-file prefix and in `-l`/`-L`/`-c` output, repeated `-` operands see the stream drained by the first one, and `-` is exempt from `-r` recursion and `--include`/`--exclude` filtering.
12
+
13
+ - [#325](https://github.com/vercel-labs/just-bash/pull/325) [`edc7f2f`](https://github.com/vercel-labs/just-bash/commit/edc7f2fac5337cebd19911c5756b76ed02e52090) Thanks [@trieloff](https://github.com/trieloff)! - Support process substitution `<(cmd)` and `>(cmd)`.
14
+
15
+ `<(cmd)` runs `cmd` and substitutes a readable `/dev/fd/N` path backed by an
16
+ in-memory file; `>(cmd)` substitutes a writable path whose contents are fed to
17
+ `cmd` once the outer command finishes. Descriptors are numbered from 63
18
+ downwards like bash and released when the command that opened them completes.
19
+ Process substitutions retain their surrounding word context in assignments,
20
+ conditionals, regular expressions, and heredoc delimiters. Previously any use
21
+ raised `Parse error: Expected redirection target`.
22
+
23
+ - [#327](https://github.com/vercel-labs/just-bash/pull/327) [`eaedb5b`](https://github.com/vercel-labs/just-bash/commit/eaedb5bc34cffd2077b88bb1ccc48ea7e0545a48) Thanks [@trieloff](https://github.com/trieloff)! - Add `grep -f FILE` / `--file=FILE` to read patterns from a file (one per line). Patterns from `-f` OR-combine with `-e` patterns and with each other, `-f -` reads patterns from stdin, empty pattern lines match every line, and an empty pattern file selects nothing (exit 1). Newline-separated `PATTERNS` operands are now split into individual patterns, and `-x` groups alternatives correctly (`^(?:a|b)$`).
24
+
25
+ ### Patch Changes
26
+
27
+ - [#358](https://github.com/vercel-labs/just-bash/pull/358) [`bd1df37`](https://github.com/vercel-labs/just-bash/commit/bd1df37f8ff836355f470e95dcaa004b769d1e61) Thanks [@privatenumber](https://github.com/privatenumber)! - Parse and serialize bare file descriptor variable redirections such as `{output}>output.log` and `{input}<<EOF`. Bare redirects create their target with a command-scoped descriptor, while named command forms keep the allocated descriptor available.
28
+
29
+ - [#347](https://github.com/vercel-labs/just-bash/pull/347) [`abb904b`](https://github.com/vercel-labs/just-bash/commit/abb904b1e126d14aa437b05f006df83117f06db3) Thanks [@privatenumber](https://github.com/privatenumber)! - Fix escaped reserved words being parsed as shell syntax. Unquoted escapes now retain their provenance through lexing and word parsing, including when the word is serialized back to Bash.
30
+
31
+ - [#332](https://github.com/vercel-labs/just-bash/pull/332) [`4f9bdec`](https://github.com/vercel-labs/just-bash/commit/4f9bdec02edb9eb72511546b759cb7e20bc2e27e) Thanks [@trieloff](https://github.com/trieloff)! - Fix `grep -L` exit status to match GNU grep. The status reports whether a line
32
+ was selected, not whether a filename was printed, so `grep -L` now exits 0 when
33
+ every file matched (printing nothing) and 1 when no file matched (printing every
34
+ name) — previously these were inverted.
35
+
36
+ - [#339](https://github.com/vercel-labs/just-bash/pull/339) [`31d247f`](https://github.com/vercel-labs/just-bash/commit/31d247fe3a62f081b4462064da195552ab0a421c) Thanks [@mutewinter](https://github.com/mutewinter)! - network: restore private-range-enforced requests from the bundled build
37
+
38
+ Every request made with `denyPrivateRanges` enabled failed with `Network access denied: DNS pinning unavailable for private IP enforcement`, so `curl` could not reach any host at all. The published ESM bundle was affected; source consumers and the CommonJS bundle were not.
39
+
40
+ The pinned connection owner reads `Agent` and `fetch` off a dynamic `import("undici")`. Node's resolution of the package exposes those as named exports, but the ESM build inlines undici's CommonJS module into a chunk whose namespace carries it under `default` alone, so `Agent` was `undefined` and the `TypeError` from constructing it was reported as a runtime incapable of pinning.
41
+
42
+ The namespace is now normalized before the transport is read off it, which also covers a consumer that bundles just-bash further.
43
+
44
+ - [#336](https://github.com/vercel-labs/just-bash/pull/336) [`d97425d`](https://github.com/vercel-labs/just-bash/commit/d97425dff8f51cfd773d22bc009561a09235cd1b) Thanks [@trieloff](https://github.com/trieloff)! - Stop command groups, function bodies and `eval` from rewinding stdin they never replaced, so `{ { read a; }; read b; }` gives `b` the second line instead of replaying the first.
45
+
46
+ - [#348](https://github.com/vercel-labs/just-bash/pull/348) [`1a7940d`](https://github.com/vercel-labs/just-bash/commit/1a7940ddf91dec8f69125474a40cef1adebabee9) Thanks [@privatenumber](https://github.com/privatenumber)! - Reject unsupported command-leading reserved words in every parser context instead of discarding them or executing them as simple commands. Unknown command AST nodes now fail explicitly instead of returning a successful result.
47
+
48
+ - [#345](https://github.com/vercel-labs/just-bash/pull/345) [`2208a34`](https://github.com/vercel-labs/just-bash/commit/2208a34e27d33a2fce712fbd024875ec60747553) Thanks [@privatenumber](https://github.com/privatenumber)! - Restore command groups and subshells after the process-substitution and stdin-ownership changes were combined without forwarding ownership through inner command dispatch.
49
+
50
+ - [#336](https://github.com/vercel-labs/just-bash/pull/336) [`d97425d`](https://github.com/vercel-labs/just-bash/commit/d97425dff8f51cfd773d22bc009561a09235cd1b) Thanks [@trieloff](https://github.com/trieloff)! - Apply output redirections attached to `while` and `until` loops. `while true; do echo x; break; done >/dev/null` no longer leaks its output to the caller, and `> file`, `>>`, `2>`, `2>&1`, `&>` and `>|` now behave on loops the way they already did on `for` and `case`. `until` loops also gained the input-redirection handling `while` loops already had, so `until ! read l; do ...; done < file` reads from the file. A loop now only restores stdin it owns, so reading inside a loop no longer rewinds an enclosing group's read position: `printf 'a\nb\n' | { while read x; do break; done; read y; }` sees `y=b`.
51
+
52
+ - [#328](https://github.com/vercel-labs/just-bash/pull/328) [`65dafd5`](https://github.com/vercel-labs/just-bash/commit/65dafd55afbfa7e62642ce485787f7d65fad4961) Thanks [@trieloff](https://github.com/trieloff)! - Stop pipelines from draining the enclosing shell's stdin, so `while read …; do … | …; done < file` runs once per line again.
53
+
54
+ - [#349](https://github.com/vercel-labs/just-bash/pull/349) [`be55fec`](https://github.com/vercel-labs/just-bash/commit/be55fec4e23b3f5a42cf8eaeb6939b379f741ae1) Thanks [@privatenumber](https://github.com/privatenumber)! - Process redirections through policy-driven transactions that preserve Bash ordering, descriptor lifetimes, persistent `exec` routes, compound-command stdin, control-flow output routing, and shared read-write descriptor positions without duplicate expansion or opening.
55
+
56
+ - [#368](https://github.com/vercel-labs/just-bash/pull/368) [`3ee215c`](https://github.com/vercel-labs/just-bash/commit/3ee215c2ad56c96ce0d88e2813050df9f15afa38) Thanks [@cramforce](https://github.com/cramforce)! - FS sym-link hardening
57
+
58
+ - [#338](https://github.com/vercel-labs/just-bash/pull/338) [`19a02c2`](https://github.com/vercel-labs/just-bash/commit/19a02c297d110fde8a8a3376d6956c2c549d128e) Thanks [@mutewinter](https://github.com/mutewinter)! - sqlite3: report failed statements on stderr and exit non-zero without `-bail`
59
+
60
+ A statement that failed was written to **stdout** as `Error: ...` and the command still exited `0` unless `-bail` was passed. Real `sqlite3` writes the error to stderr and exits `1` in either mode; `-bail` only decides whether the remaining statements still run.
61
+
62
+ Two consequences for callers: `sqlite3 db "SELECT ..." > out.csv` silently wrote the error text into the data file, and `sqlite3 db "..." && next-step` ran `next-step` after the query had failed, so a shell script could not detect a bad query without opting into `-bail` and losing the ability to see later statements.
63
+
64
+ Errors now accumulate on stderr in statement order and the exit status is `1` whenever any statement failed. Successful runs are unchanged, `-bail` still stops at the first failure, and the partial stdout produced before a failure is still emitted. Writeback of a partially-successful script is also unchanged.
65
+
66
+ - [#360](https://github.com/vercel-labs/just-bash/pull/360) [`1fbde34`](https://github.com/vercel-labs/just-bash/commit/1fbde341d74ff7f933d9cead9a390a6ab65b5df3) Thanks [@privatenumber](https://github.com/privatenumber)! - Preserve whether a here-document ended at its delimiter or at end-of-input. Unterminated final body lines now receive Bash's trailing newline, backslash-newline continuations are removed during expansion, and serialization rejects unterminated documents rather than manufacturing a closing delimiter.
67
+
3
68
  ## 3.2.0
4
69
 
5
70
  ### Minor Changes
package/README.md CHANGED
@@ -242,6 +242,53 @@ await env.exec('echo "hello" > file.txt'); // writes to real filesystem
242
242
 
243
243
  Keep `ReadWriteFs` pointed at a workspace directory, not at the installed `just-bash` package or any other trusted runtime code. Guest-writable roots should stay separate from trusted code.
244
244
 
245
+ `ReadWriteFs` uses normal in-place filesystem operations for private regular
246
+ files. For multiply-linked regular files, it isolates append and metadata
247
+ changes by copying the file and replacing only the sandbox directory entry, so
248
+ a host-created hard link cannot carry those changes beyond the configured root.
249
+ Implicit copies are limited by `maxCopyOnWriteSize` (100 MB by default; set it
250
+ to `0` to disable the limit). Overwrite does not need to copy existing content.
251
+ Explicit `cp` copies can be limited with the opt-in `maxCopySize` option
252
+ (unlimited by default). The portable copy path may materialize sparse-file
253
+ holes, so embeddings that require a disk-allocation bound should configure
254
+ `maxCopySize`.
255
+
256
+ Shared-inode isolation has a few deliberate limitations:
257
+
258
+ - Append, `chmod`, and `utimes` on a multiply-linked regular file require read
259
+ access to the file and write access to its parent directory. They fail with
260
+ `EFBIG` when the file exceeds `maxCopyOnWriteSize`.
261
+ - Copies use `O_NOATIME` when the Node.js runtime exposes it and retry with
262
+ normal read semantics if the kernel returns `EPERM`. Runtimes and platforms
263
+ without `O_NOATIME` may update access-time metadata visible through another
264
+ hard link.
265
+ - Do not mutate a `ReadWriteFs` root concurrently through direct host filesystem
266
+ APIs. Node.js does not expose the descriptor-relative operations needed to
267
+ make pathname validation atomic against an external actor. A concurrent host
268
+ append to a multiply-linked file may be lost when the isolated entry is
269
+ replaced.
270
+ - Mutations in overlapping `ReadWriteFs` roots are serialized within the
271
+ process. Unrelated roots proceed independently. The queue is not cancellable
272
+ or bounded, so a large mutation can delay later operations in overlapping
273
+ roots even if the requesting script is subsequently aborted.
274
+ - Content writes and appends to FIFOs, sockets, devices, and other special files
275
+ are rejected. This avoids indefinitely occupying an overlapping-root mutation
276
+ slot on a blocking special-file open. Metadata operations remain supported
277
+ for single-link special files; multiply-linked special files are rejected
278
+ because they cannot be isolated without changing their file type.
279
+ - Private-file and single-link special-file metadata operations use pathname
280
+ APIs to preserve normal host permission semantics. They are not atomic
281
+ against a trusted host actor concurrently replacing that pathname with a
282
+ symlink. With `allowSymlinks: false`, symlinks present during normal path
283
+ validation are still rejected.
284
+ - Copying a symlink preserves whether its guest target is absolute or relative.
285
+ Only symlinks whose resolved targets remain inside the root are copied.
286
+ - Regular-file copies replace the destination entry to prevent writes through
287
+ hard links. Existing destinations must still be writable, and their parent
288
+ directory must be writable so the isolated entry can be committed. Thus a
289
+ writable destination in a non-writable directory cannot be copied over.
290
+ Copying over a FIFO, socket, device, or other special entry is rejected.
291
+
245
292
  **MountableFs** - Mount multiple filesystems at different paths. Combines read-only and read-write filesystems into a unified namespace:
246
293
 
247
294
  ```typescript
@@ -213,6 +213,8 @@ export interface HereDocNode extends ASTNode {
213
213
  stripTabs: boolean;
214
214
  /** Quoted delimiter means no expansion */
215
215
  quoted: boolean;
216
+ /** Whether parsing consumed the closing delimiter. Undefined for legacy ASTs. */
217
+ terminated?: boolean;
216
218
  }
217
219
  /**
218
220
  * A Word is a sequence of parts that form a single shell word.
@@ -592,9 +594,10 @@ export declare const AST: {
592
594
  parameterExpansion(parameter: string, operation?: ParameterOperation | null): ParameterExpansionPart;
593
595
  commandSubstitution(body: ScriptNode, legacy?: boolean): CommandSubstitutionPart;
594
596
  arithmeticExpansion(expression: ArithmeticExpressionNode): ArithmeticExpansionPart;
597
+ processSubstitution(body: ScriptNode, direction: "input" | "output"): ProcessSubstitutionPart;
595
598
  assignment(name: string, value: WordNode | null, append?: boolean, array?: WordNode[] | null): AssignmentNode;
596
599
  redirection(operator: RedirectionOperator, target: WordNode | HereDocNode, fd?: number | null, fdVariable?: string): RedirectionNode;
597
- hereDoc(delimiter: string, content: WordNode, stripTabs?: boolean, quoted?: boolean): HereDocNode;
600
+ hereDoc(delimiter: string, content: WordNode, stripTabs?: boolean, quoted?: boolean, terminated?: boolean): HereDocNode;
598
601
  ifNode(clauses: IfClause[], elseBody?: StatementNode[] | null, redirections?: RedirectionNode[]): IfNode;
599
602
  forNode(variable: string, words: WordNode[] | null, body: StatementNode[], redirections?: RedirectionNode[]): ForNode;
600
603
  whileNode(condition: StatementNode[], body: StatementNode[], redirections?: RedirectionNode[]): WhileNode;
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as P}from"./chunk-K5KT6DMM.js";import{a as E,b as _,d as N}from"./chunk-VLWZ6L7C.js";import{l as C}from"./chunk-LCP3IKI7.js";import{a as k}from"./chunk-CPKBPQ2C.js";import{a as Z}from"./chunk-I4IRHQDW.js";import{a as W,b as T}from"./chunk-MUFNRCMY.js";import{b as G,c as D}from"./chunk-DN2YCFOR.js";var V=G(A=>{(function(){"use strict";var e={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function l(t){return r(s(t),arguments)}function n(t,o){return l.apply(null,[t].concat(o||[]))}function r(t,o){var c=1,p=t.length,i,h="",u,d,f,m,x,v,g,w;for(u=0;u<p;u++)if(typeof t[u]=="string")h+=t[u];else if(typeof t[u]=="object"){if(f=t[u],f.keys)for(i=o[c],d=0;d<f.keys.length;d++){if(i==null)throw new Error(l('[sprintf] Cannot access property "%s" of undefined value "%s"',f.keys[d],f.keys[d-1]));i=i[f.keys[d]]}else f.param_no?i=o[f.param_no]:i=o[c++];if(e.not_type.test(f.type)&&e.not_primitive.test(f.type)&&i instanceof Function&&(i=i()),e.numeric_arg.test(f.type)&&typeof i!="number"&&isNaN(i))throw new TypeError(l("[sprintf] expecting number but found %T",i));switch(e.number.test(f.type)&&(g=i>=0),f.type){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,f.width?parseInt(f.width):0);break;case"e":i=f.precision?parseFloat(i).toExponential(f.precision):parseFloat(i).toExponential();break;case"f":i=f.precision?parseFloat(i).toFixed(f.precision):parseFloat(i);break;case"g":i=f.precision?String(Number(i.toPrecision(f.precision))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=f.precision?i.substring(0,f.precision):i;break;case"t":i=String(!!i),i=f.precision?i.substring(0,f.precision):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=f.precision?i.substring(0,f.precision):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=f.precision?i.substring(0,f.precision):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase();break}e.json.test(f.type)?h+=i:(e.number.test(f.type)&&(!g||f.sign)?(w=g?"+":"-",i=i.toString().replace(e.sign,"")):w="",x=f.pad_char?f.pad_char==="0"?"0":f.pad_char.charAt(1):" ",v=f.width-(w+i).length,m=f.width&&v>0?x.repeat(v):"",h+=f.align?w+i+m:x==="0"?w+m+i:m+w+i)}return h}var a=Object.create(null);function s(t){if(a[t])return a[t];for(var o=t,c,p=[],i=0;o;){if((c=e.text.exec(o))!==null)p.push(c[0]);else if((c=e.modulo.exec(o))!==null)p.push("%");else if((c=e.placeholder.exec(o))!==null){if(c[2]){i|=1;var h=[],u=c[2],d=[];if((d=e.key.exec(u))!==null)for(h.push(d[1]);(u=u.substring(d[0].length))!=="";)if((d=e.key_access.exec(u))!==null)h.push(d[1]);else if((d=e.index_access.exec(u))!==null)h.push(d[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");c[2]=h}else i|=2;if(i===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");p.push({placeholder:c[0],param_no:c[1],keys:c[2],sign:c[3],pad_char:c[4],align:c[5],width:c[6],precision:c[7],type:c[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");o=o.substring(c[0].length)}return a[t]=p}typeof A<"u"&&(A.sprintf=l,A.vsprintf=n),typeof window<"u"&&(window.sprintf=l,window.vsprintf=n,typeof define=="function"&&define.amd&&define(function(){return{sprintf:l,vsprintf:n}}))})()});var $=D(V(),1);function J(e){let l="",n=0;for(;n<e.length;){let r=e[n];if(r<128){l+=String.fromCharCode(r),n++;continue}if((r&224)===192){if(n+1<e.length&&(e[n+1]&192)===128&&r>=194){let a=(r&31)<<6|e[n+1]&63;l+=String.fromCharCode(a),n+=2;continue}l+=String.fromCharCode(r),n++;continue}if((r&240)===224){if(n+2<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128){if(r===224&&e[n+1]<160){l+=String.fromCharCode(r),n++;continue}let a=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(a>=55296&&a<=57343){l+=String.fromCharCode(r),n++;continue}l+=String.fromCharCode(a),n+=3;continue}l+=String.fromCharCode(r),n++;continue}if((r&248)===240&&r<=244){if(n+3<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128&&(e[n+3]&192)===128){if(r===240&&e[n+1]<144){l+=String.fromCharCode(r),n++;continue}let a=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(a>1114111){l+=String.fromCharCode(r),n++;continue}l+=String.fromCodePoint(a),n+=4;continue}l+=String.fromCharCode(r),n++;continue}l+=String.fromCharCode(r),n++}return l}var Q={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},de={name:"printf",async execute(e,l){if(T(e))return W(Q);if(e.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
4
- `,exitCode:2};let n=null,r=0;for(;r<e.length;){let t=e[r];if(t==="--"){r++;break}if(t==="-v"){if(r+1>=e.length)return{stdout:"",stderr:`printf: -v: option requires an argument
5
- `,exitCode:1};if(n=e[r+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\[[^\]\n]+\])?$/.test(n)||/[;\r\\]/.test(n)||n.includes(".."))return{stdout:"",stderr:`printf: \`${n}': not a valid identifier
6
- `,exitCode:2};r+=2}else{if(t.startsWith("-")&&t!=="-")break;break}}if(r>=e.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
7
- `,exitCode:1};let a=e[r],s=e.slice(r+1);try{let t=Math.min(l.limits.maxStringLength,l.limits.maxOutputSize),o=N(a,t),c="",p=0,i=0,h=!1,u="",d=l.env.get("TZ");do{let{result:f,argsConsumed:m,error:x,errMsg:v,stopped:g}=K(o,s,i,d,t-p),w=k(f);if(w>t-p)throw new C(`printf: output size limit exceeded (${t} bytes)`,"string_length");if(c+=f,p+=w,i+=m,x&&(h=!0,v&&(u=v)),g)break}while(i<s.length&&i>0);if(i===0&&s.length>0,n){let f=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(f){let m=f[1],x=f[3];if(x=x.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(v,g)=>l.env.get(g)??""),l.assignShellVariable)await l.assignShellVariable(m,c,x);else throw new Error("printf -v array assignment requires an interpreter assignment gateway")}else if(l.assignShellVariable)await l.assignShellVariable(n,c);else{if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))throw new Error(`${n}: not a valid identifier`);l.env.set(n,c)}return{stdout:"",stderr:u,exitCode:h?1:0}}return{stdout:c,stderr:u,exitCode:h?1:0}}catch(t){if(t instanceof C||typeof t=="object"&&t!==null&&"name"in t&&t.name==="ExitError")throw t;return{stdout:"",stderr:`printf: ${Z(t)}
8
- `,exitCode:1}}}};function K(e,l,n,r,a=10*1024*1024){let s="",t=0,o=0,c=!1,p="",i=0,h=u=>{let d=k(u);if(d>a-i)throw new C(`printf: output size limit exceeded (${a} bytes)`,"string_length");s+=u,i+=d};for(;t<e.length;)if(e[t]==="%"&&t+1<e.length){let u=t;if(t++,e[t]==="%"){h("%"),t++;continue}let d=e.slice(u).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(d){let b=d[1]?parseInt(d[1],10):0,M=d[2]?parseInt(d[2],10):-1;E(b,a,"width"),M!==-1&&E(M,a,"precision");let R=d[3],H=d[0],I=l[n+o]||"";o++;let y;I===""||I==="-1"||I==="-2"?y=Math.floor(Date.now()/1e3):y=parseInt(I,10)||0;let z=P(R,y,r,{maxOperations:a-i,maxOutputBytes:a-i});z=_(z,b,M,a-i),h(z),t=u+H.length;continue}for(;t<e.length&&"+-0 #'".includes(e[t]);)t++;let f=!1;if(e[t]==="*")f=!0,t++;else for(;t<e.length&&/\d/.test(e[t]);)t++;let m=!1;if(e[t]===".")if(t++,e[t]==="*")m=!0,t++;else for(;t<e.length&&/\d/.test(e[t]);)t++;t<e.length&&"hlL".includes(e[t])&&t++;let x=e[t]||"";t++;let g=e.slice(u,t);if(f){let b=parseInt(l[n+o]||"0",10);E(b,a-i,"width"),o++,g=g.replace("*",String(b))}if(m){let b=parseInt(l[n+o]||"0",10);b>=0?E(b,a-i,"precision"):Number.isSafeInteger(b)||E(b,a-i,"precision"),o++,g=g.replace(".*",`.${b}`)}O(g,a-i);let w=l[n+o]||"";o++;let{value:U,parseError:q,parseErrMsg:j,stopped:L}=Y(g,x,w,a-i);if(h(U),q&&(c=!0,j&&(p=j)),L)return{result:s,argsConsumed:o,error:c,errMsg:p,stopped:!0}}else h(e[t]),t++;return{result:s,argsConsumed:o,error:c,errMsg:p,stopped:!1}}function Y(e,l,n,r){let a=!1,s="";switch(l){case"d":case"i":{let t=F(n);return a=S,a&&(s=`printf: ${n}: invalid number
3
+ import{a as P}from"./chunk-K5KT6DMM.js";import{a as E,b as _,d as N}from"./chunk-VLWZ6L7C.js";import{l as v}from"./chunk-LCP3IKI7.js";import{a as k}from"./chunk-CPKBPQ2C.js";import{a as Z}from"./chunk-I4IRHQDW.js";import{a as W,b as T}from"./chunk-MUFNRCMY.js";import{b as G,c as D}from"./chunk-DN2YCFOR.js";var V=G(A=>{(function(){"use strict";var e={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function l(t){return r(s(t),arguments)}function n(t,o){return l.apply(null,[t].concat(o||[]))}function r(t,o){var c=1,d=t.length,i,h="",u,p,f,m,x,C,g,w;for(u=0;u<d;u++)if(typeof t[u]=="string")h+=t[u];else if(typeof t[u]=="object"){if(f=t[u],f.keys)for(i=o[c],p=0;p<f.keys.length;p++){if(i==null)throw new Error(l('[sprintf] Cannot access property "%s" of undefined value "%s"',f.keys[p],f.keys[p-1]));i=i[f.keys[p]]}else f.param_no?i=o[f.param_no]:i=o[c++];if(e.not_type.test(f.type)&&e.not_primitive.test(f.type)&&i instanceof Function&&(i=i()),e.numeric_arg.test(f.type)&&typeof i!="number"&&isNaN(i))throw new TypeError(l("[sprintf] expecting number but found %T",i));switch(e.number.test(f.type)&&(g=i>=0),f.type){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,f.width?parseInt(f.width):0);break;case"e":i=f.precision?parseFloat(i).toExponential(f.precision):parseFloat(i).toExponential();break;case"f":i=f.precision?parseFloat(i).toFixed(f.precision):parseFloat(i);break;case"g":i=f.precision?String(Number(i.toPrecision(f.precision))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=f.precision?i.substring(0,f.precision):i;break;case"t":i=String(!!i),i=f.precision?i.substring(0,f.precision):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=f.precision?i.substring(0,f.precision):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=f.precision?i.substring(0,f.precision):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase();break}e.json.test(f.type)?h+=i:(e.number.test(f.type)&&(!g||f.sign)?(w=g?"+":"-",i=i.toString().replace(e.sign,"")):w="",x=f.pad_char?f.pad_char==="0"?"0":f.pad_char.charAt(1):" ",C=f.width-(w+i).length,m=f.width&&C>0?x.repeat(C):"",h+=f.align?w+i+m:x==="0"?w+m+i:m+w+i)}return h}var a=Object.create(null);function s(t){if(a[t])return a[t];for(var o=t,c,d=[],i=0;o;){if((c=e.text.exec(o))!==null)d.push(c[0]);else if((c=e.modulo.exec(o))!==null)d.push("%");else if((c=e.placeholder.exec(o))!==null){if(c[2]){i|=1;var h=[],u=c[2],p=[];if((p=e.key.exec(u))!==null)for(h.push(p[1]);(u=u.substring(p[0].length))!=="";)if((p=e.key_access.exec(u))!==null)h.push(p[1]);else if((p=e.index_access.exec(u))!==null)h.push(p[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");c[2]=h}else i|=2;if(i===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d.push({placeholder:c[0],param_no:c[1],keys:c[2],sign:c[3],pad_char:c[4],align:c[5],width:c[6],precision:c[7],type:c[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");o=o.substring(c[0].length)}return a[t]=d}typeof A<"u"&&(A.sprintf=l,A.vsprintf=n),typeof window<"u"&&(window.sprintf=l,window.vsprintf=n,typeof define=="function"&&define.amd&&define(function(){return{sprintf:l,vsprintf:n}}))})()});var $=D(V(),1);function J(e){let l="",n=0;for(;n<e.length;){let r=e[n];if(r<128){l+=String.fromCharCode(r),n++;continue}if((r&224)===192){if(n+1<e.length&&(e[n+1]&192)===128&&r>=194){let a=(r&31)<<6|e[n+1]&63;l+=String.fromCharCode(a),n+=2;continue}l+=String.fromCharCode(r),n++;continue}if((r&240)===224){if(n+2<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128){if(r===224&&e[n+1]<160){l+=String.fromCharCode(r),n++;continue}let a=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(a>=55296&&a<=57343){l+=String.fromCharCode(r),n++;continue}l+=String.fromCharCode(a),n+=3;continue}l+=String.fromCharCode(r),n++;continue}if((r&248)===240&&r<=244){if(n+3<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128&&(e[n+3]&192)===128){if(r===240&&e[n+1]<144){l+=String.fromCharCode(r),n++;continue}let a=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(a>1114111){l+=String.fromCharCode(r),n++;continue}l+=String.fromCodePoint(a),n+=4;continue}l+=String.fromCharCode(r),n++;continue}l+=String.fromCharCode(r),n++}return l}var Q={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},pe={name:"printf",async execute(e,l){if(T(e))return W(Q);if(e.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
4
+ `,exitCode:2,internalStdinConsumed:0};let n=null,r=0;for(;r<e.length;){let t=e[r];if(t==="--"){r++;break}if(t==="-v"){if(r+1>=e.length)return{stdout:"",stderr:`printf: -v: option requires an argument
5
+ `,exitCode:1,internalStdinConsumed:0};if(n=e[r+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\[[^\]\n]+\])?$/.test(n)||/[;\r\\]/.test(n)||n.includes(".."))return{stdout:"",stderr:`printf: \`${n}': not a valid identifier
6
+ `,exitCode:2,internalStdinConsumed:0};r+=2}else{if(t.startsWith("-")&&t!=="-")break;break}}if(r>=e.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
7
+ `,exitCode:1,internalStdinConsumed:0};let a=e[r],s=e.slice(r+1);try{let t=Math.min(l.limits.maxStringLength,l.limits.maxOutputSize),o=N(a,t),c="",d=0,i=0,h=!1,u="",p=l.env.get("TZ");do{let{result:f,argsConsumed:m,error:x,errMsg:C,stopped:g}=K(o,s,i,p,t-d),w=k(f);if(w>t-d)throw new v(`printf: output size limit exceeded (${t} bytes)`,"string_length");if(c+=f,d+=w,i+=m,x&&(h=!0,C&&(u=C)),g)break}while(i<s.length&&i>0);if(i===0&&s.length>0,n){let f=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(f){let m=f[1],x=f[3];if(x=x.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(C,g)=>l.env.get(g)??""),l.assignShellVariable)await l.assignShellVariable(m,c,x);else throw new Error("printf -v array assignment requires an interpreter assignment gateway")}else if(l.assignShellVariable)await l.assignShellVariable(n,c);else{if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))throw new Error(`${n}: not a valid identifier`);l.env.set(n,c)}return{stdout:"",stderr:u,exitCode:h?1:0,internalStdinConsumed:0}}return{stdout:c,stderr:u,exitCode:h?1:0,internalStdinConsumed:0}}catch(t){if(t instanceof v||typeof t=="object"&&t!==null&&"name"in t&&t.name==="ExitError")throw t;return{stdout:"",stderr:`printf: ${Z(t)}
8
+ `,exitCode:1,internalStdinConsumed:0}}}};function K(e,l,n,r,a=10*1024*1024){let s="",t=0,o=0,c=!1,d="",i=0,h=u=>{let p=k(u);if(p>a-i)throw new v(`printf: output size limit exceeded (${a} bytes)`,"string_length");s+=u,i+=p};for(;t<e.length;)if(e[t]==="%"&&t+1<e.length){let u=t;if(t++,e[t]==="%"){h("%"),t++;continue}let p=e.slice(u).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(p){let b=p[1]?parseInt(p[1],10):0,M=p[2]?parseInt(p[2],10):-1;E(b,a,"width"),M!==-1&&E(M,a,"precision");let R=p[3],H=p[0],I=l[n+o]||"";o++;let y;I===""||I==="-1"||I==="-2"?y=Math.floor(Date.now()/1e3):y=parseInt(I,10)||0;let z=P(R,y,r,{maxOperations:a-i,maxOutputBytes:a-i});z=_(z,b,M,a-i),h(z),t=u+H.length;continue}for(;t<e.length&&"+-0 #'".includes(e[t]);)t++;let f=!1;if(e[t]==="*")f=!0,t++;else for(;t<e.length&&/\d/.test(e[t]);)t++;let m=!1;if(e[t]===".")if(t++,e[t]==="*")m=!0,t++;else for(;t<e.length&&/\d/.test(e[t]);)t++;t<e.length&&"hlL".includes(e[t])&&t++;let x=e[t]||"";t++;let g=e.slice(u,t);if(f){let b=parseInt(l[n+o]||"0",10);E(b,a-i,"width"),o++,g=g.replace("*",String(b))}if(m){let b=parseInt(l[n+o]||"0",10);b>=0?E(b,a-i,"precision"):Number.isSafeInteger(b)||E(b,a-i,"precision"),o++,g=g.replace(".*",`.${b}`)}O(g,a-i);let w=l[n+o]||"";o++;let{value:U,parseError:q,parseErrMsg:j,stopped:L}=Y(g,x,w,a-i);if(h(U),q&&(c=!0,j&&(d=j)),L)return{result:s,argsConsumed:o,error:c,errMsg:d,stopped:!0}}else h(e[t]),t++;return{result:s,argsConsumed:o,error:c,errMsg:d,stopped:!1}}function Y(e,l,n,r){let a=!1,s="";switch(l){case"d":case"i":{let t=F(n);return a=S,a&&(s=`printf: ${n}: invalid number
9
9
  `),{value:X(e,t),parseError:a,parseErrMsg:s}}case"o":{let t=F(n);return a=S,a&&(s=`printf: ${n}: invalid number
10
10
  `),{value:B(e,t),parseError:a,parseErrMsg:s}}case"u":{let t=F(n);a=S,a&&(s=`printf: ${n}: invalid number
11
11
  `);let o=t<0?t>>>0:t;return{value:X(e.replace("u","d"),o),parseError:a,parseErrMsg:s}}case"x":case"X":{let t=F(n);return a=S,a&&(s=`printf: ${n}: invalid number
12
12
  `),{value:ee(e,t),parseError:a,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":{let t=parseFloat(n)||0;return{value:ie(e,l,t),parseError:!1,parseErrMsg:""}}case"c":{if(n==="")return{value:"",parseError:!1,parseErrMsg:""};let c=new TextEncoder().encode(n)[0];return{value:String.fromCharCode(c),parseError:!1,parseErrMsg:""}}case"s":return{value:ne(e,n,r),parseError:!1,parseErrMsg:""};case"q":return{value:re(e,n,r),parseError:!1,parseErrMsg:""};case"b":{let t=se(n,r);return{value:t.value,parseError:!1,parseErrMsg:"",stopped:t.stopped}}default:try{return{value:(0,$.sprintf)(e,n),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
13
- `}}}}function O(e,l){let n=e.match(/^%[-+0 #' ]*(\d*)(?:\.(\d*))?/);if(!n)return;let r=n[1]?Number(n[1]):0,a=n[2]!==void 0?Number(n[2]):-1;E(r,l,"width"),a!==-1&&E(a,l,"precision")}var S=!1;function F(e){S=!1;let l=e.trimStart(),n=l!==l.trimEnd();if(e=l.trimEnd(),e.startsWith("'")&&e.length>=2||e.startsWith('"')&&e.length>=2)return e.charCodeAt(1);if(e.startsWith("\\'")&&e.length>=3||e.startsWith('\\"')&&e.length>=3)return e.charCodeAt(2);if(e.startsWith("+")&&(e=e.slice(1)),e.startsWith("0x")||e.startsWith("0X")){let r=parseInt(e,16);return Number.isNaN(r)?(S=!0,0):(n&&(S=!0),r)}if(e.startsWith("0")&&e.length>1&&/^-?0[0-7]+$/.test(e))return n&&(S=!0),parseInt(e,8)||0;if(/^\d+#/.test(e)){S=!0;let r=e.match(/^(\d+)#/);return r?parseInt(r[1],10):0}if(e!==""&&!/^-?\d+$/.test(e)){S=!0;let r=parseInt(e,10);return Number.isNaN(r)?0:r}return n&&(S=!0),parseInt(e,10)||0}function X(e,l){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!n)return(0,$.sprintf)(e.replace(/\.\d*/,""),l);let r=n[1]||"",a=n[2]?parseInt(n[2],10):0,s=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,t=l<0,o=Math.abs(l),c=String(o);s>=0&&(c=c.padStart(s,"0"));let p="";t?p="-":r.includes("+")?p="+":r.includes(" ")&&(p=" ");let i=p+c;return a>i.length&&(r.includes("-")?i=i.padEnd(a," "):r.includes("0")&&s<0?i=p+c.padStart(a-p.length,"0"):i=i.padStart(a," ")),i}function B(e,l){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!n)return(0,$.sprintf)(e,l);let r=n[1]||"",a=n[2]?parseInt(n[2],10):0,s=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,t=Math.abs(l).toString(8);s>=0&&(t=t.padStart(s,"0")),r.includes("#")&&!t.startsWith("0")&&(t=`0${t}`);let o=t;return a>o.length&&(r.includes("-")?o=o.padEnd(a," "):r.includes("0")&&s<0?o=o.padStart(a,"0"):o=o.padStart(a," ")),o}function ee(e,l){let n=e.includes("X"),r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!r)return(0,$.sprintf)(e,l);let a=r[1]||"",s=r[2]?parseInt(r[2],10):0,t=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=Math.abs(l).toString(16);n&&(o=o.toUpperCase()),t>=0&&(o=o.padStart(t,"0"));let c="";a.includes("#")&&l!==0&&(c=n?"0X":"0x");let p=c+o;return s>p.length&&(a.includes("-")?p=p.padEnd(s," "):a.includes("0")&&t<0?p=c+o.padStart(s-c.length,"0"):p=p.padStart(s," ")),p}function te(e,l){if(e===""){if(l<2)throw new C(`printf: output size limit exceeded (${l} bytes)`,"string_length");return"''"}if(/^[a-zA-Z0-9_./-]+$/.test(e)){if(k(e)>l)throw new C(`printf: output size limit exceeded (${l} bytes)`,"string_length");return e}let n=/[\x00-\x1f\x7f-\xff]/.test(e),r=n?3:0;for(let s of e){let t=s.charCodeAt(0);if(n?s==="'"||s==="\\"||s===`
14
- `||s===" "||s==="\r"||s==="\x07"||s==="\b"||s==="\f"||s==="\v"||s==="\x1B"||s==='"'?r+=2:t<32||t>=127&&t<=255?r+=4:r+=k(s):r+=k(s)+(" |&;<>()$`\\\"'*?[#~=%!{}".includes(s)?1:0),r>l)throw new C(`printf: output size limit exceeded (${l} bytes)`,"string_length")}if(n){let s="$'";for(let t of e){let o=t.charCodeAt(0);t==="'"?s+="\\'":t==="\\"?s+="\\\\":t===`
15
- `?s+="\\n":t===" "?s+="\\t":t==="\r"?s+="\\r":t==="\x07"?s+="\\a":t==="\b"?s+="\\b":t==="\f"?s+="\\f":t==="\v"?s+="\\v":t==="\x1B"?s+="\\E":o<32||o>=127&&o<=255?s+=`\\${o.toString(8).padStart(3,"0")}`:t==='"'?s+='\\"':s+=t}return s+="'",s}let a="";for(let s of e)" |&;<>()$`\\\"'*?[#~=%!{}".includes(s)?a+=`\\${s}`:a+=s;return a}function ne(e,l,n){let r=e.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!r)return(0,$.sprintf)(e.replace(/0+(?=\d)/,""),l);let a=r[1]==="-",s=r[2]?parseInt(r[2],10):0,t=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=a?-s:s;return _(l,o,t,n)}function re(e,l,n){let r=te(l,n),a=e.match(/^%(-?)(\d*)q$/);if(!a)return r;let s=a[1]==="-",t=a[2]?parseInt(a[2],10):0;return _(r,s?-t:t,-1,n)}function ie(e,l,n){let r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!r)return(0,$.sprintf)(e,n);let a=r[1]||"",s=r[2]?parseInt(r[2],10):0,t=r[3]!==void 0?r[4]?parseInt(r[4],10):0:6,o,c=l.toLowerCase();if(c==="e"?(o=n.toExponential(t),o=o.replace(/e([+-])(\d)$/,"e$10$2"),l==="E"&&(o=o.toUpperCase())):c==="f"?(o=n.toFixed(t),a.includes("#")&&t===0&&!o.includes(".")&&(o+=".")):c==="g"?(o=n.toPrecision(t||1),a.includes("#")||(o=o.replace(/\.?0+$/,""),o=o.replace(/\.?0+e/,"e")),o=o.replace(/e([+-])(\d)$/,"e$10$2"),l==="G"&&(o=o.toUpperCase())):o=n.toString(),n>=0&&(a.includes("+")?o=`+${o}`:a.includes(" ")&&(o=` ${o}`)),s>o.length)if(a.includes("-"))o=o.padEnd(s," ");else if(a.includes("0")){let p=o.match(/^[+ -]/)?.[0]||"",i=p?o.slice(1):o;o=p+i.padStart(s-p.length,"0")}else o=o.padStart(s," ");return o}function se(e,l){if(k(e)>l)throw new C(`printf: output size limit exceeded (${l} bytes)`,"string_length");let n="",r=0;for(;r<e.length;)if(e[r]==="\\"&&r+1<e.length)switch(e[r+1]){case"n":n+=`
16
- `,r+=2;break;case"t":n+=" ",r+=2;break;case"r":n+="\r",r+=2;break;case"\\":n+="\\",r+=2;break;case"a":n+="\x07",r+=2;break;case"b":n+="\b",r+=2;break;case"f":n+="\f",r+=2;break;case"v":n+="\v",r+=2;break;case"c":return{value:n,stopped:!0};case"x":{let s=[],t=r;for(;t+1<e.length&&e[t]==="\\"&&e[t+1]==="x";){let o="",c=t+2;for(;c<e.length&&c<t+4&&/[0-9a-fA-F]/.test(e[c]);)o+=e[c],c++;if(o)s.push(parseInt(o,16)),t=c;else break}s.length>0?(n+=J(s),r=t):(n+="\\x",r+=2);break}case"u":{let s="",t=r+2;for(;t<e.length&&t<r+6&&/[0-9a-fA-F]/.test(e[t]);)s+=e[t],t++;s?(n+=String.fromCodePoint(parseInt(s,16)),r=t):(n+="\\u",r+=2);break}case"0":{let s="",t=r+2;for(;t<e.length&&t<r+5&&/[0-7]/.test(e[t]);)s+=e[t],t++;s?n+=String.fromCharCode(parseInt(s,8)):n+="\0",r=t;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",t=r+1;for(;t<e.length&&t<r+4&&/[0-7]/.test(e[t]);)s+=e[t],t++;n+=String.fromCharCode(parseInt(s,8)),r=t;break}default:n+=e[r],r++}else n+=e[r],r++;return{value:n,stopped:!1}}var ue={name:"printf",flags:[{flag:"-v",type:"value",valueHint:"string"}],stdinType:"none",needsArgs:!0};export{de as a,ue as b};
13
+ `}}}}function O(e,l){let n=e.match(/^%[-+0 #' ]*(\d*)(?:\.(\d*))?/);if(!n)return;let r=n[1]?Number(n[1]):0,a=n[2]!==void 0?Number(n[2]):-1;E(r,l,"width"),a!==-1&&E(a,l,"precision")}var S=!1;function F(e){S=!1;let l=e.trimStart(),n=l!==l.trimEnd();if(e=l.trimEnd(),e.startsWith("'")&&e.length>=2||e.startsWith('"')&&e.length>=2)return e.charCodeAt(1);if(e.startsWith("\\'")&&e.length>=3||e.startsWith('\\"')&&e.length>=3)return e.charCodeAt(2);if(e.startsWith("+")&&(e=e.slice(1)),e.startsWith("0x")||e.startsWith("0X")){let r=parseInt(e,16);return Number.isNaN(r)?(S=!0,0):(n&&(S=!0),r)}if(e.startsWith("0")&&e.length>1&&/^-?0[0-7]+$/.test(e))return n&&(S=!0),parseInt(e,8)||0;if(/^\d+#/.test(e)){S=!0;let r=e.match(/^(\d+)#/);return r?parseInt(r[1],10):0}if(e!==""&&!/^-?\d+$/.test(e)){S=!0;let r=parseInt(e,10);return Number.isNaN(r)?0:r}return n&&(S=!0),parseInt(e,10)||0}function X(e,l){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!n)return(0,$.sprintf)(e.replace(/\.\d*/,""),l);let r=n[1]||"",a=n[2]?parseInt(n[2],10):0,s=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,t=l<0,o=Math.abs(l),c=String(o);s>=0&&(c=c.padStart(s,"0"));let d="";t?d="-":r.includes("+")?d="+":r.includes(" ")&&(d=" ");let i=d+c;return a>i.length&&(r.includes("-")?i=i.padEnd(a," "):r.includes("0")&&s<0?i=d+c.padStart(a-d.length,"0"):i=i.padStart(a," ")),i}function B(e,l){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!n)return(0,$.sprintf)(e,l);let r=n[1]||"",a=n[2]?parseInt(n[2],10):0,s=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,t=Math.abs(l).toString(8);s>=0&&(t=t.padStart(s,"0")),r.includes("#")&&!t.startsWith("0")&&(t=`0${t}`);let o=t;return a>o.length&&(r.includes("-")?o=o.padEnd(a," "):r.includes("0")&&s<0?o=o.padStart(a,"0"):o=o.padStart(a," ")),o}function ee(e,l){let n=e.includes("X"),r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!r)return(0,$.sprintf)(e,l);let a=r[1]||"",s=r[2]?parseInt(r[2],10):0,t=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=Math.abs(l).toString(16);n&&(o=o.toUpperCase()),t>=0&&(o=o.padStart(t,"0"));let c="";a.includes("#")&&l!==0&&(c=n?"0X":"0x");let d=c+o;return s>d.length&&(a.includes("-")?d=d.padEnd(s," "):a.includes("0")&&t<0?d=c+o.padStart(s-c.length,"0"):d=d.padStart(s," ")),d}function te(e,l){if(e===""){if(l<2)throw new v(`printf: output size limit exceeded (${l} bytes)`,"string_length");return"''"}if(/^[a-zA-Z0-9_./-]+$/.test(e)){if(k(e)>l)throw new v(`printf: output size limit exceeded (${l} bytes)`,"string_length");return e}let n=/[\x00-\x1f\x7f-\xff]/.test(e),r=n?3:0;for(let s of e){let t=s.charCodeAt(0);if(n?s==="'"||s==="\\"||s===`
14
+ `||s===" "||s==="\r"||s==="\x07"||s==="\b"||s==="\f"||s==="\v"||s==="\x1B"||s==='"'?r+=2:t<32||t>=127&&t<=255?r+=4:r+=k(s):r+=k(s)+(" |&;<>()$`\\\"'*?[#~=%!{}".includes(s)?1:0),r>l)throw new v(`printf: output size limit exceeded (${l} bytes)`,"string_length")}if(n){let s="$'";for(let t of e){let o=t.charCodeAt(0);t==="'"?s+="\\'":t==="\\"?s+="\\\\":t===`
15
+ `?s+="\\n":t===" "?s+="\\t":t==="\r"?s+="\\r":t==="\x07"?s+="\\a":t==="\b"?s+="\\b":t==="\f"?s+="\\f":t==="\v"?s+="\\v":t==="\x1B"?s+="\\E":o<32||o>=127&&o<=255?s+=`\\${o.toString(8).padStart(3,"0")}`:t==='"'?s+='\\"':s+=t}return s+="'",s}let a="";for(let s of e)" |&;<>()$`\\\"'*?[#~=%!{}".includes(s)?a+=`\\${s}`:a+=s;return a}function ne(e,l,n){let r=e.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!r)return(0,$.sprintf)(e.replace(/0+(?=\d)/,""),l);let a=r[1]==="-",s=r[2]?parseInt(r[2],10):0,t=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=a?-s:s;return _(l,o,t,n)}function re(e,l,n){let r=te(l,n),a=e.match(/^%(-?)(\d*)q$/);if(!a)return r;let s=a[1]==="-",t=a[2]?parseInt(a[2],10):0;return _(r,s?-t:t,-1,n)}function ie(e,l,n){let r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!r)return(0,$.sprintf)(e,n);let a=r[1]||"",s=r[2]?parseInt(r[2],10):0,t=r[3]!==void 0?r[4]?parseInt(r[4],10):0:6,o,c=l.toLowerCase();if(c==="e"?(o=n.toExponential(t),o=o.replace(/e([+-])(\d)$/,"e$10$2"),l==="E"&&(o=o.toUpperCase())):c==="f"?(o=n.toFixed(t),a.includes("#")&&t===0&&!o.includes(".")&&(o+=".")):c==="g"?(o=n.toPrecision(t||1),a.includes("#")||(o=o.replace(/\.?0+$/,""),o=o.replace(/\.?0+e/,"e")),o=o.replace(/e([+-])(\d)$/,"e$10$2"),l==="G"&&(o=o.toUpperCase())):o=n.toString(),n>=0&&(a.includes("+")?o=`+${o}`:a.includes(" ")&&(o=` ${o}`)),s>o.length)if(a.includes("-"))o=o.padEnd(s," ");else if(a.includes("0")){let d=o.match(/^[+ -]/)?.[0]||"",i=d?o.slice(1):o;o=d+i.padStart(s-d.length,"0")}else o=o.padStart(s," ");return o}function se(e,l){if(k(e)>l)throw new v(`printf: output size limit exceeded (${l} bytes)`,"string_length");let n="",r=0;for(;r<e.length;)if(e[r]==="\\"&&r+1<e.length)switch(e[r+1]){case"n":n+=`
16
+ `,r+=2;break;case"t":n+=" ",r+=2;break;case"r":n+="\r",r+=2;break;case"\\":n+="\\",r+=2;break;case"a":n+="\x07",r+=2;break;case"b":n+="\b",r+=2;break;case"f":n+="\f",r+=2;break;case"v":n+="\v",r+=2;break;case"c":return{value:n,stopped:!0};case"x":{let s=[],t=r;for(;t+1<e.length&&e[t]==="\\"&&e[t+1]==="x";){let o="",c=t+2;for(;c<e.length&&c<t+4&&/[0-9a-fA-F]/.test(e[c]);)o+=e[c],c++;if(o)s.push(parseInt(o,16)),t=c;else break}s.length>0?(n+=J(s),r=t):(n+="\\x",r+=2);break}case"u":{let s="",t=r+2;for(;t<e.length&&t<r+6&&/[0-9a-fA-F]/.test(e[t]);)s+=e[t],t++;s?(n+=String.fromCodePoint(parseInt(s,16)),r=t):(n+="\\u",r+=2);break}case"0":{let s="",t=r+2;for(;t<e.length&&t<r+5&&/[0-7]/.test(e[t]);)s+=e[t],t++;s?n+=String.fromCharCode(parseInt(s,8)):n+="\0",r=t;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",t=r+1;for(;t<e.length&&t<r+4&&/[0-7]/.test(e[t]);)s+=e[t],t++;n+=String.fromCharCode(parseInt(s,8)),r=t;break}default:n+=e[r],r++}else n+=e[r],r++;return{value:n,stopped:!1}}var ue={name:"printf",flags:[{flag:"-v",type:"value",valueHint:"string"}],stdinType:"none",needsArgs:!0};export{pe as a,ue as b};
@@ -1,38 +1,37 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as W}from"./chunk-7I6MNC5I.js";import{c as $}from"./chunk-4SQKKW2M.js";import{b as O}from"./chunk-46CDVHZ3.js";import{a as V}from"./chunk-H4BRFPKY.js";import{b as I}from"./chunk-CPKBPQ2C.js";import{a as x,b}from"./chunk-PBOVSFTJ.js";import{a as j}from"./chunk-I4IRHQDW.js";import{a as N,b as R}from"./chunk-MUFNRCMY.js";import{existsSync as ce}from"node:fs";import{dirname as de,join as B,sep as Q}from"node:path";import{fileURLToPath as me}from"node:url";import{Worker as he}from"node:worker_threads";import pe from"sql.js";function K(e,t){return e==null?Buffer.byteLength(t,"utf8"):e instanceof Uint8Array||Buffer.isBuffer(e)?e.byteLength:Buffer.byteLength(String(e),"utf8")}function X(e,t,r){let n=r.maxOutputSize??Number.MAX_SAFE_INTEGER,s=Buffer.byteLength(r.separator,"utf8");s+=Buffer.byteLength(r.newline,"utf8");for(let a of e)s+=Buffer.byteLength(a,"utf8");for(let a of t){s+=a.length*16;for(let i of a)s+=K(i,r.nullValue);if(s>n)break}let o=s*8+(t.length+3)*(e.length+3)*16;if(!Number.isSafeInteger(o)||o>n)throw new Error(`formatted output exceeds ${n} byte limit`);return n}function _(e,t,r){let n=X(e,t,r),s;switch(r.mode){case"list":s=Y(e,t,r);break;case"csv":s=Z(e,t,r);break;case"json":s=te(e,t);break;case"line":s=re(e,t,r);break;case"column":s=ne(e,t,r);break;case"table":s=se(e,t,r);break;case"markdown":s=oe(e,t,r);break;case"tabs":s=ie(e,t,r);break;case"box":s=ae(e,t,r);break;case"quote":s=le(e,t,r);break;case"html":s=fe(e,t,r);break;case"ascii":s=ue(e,t,r);break}if(Buffer.byteLength(s,"utf8")>n)throw new Error(`formatted output exceeds ${n} byte limit`);return s}function h(e,t){return e==null?t:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="number"&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,""):String(e)}function Y(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.join(r.separator));for(let s of t)n.push(s.map(o=>h(o,r.nullValue)).join(r.separator));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function Z(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.map(v).join(","));for(let s of t)n.push(s.map(o=>v(h(o,r.nullValue))).join(","));return n.length>0?`${n.join(`
3
+ import{a as W}from"./chunk-7I6MNC5I.js";import{c as $}from"./chunk-4SQKKW2M.js";import{b as C}from"./chunk-46CDVHZ3.js";import{a as V}from"./chunk-H4BRFPKY.js";import{b as I}from"./chunk-CPKBPQ2C.js";import{a as B,b}from"./chunk-PBOVSFTJ.js";import{a as x}from"./chunk-I4IRHQDW.js";import{a as N,b as R}from"./chunk-MUFNRCMY.js";import{existsSync as ce}from"node:fs";import{dirname as de,join as T,sep as Q}from"node:path";import{fileURLToPath as me}from"node:url";import{Worker as he}from"node:worker_threads";import pe from"sql.js";function K(e,t){return e==null?Buffer.byteLength(t,"utf8"):e instanceof Uint8Array||Buffer.isBuffer(e)?e.byteLength:Buffer.byteLength(String(e),"utf8")}function X(e,t,r){let n=r.maxOutputSize??Number.MAX_SAFE_INTEGER,s=Buffer.byteLength(r.separator,"utf8");s+=Buffer.byteLength(r.newline,"utf8");for(let a of e)s+=Buffer.byteLength(a,"utf8");for(let a of t){s+=a.length*16;for(let i of a)s+=K(i,r.nullValue);if(s>n)break}let o=s*8+(t.length+3)*(e.length+3)*16;if(!Number.isSafeInteger(o)||o>n)throw new Error(`formatted output exceeds ${n} byte limit`);return n}function _(e,t,r){let n=X(e,t,r),s;switch(r.mode){case"list":s=Y(e,t,r);break;case"csv":s=Z(e,t,r);break;case"json":s=te(e,t);break;case"line":s=re(e,t,r);break;case"column":s=ne(e,t,r);break;case"table":s=se(e,t,r);break;case"markdown":s=oe(e,t,r);break;case"tabs":s=ie(e,t,r);break;case"box":s=ae(e,t,r);break;case"quote":s=le(e,t,r);break;case"html":s=fe(e,t,r);break;case"ascii":s=ue(e,t,r);break}if(Buffer.byteLength(s,"utf8")>n)throw new Error(`formatted output exceeds ${n} byte limit`);return s}function m(e,t){return e==null?t:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="number"&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,""):String(e)}function Y(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.join(r.separator));for(let s of t)n.push(s.map(o=>m(o,r.nullValue)).join(r.separator));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function Z(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.map(v).join(","));for(let s of t)n.push(s.map(o=>v(m(o,r.nullValue))).join(","));return n.length>0?`${n.join(`
4
4
  `)}
5
5
  `:""}function v(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
6
6
  `)?`"${e.replace(/"/g,'""')}"`:e}function F(e){return e.toPrecision(17).replace(/\.?0+$/,"")}function ee(e){return e===null?"null":typeof e=="number"?Number.isInteger(e)?String(e):F(e):JSON.stringify(e)}function te(e,t){return t.length===0?"":`[${t.map(n=>`{${e.map((o,a)=>`${JSON.stringify(o)}:${ee(n[a])}`).join(",")}}`).join(`,
7
7
  `)}]
8
- `}function re(e,t,r){if(e.length===0||t.length===0)return"";let n=Math.max(5,...e.map(o=>o.length)),s=[];for(let o of t)for(let a=0;a<e.length;a++){let i=e[a].padStart(n);s.push(`${i} = ${h(o[a],r.nullValue)}`)}return`${s.join(`
8
+ `}function re(e,t,r){if(e.length===0||t.length===0)return"";let n=Math.max(5,...e.map(o=>o.length)),s=[];for(let o of t)for(let a=0;a<e.length;a++){let i=e[a].padStart(n);s.push(`${i} = ${m(o[a],r.nullValue)}`)}return`${s.join(`
9
9
  `)}
10
- `}function ne(e,t,r){if(e.length===0)return"";let n=e.map(o=>o.length);for(let o of t)for(let a=0;a<o.length;a++){let i=h(o[a],r.nullValue).length;i>n[a]&&(n[a]=i)}let s=[];r.header&&(s.push(e.map((o,a)=>o.padEnd(n[a])).join(" ")),s.push(n.map(o=>"-".repeat(o)).join(" ")));for(let o of t)s.push(o.map((a,i)=>h(a,r.nullValue).padEnd(n[i])).join(" "));return s.length>0?`${s.join(`
10
+ `}function ne(e,t,r){if(e.length===0)return"";let n=e.map(o=>o.length);for(let o of t)for(let a=0;a<o.length;a++){let i=m(o[a],r.nullValue).length;i>n[a]&&(n[a]=i)}let s=[];r.header&&(s.push(e.map((o,a)=>o.padEnd(n[a])).join(" ")),s.push(n.map(o=>"-".repeat(o)).join(" ")));for(let o of t)s.push(o.map((a,i)=>m(a,r.nullValue).padEnd(n[i])).join(" "));return s.length>0?`${s.join(`
11
11
  `)}
12
- `:""}function se(e,t,r){if(e.length===0)return"";let n=e.map(a=>a.length);for(let a of t)for(let i=0;i<a.length;i++){let c=h(a[i],r.nullValue).length;c>n[i]&&(n[i]=c)}let s=[],o=`+${n.map(a=>"-".repeat(a+2)).join("+")}+`;s.push(o),r.header&&(s.push(`| ${e.map((a,i)=>a.padEnd(n[i])).join(" | ")} |`),s.push(o));for(let a of t)s.push(`| ${a.map((i,c)=>h(i,r.nullValue).padEnd(n[c])).join(" | ")} |`);return s.push(o),`${s.join(`
12
+ `:""}function se(e,t,r){if(e.length===0)return"";let n=e.map(a=>a.length);for(let a of t)for(let i=0;i<a.length;i++){let c=m(a[i],r.nullValue).length;c>n[i]&&(n[i]=c)}let s=[],o=`+${n.map(a=>"-".repeat(a+2)).join("+")}+`;s.push(o),r.header&&(s.push(`| ${e.map((a,i)=>a.padEnd(n[i])).join(" | ")} |`),s.push(o));for(let a of t)s.push(`| ${a.map((i,c)=>m(i,r.nullValue).padEnd(n[c])).join(" | ")} |`);return s.push(o),`${s.join(`
13
13
  `)}
14
- `}function oe(e,t,r){if(e.length===0)return"";let n=[];r.header&&(n.push(`| ${e.join(" | ")} |`),n.push(`|${e.map(()=>"---").join("|")}|`));for(let s of t)n.push(`| ${s.map(o=>h(o,r.nullValue)).join(" | ")} |`);return n.length>0?`${n.join(`
14
+ `}function oe(e,t,r){if(e.length===0)return"";let n=[];r.header&&(n.push(`| ${e.join(" | ")} |`),n.push(`|${e.map(()=>"---").join("|")}|`));for(let s of t)n.push(`| ${s.map(o=>m(o,r.nullValue)).join(" | ")} |`);return n.length>0?`${n.join(`
15
15
  `)}
16
- `:""}function ie(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.join(" "));for(let s of t)n.push(s.map(o=>h(o,r.nullValue)).join(" "));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function ae(e,t,r){if(e.length===0)return"";let n=e.map(o=>o.length);for(let o of t)for(let a=0;a<o.length;a++){let i=h(o[a],r.nullValue).length;i>n[a]&&(n[a]=i)}let s=[];s.push(`\u250C${n.map(o=>"\u2500".repeat(o+2)).join("\u252C")}\u2510`),s.push(`\u2502 ${e.map((o,a)=>o.padEnd(n[a])).join(" \u2502 ")} \u2502`),s.push(`\u251C${n.map(o=>"\u2500".repeat(o+2)).join("\u253C")}\u2524`);for(let o of t)s.push(`\u2502 ${o.map((a,i)=>h(a,r.nullValue).padEnd(n[i])).join(" \u2502 ")} \u2502`);return s.push(`\u2514${n.map(o=>"\u2500".repeat(o+2)).join("\u2534")}\u2518`),`${s.join(`
16
+ `:""}function ie(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.join(" "));for(let s of t)n.push(s.map(o=>m(o,r.nullValue)).join(" "));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function ae(e,t,r){if(e.length===0)return"";let n=e.map(o=>o.length);for(let o of t)for(let a=0;a<o.length;a++){let i=m(o[a],r.nullValue).length;i>n[a]&&(n[a]=i)}let s=[];s.push(`\u250C${n.map(o=>"\u2500".repeat(o+2)).join("\u252C")}\u2510`),s.push(`\u2502 ${e.map((o,a)=>o.padEnd(n[a])).join(" \u2502 ")} \u2502`),s.push(`\u251C${n.map(o=>"\u2500".repeat(o+2)).join("\u253C")}\u2524`);for(let o of t)s.push(`\u2502 ${o.map((a,i)=>m(a,r.nullValue).padEnd(n[i])).join(" \u2502 ")} \u2502`);return s.push(`\u2514${n.map(o=>"\u2500".repeat(o+2)).join("\u2534")}\u2518`),`${s.join(`
17
17
  `)}
18
- `}function le(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.map(P).join(","));for(let s of t)n.push(s.map(P).join(","));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function P(e){if(e==null)return"NULL";if(e instanceof Uint8Array||Buffer.isBuffer(e))return`X'${Buffer.from(e).toString("hex").toUpperCase()}'`;if(typeof e=="number"){if(Number.isInteger(e))return String(e);if(Number.isFinite(e))return F(e)}return`'${String(e).replace(/'/g,"''")}'`}function fe(e,t,r){let n=[];r.header&&e.length>0&&(n.push(`<TR>${e.map(s=>`<TH>${D(s)}</TH>`).join("")}`),n.push("</TR>"));for(let s of t)n.push(`<TR>${s.map(o=>`<TD>${D(h(o,r.nullValue))}</TD>`).join("")}`),n.push("</TR>");return n.length>0?`${n.join(`
18
+ `}function le(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.map(P).join(","));for(let s of t)n.push(s.map(P).join(","));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function P(e){if(e==null)return"NULL";if(e instanceof Uint8Array||Buffer.isBuffer(e))return`X'${Buffer.from(e).toString("hex").toUpperCase()}'`;if(typeof e=="number"){if(Number.isInteger(e))return String(e);if(Number.isFinite(e))return F(e)}return`'${String(e).replace(/'/g,"''")}'`}function fe(e,t,r){let n=[];r.header&&e.length>0&&(n.push(`<TR>${e.map(s=>`<TH>${D(s)}</TH>`).join("")}`),n.push("</TR>"));for(let s of t)n.push(`<TR>${s.map(o=>`<TD>${D(m(o,r.nullValue))}</TD>`).join("")}`),n.push("</TR>");return n.length>0?`${n.join(`
19
19
  `)}
20
- `:""}function D(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function ue(e,t,r){let o=[];r.header&&e.length>0&&o.push(e.join(""));for(let a of t)o.push(a.map(i=>h(i,r.nullValue)).join(""));return o.length>0?o.join("")+"":""}var ge=1024,be=128,we=16,U="Worker termination was not acknowledged";function T(e,t){if(!Number.isSafeInteger(e)||e<0||e>t)throw new Error(`database exceeds ${t} byte limit`)}var A=new WeakMap;async function z(e,t,r){let n=A.get(e);n||(n=new Map,A.set(e,n));let s=n.get(t);if(s||(s={held:!1,waiters:[]},n.set(t,s)),s.poisonedError)throw new Error(s.poisonedError);if(s.held){if(s.waiters.length>=ge)throw new Error("too many concurrent database operations");await new Promise((a,i)=>{let c={signal:r,grant(){r&&c.abort&&r.removeEventListener("abort",c.abort),a()},reject:i};if(r&&(c.abort=()=>{let u=s?.waiters.indexOf(c)??-1;u!==-1&&s?.waiters.splice(u,1),i(new Error("database lock wait aborted"))},r.addEventListener("abort",c.abort,{once:!0}),r.aborted)){c.abort();return}s?.waiters.push(c)})}else s.held=!0;let o=!1;return()=>{if(o||(o=!0,s?.poisonedError))return;let a=s?.waiters.shift();a?a.grant():(s&&(s.held=!1),n?.delete(t))}}async function ye(e,t,r){let n=[];try{for(let s of[...new Set(t)].sort())n.push(await z(e,s,r))}catch(s){for(let o of n.reverse())o();throw s}return()=>{for(let s of n.reverse())s()}}function ke(e,t,r){let n=A.get(e)?.get(t);if(!(!n||n.poisonedError)){n.poisonedError=r;for(let s of n.waiters.splice(0))s.signal&&s.abort&&s.signal.removeEventListener("abort",s.abort),s.reject(new Error(r))}}var Ee={name:"sqlite3",summary:"SQLite database CLI",usage:"sqlite3 [OPTIONS] DATABASE [SQL]",options:["-list output in list mode (default)","-csv output in CSV mode","-json output in JSON mode","-line output in line mode","-column output in column mode","-table output as ASCII table","-markdown output as markdown table","-tabs output in tab-separated mode","-box output in Unicode box mode","-quote output in SQL quote mode","-html output as HTML table","-ascii output in ASCII mode (control chars)","-header show column headers","-noheader hide column headers","-separator SEP field separator for list mode (default: |)","-newline SEP row separator (default: \\n)","-nullvalue TEXT text for NULL values (default: empty)","-readonly open database read-only (no writeback)","-bail stop on first error","-echo print SQL before execution","-cmd COMMAND run SQL command before main SQL","-version show SQLite version","-- end of options","--help show this help"],examples:['sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(1); SELECT * FROM t"','sqlite3 -json data.db "SELECT * FROM users"','sqlite3 -csv -header data.db "SELECT id, name FROM products"','sqlite3 -box data.db "SELECT * FROM users"']};function Se(e){let t={mode:"list",header:!1,separator:"|",newline:`
20
+ `:""}function D(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function ue(e,t,r){let o=[];r.header&&e.length>0&&o.push(e.join(""));for(let a of t)o.push(a.map(i=>m(i,r.nullValue)).join(""));return o.length>0?o.join("")+"":""}var ge=1024,be=128,we=16,U="Worker termination was not acknowledged";function M(e,t){if(!Number.isSafeInteger(e)||e<0||e>t)throw new Error(`database exceeds ${t} byte limit`)}var O=new WeakMap;async function z(e,t,r){let n=O.get(e);n||(n=new Map,O.set(e,n));let s=n.get(t);if(s||(s={held:!1,waiters:[]},n.set(t,s)),s.poisonedError)throw new Error(s.poisonedError);if(s.held){if(s.waiters.length>=ge)throw new Error("too many concurrent database operations");await new Promise((a,i)=>{let c={signal:r,grant(){r&&c.abort&&r.removeEventListener("abort",c.abort),a()},reject:i};if(r&&(c.abort=()=>{let u=s?.waiters.indexOf(c)??-1;u!==-1&&s?.waiters.splice(u,1),i(new Error("database lock wait aborted"))},r.addEventListener("abort",c.abort,{once:!0}),r.aborted)){c.abort();return}s?.waiters.push(c)})}else s.held=!0;let o=!1;return()=>{if(o||(o=!0,s?.poisonedError))return;let a=s?.waiters.shift();a?a.grant():(s&&(s.held=!1),n?.delete(t))}}async function ye(e,t,r){let n=[];try{for(let s of[...new Set(t)].sort())n.push(await z(e,s,r))}catch(s){for(let o of n.reverse())o();throw s}return()=>{for(let s of n.reverse())s()}}function ke(e,t,r){let n=O.get(e)?.get(t);if(!(!n||n.poisonedError)){n.poisonedError=r;for(let s of n.waiters.splice(0))s.signal&&s.abort&&s.signal.removeEventListener("abort",s.abort),s.reject(new Error(r))}}var Ee={name:"sqlite3",summary:"SQLite database CLI",usage:"sqlite3 [OPTIONS] DATABASE [SQL]",options:["-list output in list mode (default)","-csv output in CSV mode","-json output in JSON mode","-line output in line mode","-column output in column mode","-table output as ASCII table","-markdown output as markdown table","-tabs output in tab-separated mode","-box output in Unicode box mode","-quote output in SQL quote mode","-html output as HTML table","-ascii output in ASCII mode (control chars)","-header show column headers","-noheader hide column headers","-separator SEP field separator for list mode (default: |)","-newline SEP row separator (default: \\n)","-nullvalue TEXT text for NULL values (default: empty)","-readonly open database read-only (no writeback)","-bail stop on first error","-echo print SQL before execution","-cmd COMMAND run SQL command before main SQL","-version show SQLite version","-- end of options","--help show this help"],examples:['sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(1); SELECT * FROM t"','sqlite3 -json data.db "SELECT * FROM users"','sqlite3 -csv -header data.db "SELECT id, name FROM products"','sqlite3 -box data.db "SELECT * FROM users"']};function Se(e){let t={mode:"list",header:!1,separator:"|",newline:`
21
21
  `,nullValue:"",readonly:!1,bail:!1,echo:!1,cmd:null},r=null,n=null,s=!1,o=!1;for(let a=0;a<e.length;a++){let i=e[a];if(o){r===null?r=i:n===null&&(n=i);continue}if(i==="--")o=!0;else if(i==="-version")s=!0;else if(i==="-list")t.mode="list";else if(i==="-csv")t.mode="csv";else if(i==="-json")t.mode="json";else if(i==="-line")t.mode="line";else if(i==="-column")t.mode="column";else if(i==="-table")t.mode="table";else if(i==="-markdown")t.mode="markdown";else if(i==="-tabs")t.mode="tabs";else if(i==="-box")t.mode="box";else if(i==="-quote")t.mode="quote";else if(i==="-html")t.mode="html";else if(i==="-ascii")t.mode="ascii";else if(i==="-header")t.header=!0;else if(i==="-noheader")t.header=!1;else if(i==="-readonly")t.readonly=!0;else if(i==="-bail")t.bail=!0;else if(i==="-echo")t.echo=!0;else if(i==="-separator"){if(a+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -separator
22
22
  `,exitCode:1};t.separator=e[++a]}else if(i==="-newline"){if(a+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -newline
23
23
  `,exitCode:1};t.newline=e[++a]}else if(i==="-nullvalue"){if(a+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -nullvalue
24
24
  `,exitCode:1};t.nullValue=e[++a]}else if(i==="-cmd"){if(a+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -cmd
25
25
  `,exitCode:1};t.cmd=e[++a]}else{if(i.startsWith("-"))return{stdout:"",stderr:`sqlite3: Error: unknown option: ${i.startsWith("--")?i.slice(1):i}
26
26
  Use -help for a list of options.
27
- `,exitCode:1};r===null?r=i:n===null&&(n=i)}}return{options:t,database:r,sql:n,showVersion:s}}async function Le(){let e=await O.runTrustedAsync(()=>pe()),t=new e.Database;try{let r=t.exec("SELECT sqlite_version()");return r.length>0&&r[0].values.length>0?String(r[0].values[0][0]):"unknown"}finally{t.close()}}function H(e=de(me(import.meta.url))){let t=[B(e,"sqlite3-worker.js"),B(e,"../../commands/sqlite3/worker.js")];(e.endsWith(`${Q}commands${Q}sqlite3`)||e.endsWith("/commands/sqlite3"))&&t.push(B(e,"worker.js")),t.push(B(e,"../../../dist/commands/sqlite3/worker.js"));for(let r of t)if(ce(r))return r;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}var $e={createWorker(e,t){return new he(e,{workerData:t,resourceLimits:{maxOldGenerationSizeMb:be,maxYoungGenerationSizeMb:we}})},findWorkerPath:H,acquireDatabaseLock:z};function qe(e,t){if(!e||typeof e!="object")return{success:!1,error:"Malformed worker response"};let r=e;return typeof r.protocolToken!="string"||r.protocolToken!==t?{success:!1,error:"Malformed worker response: invalid protocol token"}:r.type==="security-violation"?{success:!1,error:`Security violation: ${typeof r.violation?.type=="string"?r.violation.type:"unknown"}`}:typeof r.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:r.success?Array.isArray(r.results)?typeof r.hasModifications!="boolean"?{success:!1,error:"Malformed worker response: missing hasModifications flag"}:r.dbBuffer!==null&&r.dbBuffer!==void 0&&!(r.dbBuffer instanceof Uint8Array)?{success:!1,error:"Malformed worker response: invalid dbBuffer"}:{success:!0,results:r.results,hasModifications:r.hasModifications,dbBuffer:r.dbBuffer===void 0?null:r.dbBuffer,defenseStats:r.defenseStats}:{success:!1,error:"Malformed worker response: missing results array"}:{success:!1,error:typeof r.error=="string"&&r.error.length>0?r.error:"Worker execution failed"}}async function je(e,t,r){try{let n=H();return await new Promise(s=>{let o,a=!1,i=!1,c=()=>{!i||!o||(i=!1,o.removeListener?.("message",d),o.removeListener?.("error",p),o.removeListener?.("exit",L))},u=async(l,f)=>{if(a)return;a=!0,c();let g=f?await t.terminate(o):!1;t.close(),s(g?l:{success:!1,error:U})},w=$(r,"sqlite3","worker cancellation callback",l=>{u({success:!1,error:l==="abort"?t.abortMessage():t.timeoutMessage("Query")},!0)});if(t.arm(l=>{try{w(l)}catch(f){u({success:!1,error:b(j(f))},!0)}}),t.isCanceled)return;try{o=O.runTrusted(()=>$e.createWorker(n,e))}catch(l){throw t.close(),l}let y=$(r,"sqlite3","worker message callback",l=>{try{let f=l&&typeof l=="object"?{protocolToken:l.protocolToken,type:l.type,violation:l.violation,success:l.success,error:l.error,results:l.results,hasModifications:l.hasModifications,defenseStats:l.defenseStats}:l;t.assertMessageSize(f,"response"),u(qe(l,e.protocolToken),!0)}catch(f){u({success:!1,error:b(j(f))},!0)}}),S=$(r,"sqlite3","worker error callback",l=>{u({success:!1,error:b(j(l))},!0)}),q=$(r,"sqlite3","worker exit callback",l=>{l!==0&&u({success:!1,error:`Worker exited with code ${l}`},!1)}),d=l=>{try{y(l)}catch(f){let g=f instanceof Error?f.message:String(f);u({success:!1,error:b(g)},!0)}},p=l=>{try{S(l)}catch(f){let g=f instanceof Error?f.message:String(f);u({success:!1,error:b(g)},!0)}},L=l=>{try{q(l)}catch(f){let g=f instanceof Error?f.message:String(f);u({success:!1,error:b(g)},!0)}};o.on("message",d),o.on("error",p),o.on("exit",L),i=!0})}catch(n){let s=b(n.message);throw new Error(`sqlite3 worker failed to load: ${s}`)}}var _e={name:"sqlite3",async execute(e,t){if(R(e)||e.includes("-help"))return N(Ee);let r=Se(e);if("exitCode"in r)return r;let{options:n,database:s,sql:o,showVersion:a}=r;if(a)return{stdout:`${await Le()}
27
+ `,exitCode:1};r===null?r=i:n===null&&(n=i)}}return{options:t,database:r,sql:n,showVersion:s}}async function Le(){let e=await C.runTrustedAsync(()=>pe()),t=new e.Database;try{let r=t.exec("SELECT sqlite_version()");return r.length>0&&r[0].values.length>0?String(r[0].values[0][0]):"unknown"}finally{t.close()}}function H(e=de(me(import.meta.url))){let t=[T(e,"sqlite3-worker.js"),T(e,"../../commands/sqlite3/worker.js")];(e.endsWith(`${Q}commands${Q}sqlite3`)||e.endsWith("/commands/sqlite3"))&&t.push(T(e,"worker.js")),t.push(T(e,"../../../dist/commands/sqlite3/worker.js"));for(let r of t)if(ce(r))return r;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}var $e={createWorker(e,t){return new he(e,{workerData:t,resourceLimits:{maxOldGenerationSizeMb:be,maxYoungGenerationSizeMb:we}})},findWorkerPath:H,acquireDatabaseLock:z};function qe(e,t){if(!e||typeof e!="object")return{success:!1,error:"Malformed worker response"};let r=e;return typeof r.protocolToken!="string"||r.protocolToken!==t?{success:!1,error:"Malformed worker response: invalid protocol token"}:r.type==="security-violation"?{success:!1,error:`Security violation: ${typeof r.violation?.type=="string"?r.violation.type:"unknown"}`}:typeof r.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:r.success?Array.isArray(r.results)?typeof r.hasModifications!="boolean"?{success:!1,error:"Malformed worker response: missing hasModifications flag"}:r.dbBuffer!==null&&r.dbBuffer!==void 0&&!(r.dbBuffer instanceof Uint8Array)?{success:!1,error:"Malformed worker response: invalid dbBuffer"}:{success:!0,results:r.results,hasModifications:r.hasModifications,dbBuffer:r.dbBuffer===void 0?null:r.dbBuffer,defenseStats:r.defenseStats}:{success:!1,error:"Malformed worker response: missing results array"}:{success:!1,error:typeof r.error=="string"&&r.error.length>0?r.error:"Worker execution failed"}}async function je(e,t,r){try{let n=H();return await new Promise(s=>{let o,a=!1,i=!1,c=()=>{!i||!o||(i=!1,o.removeListener?.("message",d),o.removeListener?.("error",p),o.removeListener?.("exit",L))},u=async(l,f)=>{if(a)return;a=!0,c();let g=f?await t.terminate(o):!1;t.close(),s(g?l:{success:!1,error:U})},w=$(r,"sqlite3","worker cancellation callback",l=>{u({success:!1,error:l==="abort"?t.abortMessage():t.timeoutMessage("Query")},!0)});if(t.arm(l=>{try{w(l)}catch(f){u({success:!1,error:b(x(f))},!0)}}),t.isCanceled)return;try{o=C.runTrusted(()=>$e.createWorker(n,e))}catch(l){throw t.close(),l}let y=$(r,"sqlite3","worker message callback",l=>{try{let f=l&&typeof l=="object"?{protocolToken:l.protocolToken,type:l.type,violation:l.violation,success:l.success,error:l.error,results:l.results,hasModifications:l.hasModifications,defenseStats:l.defenseStats}:l;t.assertMessageSize(f,"response"),u(qe(l,e.protocolToken),!0)}catch(f){u({success:!1,error:b(x(f))},!0)}}),S=$(r,"sqlite3","worker error callback",l=>{u({success:!1,error:b(x(l))},!0)}),q=$(r,"sqlite3","worker exit callback",l=>{l!==0&&u({success:!1,error:`Worker exited with code ${l}`},!1)}),d=l=>{try{y(l)}catch(f){let g=f instanceof Error?f.message:String(f);u({success:!1,error:b(g)},!0)}},p=l=>{try{S(l)}catch(f){let g=f instanceof Error?f.message:String(f);u({success:!1,error:b(g)},!0)}},L=l=>{try{q(l)}catch(f){let g=f instanceof Error?f.message:String(f);u({success:!1,error:b(g)},!0)}};o.on("message",d),o.on("error",p),o.on("exit",L),i=!0})}catch(n){let s=b(n.message);throw new Error(`sqlite3 worker failed to load: ${s}`)}}var _e={name:"sqlite3",async execute(e,t){if(R(e)||e.includes("-help"))return N(Ee);let r=Se(e);if("exitCode"in r)return r;let{options:n,database:s,sql:o,showVersion:a}=r;if(a)return{stdout:`${await Le()}
28
28
  `,stderr:"",exitCode:0};if(!s)return{stdout:"",stderr:`sqlite3: missing database argument
29
29
  `,exitCode:1};let i=o||I(t.stdin).trim();if(n.cmd&&(i=n.cmd+(i?`; ${i}`:"")),!i)return{stdout:"",stderr:`sqlite3: no SQL provided
30
- `,exitCode:1};let c=s===":memory:",u="",w=[],y=null,S,q;try{if(!c){u=t.fs.resolvePath(t.cwd,s);let d=await V(t.fs,u);if(d.existence==="unknown")throw new Error("database identity cannot be determined safely");if(d.canonicalPath!==void 0&&(u=d.canonicalPath),w=[],d.canonicalPath!==void 0&&w.push(`path:${d.canonicalPath}`),d.existence==="existing"){if(d.stableIdentity===void 0)throw new Error("database identity cannot be determined safely");w.push(`identity:${d.stableIdentity}`)}if(w.length===0)throw new Error("database identity cannot be determined safely");if(S=await ye(t.fsIdentity??t.fs,w,t.signal),await t.fs.exists(u)){let p=await t.fs.stat(u);T(p.size,t.limits.maxDatabaseBytes),y=await t.fs.readFileBuffer(u),T(y.byteLength,t.limits.maxDatabaseBytes),q=t.executionScope?.reserveBytes("sqlite-database",y.byteLength,"sqlite3 database")}}}catch(d){S?.();let p=x(d.message);return{stdout:"",stderr:`sqlite3: unable to open database "${s}": ${p}
31
- `,exitCode:1}}try{let d=t.limits.maxSqliteTimeoutMs,p=new W({commandName:"sqlite3",timeoutMs:d,signal:t.signal,maxMessageBytes:t.limits.maxWorkerMessageBytes}),L={protocolToken:p.protocolToken,dbBuffer:y,sql:i,options:{bail:n.bail,echo:n.echo},limits:{maxResultRows:t.limits.maxArrayElements,maxResultBytes:t.limits.maxDatabaseResultBytes,maxDatabaseBytes:t.limits.maxDatabaseBytes}};p.assertMessageSize({...L,dbBuffer:void 0},"request");let l,f;try{y&&(T(y.byteLength,t.limits.maxDatabaseBytes),f=t.executionScope?.reserveBytes("sqlite-worker-clone",y.byteLength,"sqlite3 worker clone")),l=await je(L,p,t.requireDefenseContext)}catch(m){return{stdout:"",stderr:`sqlite3: worker error: ${b(m.message)}
32
- `,exitCode:1}}finally{f?.release()}if(!l.success){if(w.length>0&&l.error===U)for(let E of w)ke(t.fsIdentity??t.fs,E,l.error);return{stdout:"",stderr:`sqlite3: ${b(l.error)}
33
- `,exitCode:1}}let g=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),G={mode:n.mode,header:n.header,separator:n.separator,newline:n.newline,nullValue:n.nullValue,maxOutputSize:g},k="";n.echo&&(k+=`${i}
34
- `);let M=!1,C=null;for(let m of l.results)if(m.type==="error"){if(n.bail){C=m.error??"SQL error",M=!0;break}k+=`Error: ${m.error}
35
- `,M=!0}else if(m.columns&&m.rows&&(m.rows.length>0||n.header))try{let E=Math.max(0,g-Buffer.byteLength(k,"utf8"));k+=_(m.columns,m.rows,{...G,maxOutputSize:E})}catch(E){let J=x(E.message);return{stdout:k,stderr:`sqlite3: ${J}
36
- `,exitCode:1}}if(l.hasModifications&&!n.readonly&&!c&&u&&l.dbBuffer)try{T(l.dbBuffer.byteLength,t.limits.maxDatabaseBytes),await t.fs.writeFile(u,l.dbBuffer)}catch(m){let E=x(m.message);return{stdout:k,stderr:`sqlite3: failed to write database: ${E}
37
- `,exitCode:1}}return C!==null?{stdout:k,stderr:`Error: ${C}
38
- `,exitCode:1}:{stdout:k,stderr:"",exitCode:M&&n.bail?1:0}}finally{q?.release(),S?.()}}},Fe={name:"sqlite3",flags:[],needsArgs:!0};export{$e as a,_e as b,Fe as c};
30
+ `,exitCode:1};let c=s===":memory:",u="",w=[],y=null,S,q;try{if(!c){u=t.fs.resolvePath(t.cwd,s);let d=await V(t.fs,u);if(d.existence==="unknown")throw new Error("database identity cannot be determined safely");if(d.canonicalPath!==void 0&&(u=d.canonicalPath),w=[],d.canonicalPath!==void 0&&w.push(`path:${d.canonicalPath}`),d.existence==="existing"){if(d.stableIdentity===void 0)throw new Error("database identity cannot be determined safely");w.push(`identity:${d.stableIdentity}`)}if(w.length===0)throw new Error("database identity cannot be determined safely");if(S=await ye(t.fsIdentity??t.fs,w,t.signal),await t.fs.exists(u)){let p=await t.fs.stat(u);M(p.size,t.limits.maxDatabaseBytes),y=await t.fs.readFileBuffer(u),M(y.byteLength,t.limits.maxDatabaseBytes),q=t.executionScope?.reserveBytes("sqlite-database",y.byteLength,"sqlite3 database")}}}catch(d){S?.();let p=B(d.message);return{stdout:"",stderr:`sqlite3: unable to open database "${s}": ${p}
31
+ `,exitCode:1}}try{let d=t.limits.maxSqliteTimeoutMs,p=new W({commandName:"sqlite3",timeoutMs:d,signal:t.signal,maxMessageBytes:t.limits.maxWorkerMessageBytes}),L={protocolToken:p.protocolToken,dbBuffer:y,sql:i,options:{bail:n.bail,echo:n.echo},limits:{maxResultRows:t.limits.maxArrayElements,maxResultBytes:t.limits.maxDatabaseResultBytes,maxDatabaseBytes:t.limits.maxDatabaseBytes}};p.assertMessageSize({...L,dbBuffer:void 0},"request");let l,f;try{y&&(M(y.byteLength,t.limits.maxDatabaseBytes),f=t.executionScope?.reserveBytes("sqlite-worker-clone",y.byteLength,"sqlite3 worker clone")),l=await je(L,p,t.requireDefenseContext)}catch(h){return{stdout:"",stderr:`sqlite3: worker error: ${b(h.message)}
32
+ `,exitCode:1}}finally{f?.release()}if(!l.success){if(w.length>0&&l.error===U)for(let k of w)ke(t.fsIdentity??t.fs,k,l.error);return{stdout:"",stderr:`sqlite3: ${b(l.error)}
33
+ `,exitCode:1}}let g=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),G={mode:n.mode,header:n.header,separator:n.separator,newline:n.newline,nullValue:n.nullValue,maxOutputSize:g},E="";n.echo&&(E+=`${i}
34
+ `);let j="",A=!1;for(let h of l.results)if(h.type==="error"){if(j+=`Error: ${h.error??"SQL error"}
35
+ `,A=!0,n.bail)break}else if(h.columns&&h.rows&&(h.rows.length>0||n.header))try{let k=Math.max(0,g-Buffer.byteLength(E,"utf8"));E+=_(h.columns,h.rows,{...G,maxOutputSize:k})}catch(k){let J=B(k.message);return{stdout:E,stderr:`${j}sqlite3: ${J}
36
+ `,exitCode:1}}if(l.hasModifications&&!n.readonly&&!c&&u&&l.dbBuffer)try{M(l.dbBuffer.byteLength,t.limits.maxDatabaseBytes),await t.fs.writeFile(u,l.dbBuffer)}catch(h){let k=B(h.message);return{stdout:E,stderr:`${j}sqlite3: failed to write database: ${k}
37
+ `,exitCode:1}}return{stdout:E,stderr:j,exitCode:A?1:0}}finally{q?.release(),S?.()}}},Fe={name:"sqlite3",flags:[],needsArgs:!0};export{$e as a,_e as b,Fe as c};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
3
  function n(r){let s="",e=0;for(;e<r.length;)if(r[e]==="\\"){if(e+1>=r.length){s+="\\";break}let o=r[e+1];switch(o){case"\\":s+="\\",e+=2;break;case"n":s+=`
4
- `,e+=2;break;case"t":s+=" ",e+=2;break;case"r":s+="\r",e+=2;break;case"a":s+="\x07",e+=2;break;case"b":s+="\b",e+=2;break;case"f":s+="\f",e+=2;break;case"v":s+="\v",e+=2;break;case"e":case"E":s+="\x1B",e+=2;break;case"c":return{output:s,stop:!0};case"0":{let a="",t=e+2;for(;t<r.length&&t<e+5&&/[0-7]/.test(r[t]);)a+=r[t],t++;if(a.length===0)s+="\0";else{let l=parseInt(a,8)%256;s+=String.fromCharCode(l)}e=t;break}case"x":{let a="",t=e+2;for(;t<r.length&&t<e+4&&/[0-9a-fA-F]/.test(r[t]);)a+=r[t],t++;if(a.length===0)s+="\\x",e+=2;else{let l=parseInt(a,16);s+=String.fromCharCode(l),e=t}break}case"u":{let a="",t=e+2;for(;t<r.length&&t<e+6&&/[0-9a-fA-F]/.test(r[t]);)a+=r[t],t++;if(a.length===0)s+="\\u",e+=2;else{let l=parseInt(a,16);s+=String.fromCodePoint(l),e=t}break}case"U":{let a="",t=e+2;for(;t<r.length&&t<e+10&&/[0-9a-fA-F]/.test(r[t]);)a+=r[t],t++;if(a.length===0)s+="\\U",e+=2;else{let l=parseInt(a,16);try{s+=String.fromCodePoint(l)}catch{s+=`\\U${a}`}e=t}break}default:s+=`\\${o}`,e+=2}}else s+=r[e],e++;return{output:s,stop:!1}}var c={name:"echo",async execute(r,s){let e=!1,o=s.xpgEcho??!1,a=0;for(;a<r.length;){let l=r[a];if(l==="-n")e=!0,a++;else if(l==="-e")o=!0,a++;else if(l==="-E")o=!1,a++;else if(l==="-ne"||l==="-en")e=!0,o=!0,a++;else break}let t=r.slice(a).join(" ");if(o){let l=n(t);if(t=l.output,l.stop)return{stdout:t,stderr:"",exitCode:0}}return e||(t+=`
5
- `),{stdout:t,stderr:"",exitCode:0}}},f={name:"echo",flags:[{flag:"-n",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-E",type:"boolean"}],stdinType:"none",needsArgs:!0};export{c as a,f as b};
4
+ `,e+=2;break;case"t":s+=" ",e+=2;break;case"r":s+="\r",e+=2;break;case"a":s+="\x07",e+=2;break;case"b":s+="\b",e+=2;break;case"f":s+="\f",e+=2;break;case"v":s+="\v",e+=2;break;case"e":case"E":s+="\x1B",e+=2;break;case"c":return{output:s,stop:!0};case"0":{let a="",t=e+2;for(;t<r.length&&t<e+5&&/[0-7]/.test(r[t]);)a+=r[t],t++;if(a.length===0)s+="\0";else{let l=parseInt(a,8)%256;s+=String.fromCharCode(l)}e=t;break}case"x":{let a="",t=e+2;for(;t<r.length&&t<e+4&&/[0-9a-fA-F]/.test(r[t]);)a+=r[t],t++;if(a.length===0)s+="\\x",e+=2;else{let l=parseInt(a,16);s+=String.fromCharCode(l),e=t}break}case"u":{let a="",t=e+2;for(;t<r.length&&t<e+6&&/[0-9a-fA-F]/.test(r[t]);)a+=r[t],t++;if(a.length===0)s+="\\u",e+=2;else{let l=parseInt(a,16);s+=String.fromCodePoint(l),e=t}break}case"U":{let a="",t=e+2;for(;t<r.length&&t<e+10&&/[0-9a-fA-F]/.test(r[t]);)a+=r[t],t++;if(a.length===0)s+="\\U",e+=2;else{let l=parseInt(a,16);try{s+=String.fromCodePoint(l)}catch{s+=`\\U${a}`}e=t}break}default:s+=`\\${o}`,e+=2}}else s+=r[e],e++;return{output:s,stop:!1}}var c={name:"echo",async execute(r,s){let e=!1,o=s.xpgEcho??!1,a=0;for(;a<r.length;){let l=r[a];if(l==="-n")e=!0,a++;else if(l==="-e")o=!0,a++;else if(l==="-E")o=!1,a++;else if(l==="-ne"||l==="-en")e=!0,o=!0,a++;else break}let t=r.slice(a).join(" ");if(o){let l=n(t);if(t=l.output,l.stop)return{stdout:t,stderr:"",exitCode:0,internalStdinConsumed:0}}return e||(t+=`
5
+ `),{stdout:t,stderr:"",exitCode:0,internalStdinConsumed:0}}},f={name:"echo",flags:[{flag:"-n",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-E",type:"boolean"}],stdinType:"none",needsArgs:!0};export{c as a,f as b};