@poe-platform/safe-bash 0.1.630 → 0.1.632
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/office-package/compression.d.ts +19 -0
- package/dist/office-package/compression.js +186 -0
- package/dist/office-package/runtime.d.ts +11 -0
- package/dist/office-package/runtime.js +28 -0
- package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js → bz2-ACU4EOVE.js} +2 -2
- package/dist/safe-bash/chunks/chunk-2E4KBFO6.js +239 -0
- package/dist/safe-bash/chunks/chunk-2E4KBFO6.js.map +7 -0
- package/dist/safe-bash/chunks/chunk-3E5M2WEL.js +33 -0
- package/dist/safe-bash/chunks/chunk-3E5M2WEL.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-KQ6J7JHQ.js → chunk-3LD67SER.js} +12 -10
- package/dist/safe-bash/chunks/{chunk-KQ6J7JHQ.js.map → chunk-3LD67SER.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js → chunk-6HNK7Q66.js} +11 -7
- package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js.map → chunk-6HNK7Q66.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js → chunk-7EEWZY5S.js} +10 -8
- package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js.map → chunk-7EEWZY5S.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js → chunk-CDBQXRWL.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-UYX72YHY.js → chunk-CHHAB5SS.js} +10 -74
- package/dist/safe-bash/chunks/{chunk-UYX72YHY.js.map → chunk-CHHAB5SS.js.map} +3 -3
- package/dist/safe-bash/chunks/{chunk-6YSBXTTJ.js → chunk-EI4X5ETX.js} +12 -10
- package/dist/safe-bash/chunks/{chunk-6YSBXTTJ.js.map → chunk-EI4X5ETX.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js → chunk-GIBLUW2U.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js.map → chunk-GIBLUW2U.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js +1528 -0
- package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js → chunk-H3E67KTZ.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js.map → chunk-H3E67KTZ.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-AFH57PPL.js → chunk-IEKESMO4.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js → chunk-JLBIUYT3.js} +2 -2
- package/dist/safe-bash/chunks/chunk-JZDO5MC3.js +77 -0
- package/dist/safe-bash/chunks/chunk-JZDO5MC3.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js → chunk-LA6BX562.js} +8 -6
- package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js.map → chunk-LA6BX562.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js → chunk-M3GPCYSP.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js → chunk-NDCZ3UBP.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js.map → chunk-NDCZ3UBP.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js → chunk-O2EVBRKF.js} +1 -2
- package/dist/safe-bash/chunks/chunk-OFT77XIB.js +389 -0
- package/dist/safe-bash/chunks/chunk-OFT77XIB.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-PCLOK32J.js → chunk-PC6BEIAF.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-PCLOK32J.js.map → chunk-PC6BEIAF.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js → chunk-QWKP7ZU7.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js.map → chunk-QWKP7ZU7.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-THXJ6CLF.js +53 -0
- package/dist/safe-bash/chunks/chunk-THXJ6CLF.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-K7W6Q6FN.js → chunk-V73A742N.js} +58 -16
- package/dist/safe-bash/chunks/chunk-V73A742N.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js → chunk-VN3ZGME3.js} +12 -8
- package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js.map → chunk-VN3ZGME3.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-3BZ5NQ73.js → chunk-WECHUK3Y.js} +369 -36
- package/dist/safe-bash/chunks/chunk-WECHUK3Y.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-X55AMTNM.js → chunk-WIOEUR7D.js} +14 -10
- package/dist/safe-bash/chunks/{chunk-X55AMTNM.js.map → chunk-WIOEUR7D.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-WPIOO4NX.js +443 -0
- package/dist/safe-bash/chunks/chunk-WPIOO4NX.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js → chunk-WYTI64IU.js} +2 -2
- package/dist/safe-bash/chunks/{xz-AVXFDXW4.js → xz-U4QDTPZL.js} +2 -2
- package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js → zstd-OG5RPYXO.js} +2 -2
- package/dist/safe-bash/commands/archive/zip/crc.d.ts +2 -0
- package/dist/safe-bash/commands/archive/zip/crc.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/crc.js +7 -0
- package/dist/safe-bash/commands/archive/zip/crc.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip/crypto.d.ts +4 -0
- package/dist/safe-bash/commands/archive/zip/crypto.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/crypto.js +34 -0
- package/dist/safe-bash/commands/archive/zip/crypto.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip/help.d.ts +3 -0
- package/dist/safe-bash/commands/archive/zip/help.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/help.js +87 -0
- package/dist/safe-bash/commands/archive/zip/help.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip/move.d.ts +12 -0
- package/dist/safe-bash/commands/archive/zip/move.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/move.js +60 -0
- package/dist/safe-bash/commands/archive/zip/move.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip/options.js +5 -5
- package/dist/safe-bash/commands/archive/zip/options.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -1
- package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip-format.js +14 -17
- package/dist/safe-bash/commands/archive/zip-format.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip.js +45 -15
- package/dist/safe-bash/commands/archive/zip.js.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts +2 -0
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.js +4 -0
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.js.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/codec.d.ts +4 -24
- package/dist/safe-bash/commands/bytes/compression/codec.d.ts.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/codec.js +12 -168
- package/dist/safe-bash/commands/bytes/compression/codec.js.map +1 -1
- package/dist/safe-bash/commands/cmp.js +1 -1
- package/dist/safe-bash/commands/cmp.js.map +1 -1
- package/dist/safe-bash/commands/csplit/index.browser.js +10 -7
- package/dist/safe-bash/commands/docx/index.browser.js +54 -0
- package/dist/safe-bash/commands/docx/index.browser.js.map +7 -0
- package/dist/safe-bash/commands/docx/index.d.ts +25 -0
- package/dist/safe-bash/commands/docx/index.d.ts.map +1 -0
- package/dist/safe-bash/commands/docx/index.js +42 -0
- package/dist/safe-bash/commands/docx/index.js.map +1 -0
- package/dist/safe-bash/commands/docx/io.d.ts +15 -0
- package/dist/safe-bash/commands/docx/io.d.ts.map +1 -0
- package/dist/safe-bash/commands/docx/io.js +16 -0
- package/dist/safe-bash/commands/docx/io.js.map +1 -0
- package/dist/safe-bash/commands/factor/index.browser.js +7 -5
- package/dist/safe-bash/commands/filesystem.d.ts.map +1 -1
- package/dist/safe-bash/commands/filesystem.js +9 -1
- package/dist/safe-bash/commands/filesystem.js.map +1 -1
- package/dist/safe-bash/commands/getopt/index.browser.js +7 -5
- package/dist/safe-bash/commands/hexdump/index.browser.js +8 -6
- package/dist/safe-bash/commands/iconv/index.browser.js +8 -6
- package/dist/safe-bash/commands/line-endings/index.browser.js +10 -7
- package/dist/safe-bash/commands/llm/index.browser.js +10 -8
- package/dist/safe-bash/commands/llm/providers/index.browser.js +3 -3
- package/dist/safe-bash/commands/network/index.browser.js +11 -8
- package/dist/safe-bash/commands/node/index.browser.js +8 -6
- package/dist/safe-bash/commands/op/index.browser.js +3 -3
- package/dist/safe-bash/commands/op/index.js +0 -1
- package/dist/safe-bash/commands/op/index.js.map +2 -2
- package/dist/safe-bash/commands/pptx/index.d.ts +29 -0
- package/dist/safe-bash/commands/pptx/index.d.ts.map +1 -0
- package/dist/safe-bash/commands/pptx/index.js +153 -0
- package/dist/safe-bash/commands/pptx/index.js.map +1 -0
- package/dist/safe-bash/commands/pr/index.browser.js +8 -6
- package/dist/safe-bash/commands/predicates.js +1 -1
- package/dist/safe-bash/commands/python/execution.d.ts +3 -0
- package/dist/safe-bash/commands/python/execution.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/execution.js +193 -0
- package/dist/safe-bash/commands/python/execution.js.map +1 -0
- package/dist/safe-bash/commands/python/index.browser.js +21 -0
- package/dist/safe-bash/commands/python/index.browser.js.map +7 -0
- package/dist/safe-bash/commands/python/index.d.ts +49 -0
- package/dist/safe-bash/commands/python/index.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/index.js +317 -0
- package/dist/safe-bash/commands/python/index.js.map +1 -0
- package/dist/safe-bash/commands/python/installation.d.ts +9 -0
- package/dist/safe-bash/commands/python/installation.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/installation.js +80 -0
- package/dist/safe-bash/commands/python/installation.js.map +1 -0
- package/dist/safe-bash/commands/python/invocation.d.ts +10 -0
- package/dist/safe-bash/commands/python/invocation.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/invocation.js +81 -0
- package/dist/safe-bash/commands/python/invocation.js.map +1 -0
- package/dist/safe-bash/commands/python/node.d.ts +12 -0
- package/dist/safe-bash/commands/python/node.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/node.js +33 -0
- package/dist/safe-bash/commands/python/node.js.map +1 -0
- package/dist/safe-bash/commands/python/provisioning-runtime.d.ts +5 -0
- package/dist/safe-bash/commands/python/provisioning-runtime.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/provisioning-runtime.js +179 -0
- package/dist/safe-bash/commands/python/provisioning-runtime.js.map +1 -0
- package/dist/safe-bash/commands/python/provisioning.d.ts +49 -0
- package/dist/safe-bash/commands/python/provisioning.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/provisioning.js +320 -0
- package/dist/safe-bash/commands/python/provisioning.js.map +1 -0
- package/dist/safe-bash/commands/python/reply.d.ts +3 -0
- package/dist/safe-bash/commands/python/reply.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/reply.js +103 -0
- package/dist/safe-bash/commands/python/reply.js.map +1 -0
- package/dist/safe-bash/commands/python/worker.browser.js +736 -0
- package/dist/safe-bash/commands/python/worker.browser.js.map +7 -0
- package/dist/safe-bash/commands/python/worker.d.ts +47 -0
- package/dist/safe-bash/commands/python/worker.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/worker.js +373 -0
- package/dist/safe-bash/commands/python/worker.js.map +1 -0
- package/dist/safe-bash/commands/tsort/index.browser.js +8 -6
- package/dist/safe-bash/commands/xml/index.browser.js +9 -7
- package/dist/safe-bash/commands/yq/index.browser.js +10 -8
- package/dist/safe-bash/commands/yq/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/yq/index.js +32 -4
- package/dist/safe-bash/commands/yq/index.js.map +1 -1
- package/dist/safe-bash/commands/yq/parser.d.ts.map +1 -1
- package/dist/safe-bash/commands/yq/parser.js +21 -5
- package/dist/safe-bash/commands/yq/parser.js.map +1 -1
- package/dist/safe-bash/contracts/command.d.ts +2 -0
- package/dist/safe-bash/contracts/command.d.ts.map +1 -1
- package/dist/safe-bash/contracts/command.js +6 -2
- package/dist/safe-bash/contracts/command.js.map +1 -1
- package/dist/safe-bash/contracts/filesystem-descriptor.d.ts +13 -0
- package/dist/safe-bash/contracts/filesystem-descriptor.d.ts.map +1 -0
- package/dist/safe-bash/contracts/filesystem-descriptor.js +189 -0
- package/dist/safe-bash/contracts/filesystem-descriptor.js.map +1 -0
- package/dist/safe-bash/contracts/filesystem-output-budget.d.ts +15 -0
- package/dist/safe-bash/contracts/filesystem-output-budget.d.ts.map +1 -0
- package/dist/safe-bash/contracts/filesystem-output-budget.js +69 -0
- package/dist/safe-bash/contracts/filesystem-output-budget.js.map +1 -0
- package/dist/safe-bash/contracts/filesystem-output.d.ts +11 -5
- package/dist/safe-bash/contracts/filesystem-output.d.ts.map +1 -1
- package/dist/safe-bash/contracts/filesystem-output.js +229 -20
- package/dist/safe-bash/contracts/filesystem-output.js.map +1 -1
- package/dist/safe-bash/contracts/io.d.ts +29 -0
- package/dist/safe-bash/contracts/io.d.ts.map +1 -1
- package/dist/safe-bash/contracts/io.js +317 -37
- package/dist/safe-bash/contracts/io.js.map +1 -1
- package/dist/safe-bash/core.browser.js +5502 -2210
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/dist/safe-bash/core.d.ts +1 -0
- package/dist/safe-bash/core.d.ts.map +1 -1
- package/dist/safe-bash/core.js +1 -0
- package/dist/safe-bash/core.js.map +1 -1
- package/dist/safe-bash/opt-in/commands/cmp/compare.js +95 -0
- package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -0
- package/dist/safe-bash/opt-in/commands/cmp/index.js +99 -0
- package/dist/safe-bash/opt-in/commands/cmp/io.js +218 -0
- package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +24 -0
- package/dist/safe-bash/opt-in/commands/cmp/options.js +195 -0
- package/dist/safe-bash/opt-in/commands/dd/conversions.js +152 -0
- package/dist/safe-bash/opt-in/commands/dd/index.d.ts +18 -0
- package/dist/safe-bash/opt-in/commands/dd/index.js +561 -0
- package/dist/safe-bash/opt-in/commands/dd/io.d.ts +31 -0
- package/dist/safe-bash/opt-in/commands/dd/io.js +244 -0
- package/dist/safe-bash/opt-in/commands/dd/options.js +184 -0
- package/dist/safe-bash/opt-in/commands/dd/report.js +69 -0
- package/dist/safe-bash/opt-in/commands/install/arguments.js +224 -0
- package/dist/safe-bash/opt-in/commands/install/index.d.ts +6 -0
- package/dist/safe-bash/opt-in/commands/install/index.js +678 -0
- package/dist/safe-bash/opt-in/commands/install/mode.js +71 -0
- package/dist/safe-bash/opt-in/commands/install/options.d.ts +36 -0
- package/dist/safe-bash/opt-in/commands/install/options.js +27 -0
- package/dist/safe-bash/opt-in/commands/shuf/args.js +179 -0
- package/dist/safe-bash/opt-in/commands/shuf/index.d.ts +6 -0
- package/dist/safe-bash/opt-in/commands/shuf/index.js +20 -0
- package/dist/safe-bash/opt-in/commands/shuf/input.js +93 -0
- package/dist/safe-bash/opt-in/commands/shuf/options.d.ts +9 -0
- package/dist/safe-bash/opt-in/commands/shuf/options.js +8 -0
- package/dist/safe-bash/opt-in/commands/shuf/random.js +114 -0
- package/dist/safe-bash/opt-in/commands/shuf/shuf.d.ts +3 -0
- package/dist/safe-bash/opt-in/commands/shuf/shuf.js +230 -0
- package/dist/safe-bash/opt-in/commands/shuf/usage.js +24 -0
- package/dist/safe-bash/opt-in/commands/truncate/arguments.js +186 -0
- package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +9 -0
- package/dist/safe-bash/opt-in/commands/truncate/index.js +244 -0
- package/dist/safe-bash/opt-in/commands/yes/index.d.ts +11 -0
- package/dist/safe-bash/opt-in/commands/yes/index.js +167 -0
- package/dist/safe-bash/opt-in/commands/yq/arguments.js +177 -0
- package/dist/safe-bash/opt-in/commands/yq/evaluate.js +564 -0
- package/dist/safe-bash/opt-in/commands/yq/expression.js +183 -0
- package/dist/safe-bash/opt-in/commands/yq/inplace.js +65 -0
- package/dist/safe-bash/opt-in/commands/yq/mike.d.ts +9 -0
- package/dist/safe-bash/opt-in/commands/yq/mike.js +192 -0
- package/dist/safe-bash/opt-in/commands/yq/native-encoder.js +165 -0
- package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +44 -0
- package/dist/safe-bash/opt-in/commands/yq/native-work.js +188 -0
- package/dist/safe-bash/opt-in/commands/yq/nodes.js +621 -0
- package/dist/safe-bash/opt-in/entrypoints/arrays.d.ts +1 -0
- package/dist/safe-bash/opt-in/entrypoints/arrays.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/cmp.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/cmp.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/dd.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/dd.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/devices.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/devices.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/install.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/install.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/jobs.d.ts +1 -0
- package/dist/safe-bash/opt-in/entrypoints/jobs.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/mapfile.d.ts +1 -0
- package/dist/safe-bash/opt-in/entrypoints/mapfile.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/read.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/read.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/shuf.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/shuf.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/trap.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/trap.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/truncate.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/truncate.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/yes.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/yes.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/yq.d.ts +3 -0
- package/dist/safe-bash/opt-in/entrypoints/yq.js +1 -0
- package/dist/safe-bash/opt-in/fs/devices/index.d.ts +8 -0
- package/dist/safe-bash/opt-in/fs/devices/index.js +292 -0
- package/dist/safe-bash/opt-in/optional.d.ts +28 -0
- package/dist/safe-bash/opt-in/optional.js +14 -0
- package/dist/safe-bash/opt-in/shell/extensions/arrays/index.d.ts +2 -0
- package/dist/safe-bash/opt-in/shell/extensions/arrays/index.js +4 -0
- package/dist/safe-bash/opt-in/shell/extensions/jobs/index.d.ts +2 -0
- package/dist/safe-bash/opt-in/shell/extensions/jobs/index.js +291 -0
- package/dist/safe-bash/opt-in/shell/extensions/jobs/state.js +374 -0
- package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.d.ts +24 -0
- package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.js +338 -0
- package/dist/safe-bash/opt-in/shell/extensions/read/index.d.ts +5 -0
- package/dist/safe-bash/opt-in/shell/extensions/read/index.js +351 -0
- package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +9 -0
- package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +210 -0
- package/dist/safe-bash/optional-host.d.ts +5 -0
- package/dist/safe-bash/optional-host.d.ts.map +1 -0
- package/dist/safe-bash/optional-host.js +3 -0
- package/dist/safe-bash/optional-host.js.map +1 -0
- package/dist/safe-bash/shell/arrays/bindings.d.ts +15 -5
- package/dist/safe-bash/shell/arrays/bindings.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/bindings.js +131 -23
- package/dist/safe-bash/shell/arrays/bindings.js.map +1 -1
- package/dist/safe-bash/shell/arrays/ledger.d.ts +1 -0
- package/dist/safe-bash/shell/arrays/ledger.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/ledger.js +19 -0
- package/dist/safe-bash/shell/arrays/ledger.js.map +1 -1
- package/dist/safe-bash/shell/arrays/state.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/state.js +3 -1
- package/dist/safe-bash/shell/arrays/state.js.map +1 -1
- package/dist/safe-bash/shell/arrays/syntax.d.ts +4 -1
- package/dist/safe-bash/shell/arrays/syntax.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/syntax.js +3 -3
- package/dist/safe-bash/shell/arrays/syntax.js.map +1 -1
- package/dist/safe-bash/shell/conditional.js +1 -1
- package/dist/safe-bash/shell/descriptors.d.ts +31 -0
- package/dist/safe-bash/shell/descriptors.d.ts.map +1 -0
- package/dist/safe-bash/shell/descriptors.js +234 -0
- package/dist/safe-bash/shell/descriptors.js.map +1 -0
- package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts +2 -0
- package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts.map +1 -0
- package/dist/safe-bash/shell/diagnostic-name-ranges.js +717 -0
- package/dist/safe-bash/shell/diagnostic-name-ranges.js.map +1 -0
- package/dist/safe-bash/shell/diagnostic-name.d.ts +3 -0
- package/dist/safe-bash/shell/diagnostic-name.d.ts.map +1 -0
- package/dist/safe-bash/shell/diagnostic-name.js +89 -0
- package/dist/safe-bash/shell/diagnostic-name.js.map +1 -0
- package/dist/safe-bash/shell/display.js +1 -1
- package/dist/safe-bash/shell/display.js.map +1 -1
- package/dist/safe-bash/shell/extensions.d.ts +188 -0
- package/dist/safe-bash/shell/extensions.d.ts.map +1 -0
- package/dist/safe-bash/shell/extensions.js +141 -0
- package/dist/safe-bash/shell/extensions.js.map +1 -0
- package/dist/safe-bash/shell/input.d.ts +66 -14
- package/dist/safe-bash/shell/input.d.ts.map +1 -1
- package/dist/safe-bash/shell/input.js +947 -173
- package/dist/safe-bash/shell/input.js.map +1 -1
- package/dist/safe-bash/shell/parser.d.ts +38 -6
- package/dist/safe-bash/shell/parser.d.ts.map +1 -1
- package/dist/safe-bash/shell/parser.js +339 -52
- package/dist/safe-bash/shell/parser.js.map +1 -1
- package/dist/safe-bash/shell/runtime.d.ts +92 -20
- package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
- package/dist/safe-bash/shell/runtime.js +2547 -689
- package/dist/safe-bash/shell/runtime.js.map +1 -1
- package/dist/safe-bash/shell/shell.d.ts.map +1 -1
- package/dist/safe-bash/shell/shell.js +52 -21
- package/dist/safe-bash/shell/shell.js.map +1 -1
- package/dist/safe-bash/shell/types.d.ts +4 -0
- package/dist/safe-bash/shell/types.d.ts.map +1 -1
- package/dist/safe-bash/shell/types.js.map +1 -1
- package/package.json +92 -4
- package/dist/safe-bash/chunks/chunk-3BZ5NQ73.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-4DBWBEU7.js +0 -194
- package/dist/safe-bash/chunks/chunk-4DBWBEU7.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-CXMIIXJA.js +0 -178
- package/dist/safe-bash/chunks/chunk-CXMIIXJA.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-K7W6Q6FN.js.map +0 -7
- /package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js.map → bz2-ACU4EOVE.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js.map → chunk-CDBQXRWL.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-AFH57PPL.js.map → chunk-IEKESMO4.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js.map → chunk-JLBIUYT3.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js.map → chunk-M3GPCYSP.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js.map → chunk-O2EVBRKF.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js.map → chunk-WYTI64IU.js.map} +0 -0
- /package/dist/safe-bash/chunks/{xz-AVXFDXW4.js.map → xz-U4QDTPZL.js.map} +0 -0
- /package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js.map → zstd-OG5RPYXO.js.map} +0 -0
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
import { cloneNode, decodeDocuments, dereference, nodeTag, replace, scalar, truth } from "./nodes.js";
|
|
2
|
+
import { MikeError } from "./native-work.js";
|
|
3
|
+
function value(node, yaml) {
|
|
4
|
+
if (!yaml.isScalar(node))
|
|
5
|
+
throw new MikeError("expected a scalar value");
|
|
6
|
+
const result = node.value;
|
|
7
|
+
if (result == null)
|
|
8
|
+
return null;
|
|
9
|
+
if (typeof result === "string" && node.tag && !node.tag.startsWith("tag:yaml.org,2002:")) {
|
|
10
|
+
if (/^[+-]?[0-9]+$/u.test(result))
|
|
11
|
+
return BigInt(result);
|
|
12
|
+
if (/^[+-]?0[xX][0-9a-fA-F]+$/u.test(result)) {
|
|
13
|
+
if (result[0] === "+" || result[0] === "-")
|
|
14
|
+
throw new MikeError(`strconv.ParseInt: parsing ${JSON.stringify(result)}: invalid syntax`);
|
|
15
|
+
return BigInt(result);
|
|
16
|
+
}
|
|
17
|
+
if (/^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/u.test(result))
|
|
18
|
+
return Number(result);
|
|
19
|
+
}
|
|
20
|
+
if (typeof result === "string" && node.tag === "tag:yaml.org,2002:int") {
|
|
21
|
+
try {
|
|
22
|
+
return BigInt(result);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw new MikeError(`invalid integer value ${JSON.stringify(result)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (typeof result === "string" && node.tag === "tag:yaml.org,2002:float")
|
|
29
|
+
return Number(result);
|
|
30
|
+
if (typeof result === "string" && node.tag === "tag:yaml.org,2002:bool")
|
|
31
|
+
return result.toLowerCase() === "true";
|
|
32
|
+
if (["string", "number", "bigint", "boolean"].includes(typeof result))
|
|
33
|
+
return result;
|
|
34
|
+
throw new MikeError("unsupported scalar value");
|
|
35
|
+
}
|
|
36
|
+
function scalarText(node, yaml) {
|
|
37
|
+
if (!yaml.isScalar(node))
|
|
38
|
+
throw new MikeError("expected a scalar value");
|
|
39
|
+
return node.source ?? String(node.value);
|
|
40
|
+
}
|
|
41
|
+
export class Evaluator {
|
|
42
|
+
yaml;
|
|
43
|
+
work;
|
|
44
|
+
mergeSpec;
|
|
45
|
+
#warnedMerge = false;
|
|
46
|
+
constructor(yaml, work, mergeSpec = false) {
|
|
47
|
+
this.yaml = yaml;
|
|
48
|
+
this.work = work;
|
|
49
|
+
this.mergeSpec = mergeSpec;
|
|
50
|
+
}
|
|
51
|
+
async match(first, pattern) {
|
|
52
|
+
await this.work.tick(first.length + pattern.length);
|
|
53
|
+
const name = Buffer.from(first);
|
|
54
|
+
const glob = Buffer.from(pattern);
|
|
55
|
+
let nameIndex = 0;
|
|
56
|
+
let patternIndex = 0;
|
|
57
|
+
let restartPattern = 0;
|
|
58
|
+
let restartName = 0;
|
|
59
|
+
while (patternIndex < glob.length || nameIndex < name.length) {
|
|
60
|
+
await this.work.tick();
|
|
61
|
+
if (patternIndex < glob.length) {
|
|
62
|
+
const character = glob[patternIndex];
|
|
63
|
+
if (character === 42) {
|
|
64
|
+
restartPattern = patternIndex;
|
|
65
|
+
restartName = nameIndex + 1;
|
|
66
|
+
patternIndex++;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (nameIndex < name.length && (character === 63 || character === name[nameIndex])) {
|
|
70
|
+
patternIndex++;
|
|
71
|
+
nameIndex++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (restartName > 0 && restartName <= name.length) {
|
|
76
|
+
patternIndex = restartPattern;
|
|
77
|
+
nameIndex = restartName;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
child(node, parent, collection, slot) {
|
|
85
|
+
this.work.node();
|
|
86
|
+
return { node, document: parent.document, ...(collection === undefined ? {} : { parent: collection, slot: slot }) };
|
|
87
|
+
}
|
|
88
|
+
async entries(input, depth = 0) {
|
|
89
|
+
this.work.depth(depth);
|
|
90
|
+
await this.work.tick();
|
|
91
|
+
const base = dereference(input, this.yaml, this.work);
|
|
92
|
+
const entries = new Map();
|
|
93
|
+
if (!this.yaml.isMap(base.node))
|
|
94
|
+
return entries;
|
|
95
|
+
const node = base.node;
|
|
96
|
+
const isMerge = (key) => this.yaml.isScalar(key) && (key.tag === "tag:yaml.org,2002:merge" || key.value === "<<" && key.type === "PLAIN");
|
|
97
|
+
const merge = async (incoming) => {
|
|
98
|
+
const source = dereference(this.child(incoming, base), this.yaml, this.work);
|
|
99
|
+
const values = this.yaml.isSeq(source.node) ? source.node.items : [source.node];
|
|
100
|
+
for (let index = 0; index < values.length; index++) {
|
|
101
|
+
const selected = values[this.mergeSpec ? values.length - 1 - index : index];
|
|
102
|
+
if (!this.yaml.isNode(selected))
|
|
103
|
+
continue;
|
|
104
|
+
for (const [key, child] of await this.entries(this.child(selected, source), depth + 1)) {
|
|
105
|
+
await this.work.tick();
|
|
106
|
+
entries.set(key, child);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
if (this.mergeSpec)
|
|
111
|
+
for (let index = node.items.length - 1; index >= 0; index--) {
|
|
112
|
+
const pair = node.items[index];
|
|
113
|
+
await this.work.tick();
|
|
114
|
+
if (isMerge(pair.key) && this.yaml.isNode(pair.value))
|
|
115
|
+
await merge(pair.value);
|
|
116
|
+
}
|
|
117
|
+
for (const [slot, pair] of node.items.entries()) {
|
|
118
|
+
await this.work.tick();
|
|
119
|
+
if (isMerge(pair.key)) {
|
|
120
|
+
if (!this.mergeSpec) {
|
|
121
|
+
if (!this.#warnedMerge) {
|
|
122
|
+
this.#warnedMerge = true;
|
|
123
|
+
const now = new Date();
|
|
124
|
+
const offset = now.getTimezoneOffset();
|
|
125
|
+
const local = new Date(now.getTime() - offset * 60_000).toISOString().slice(0, -1);
|
|
126
|
+
const zone = offset === 0 ? "Z" : `${offset < 0 ? "+" : "-"}${String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0")}:${String(Math.abs(offset) % 60).padStart(2, "0")}`;
|
|
127
|
+
await this.work.write(Buffer.from(`time=${local}${zone} level=WARN msg="--yaml-fix-merge-anchor-to-spec is false; causing merge anchors to override the existing values which isn't to the yaml spec. This flag will default to true in late 2025. See https://mikefarah.gitbook.io/yq/operators/traverse-read for more details."\n`), true);
|
|
128
|
+
}
|
|
129
|
+
if (this.yaml.isNode(pair.value))
|
|
130
|
+
await merge(pair.value);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (this.yaml.isScalar(pair.key) && this.yaml.isNode(pair.value))
|
|
134
|
+
entries.set(String(pair.key.value), this.child(pair.value, base, node, slot));
|
|
135
|
+
}
|
|
136
|
+
return entries;
|
|
137
|
+
}
|
|
138
|
+
async field(input, key, create, omitMissing = false) {
|
|
139
|
+
let base = dereference(input, this.yaml, this.work);
|
|
140
|
+
if (this.yaml.isScalar(base.node) && base.node.value == null && create) {
|
|
141
|
+
const collection = typeof key === "string" ? new this.yaml.YAMLMap() : new this.yaml.YAMLSeq();
|
|
142
|
+
await replace(base, collection, this.yaml, this.work);
|
|
143
|
+
}
|
|
144
|
+
base = dereference(base, this.yaml, this.work);
|
|
145
|
+
const node = base.node;
|
|
146
|
+
if (this.yaml.isMap(node)) {
|
|
147
|
+
if (key === "<<")
|
|
148
|
+
for (let slot = node.items.length - 1; slot >= 0; slot--) {
|
|
149
|
+
await this.work.tick();
|
|
150
|
+
const pair = node.items[slot];
|
|
151
|
+
if (this.yaml.isScalar(pair.key) && String(pair.key.value) === String(key))
|
|
152
|
+
return [this.child(pair.value, base, node, slot)];
|
|
153
|
+
}
|
|
154
|
+
const existing = (await this.entries(base)).get(String(key));
|
|
155
|
+
if (existing)
|
|
156
|
+
return [existing];
|
|
157
|
+
if (create) {
|
|
158
|
+
this.work.node(2);
|
|
159
|
+
if (!node.items.length)
|
|
160
|
+
node.flow = false;
|
|
161
|
+
node.items.push(new this.yaml.Pair(new this.yaml.Scalar(key), new this.yaml.Scalar(null)));
|
|
162
|
+
return [this.child(node.items.at(-1).value, base, node, node.items.length - 1)];
|
|
163
|
+
}
|
|
164
|
+
return omitMissing ? [] : [this.child(scalar(this.yaml, this.work, null), base)];
|
|
165
|
+
}
|
|
166
|
+
if (this.yaml.isSeq(node)) {
|
|
167
|
+
let index = Number(key);
|
|
168
|
+
if (!Number.isSafeInteger(index))
|
|
169
|
+
throw new MikeError(`cannot index array with '${String(key)}' (strconv.ParseInt: parsing ${JSON.stringify(String(key))}: invalid syntax)`);
|
|
170
|
+
if (index < 0)
|
|
171
|
+
index += node.items.length;
|
|
172
|
+
if (index < 0)
|
|
173
|
+
throw new MikeError(`index [${String(key)}] out of range, array size is ${node.items.length}`);
|
|
174
|
+
if (index >= node.items.length) {
|
|
175
|
+
if (index >= this.work.limits.maxNodes)
|
|
176
|
+
throw new MikeError("yq limit exceeded: maxNodes");
|
|
177
|
+
if (!node.items.length)
|
|
178
|
+
node.flow = false;
|
|
179
|
+
while (node.items.length <= index) {
|
|
180
|
+
node.items.push(scalar(this.yaml, this.work, null));
|
|
181
|
+
await this.work.tick();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return [index < node.items.length ? this.child(node.items[index], base, node, index) : this.child(scalar(this.yaml, this.work, null), base)];
|
|
185
|
+
}
|
|
186
|
+
return !omitMissing && this.yaml.isScalar(node) && node.value == null ? [this.child(scalar(this.yaml, this.work, null), base)] : [];
|
|
187
|
+
}
|
|
188
|
+
async binary(operator, left, right) {
|
|
189
|
+
await this.work.tick();
|
|
190
|
+
const yaml = this.yaml;
|
|
191
|
+
if (operator === "+" && nodeTag(left, yaml) === "!!null")
|
|
192
|
+
return cloneNode(right, yaml, this.work);
|
|
193
|
+
if ((operator === "*" || operator === "+") && yaml.isMap(left) && yaml.isMap(right)) {
|
|
194
|
+
const output = await cloneNode(left, yaml, this.work);
|
|
195
|
+
for (const pair of right.items) {
|
|
196
|
+
const key = yaml.isScalar(pair.key) ? String(pair.key.value) : "";
|
|
197
|
+
const existing = output.items.find(item => yaml.isScalar(item.key) && String(item.key.value) === key);
|
|
198
|
+
if (existing)
|
|
199
|
+
existing.value = operator === "*" && yaml.isMap(existing.value) && yaml.isMap(pair.value)
|
|
200
|
+
? await this.binary("*", existing.value, pair.value) : await cloneNode(pair.value, yaml, this.work);
|
|
201
|
+
else
|
|
202
|
+
output.items.push(new yaml.Pair(await cloneNode(pair.key, yaml, this.work), await cloneNode(pair.value, yaml, this.work)));
|
|
203
|
+
}
|
|
204
|
+
return output;
|
|
205
|
+
}
|
|
206
|
+
if (operator === "+" && yaml.isSeq(left)) {
|
|
207
|
+
const result = await cloneNode(left, yaml, this.work);
|
|
208
|
+
if (!result.items.length)
|
|
209
|
+
result.flow = false;
|
|
210
|
+
const members = yaml.isSeq(right) ? right.items : nodeTag(right, yaml) === "!!null" ? [] : [right];
|
|
211
|
+
for (const node of members)
|
|
212
|
+
result.items.push(await cloneNode(node, yaml, this.work));
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
if (operator === "==" || operator === "!=") {
|
|
216
|
+
let equal = false;
|
|
217
|
+
if (nodeTag(left, yaml) === "!!null")
|
|
218
|
+
equal = nodeTag(right, yaml) === "!!null";
|
|
219
|
+
else if (yaml.isScalar(left) && yaml.isScalar(right)) {
|
|
220
|
+
const first = scalarText(left, yaml);
|
|
221
|
+
const second = scalarText(right, yaml);
|
|
222
|
+
equal = await this.match(first, second);
|
|
223
|
+
}
|
|
224
|
+
return scalar(yaml, this.work, operator === "==" ? equal : !equal);
|
|
225
|
+
}
|
|
226
|
+
const first = value(left, yaml);
|
|
227
|
+
const second = value(right, yaml);
|
|
228
|
+
if (operator === "+" && (typeof first === "string" || typeof second === "string")) {
|
|
229
|
+
const text = scalarText(left, yaml) + (typeof first === "string" && second === null ? "" : scalarText(right, yaml));
|
|
230
|
+
const result = scalar(yaml, this.work, text);
|
|
231
|
+
if (yaml.isScalar(result) && yaml.isScalar(left) && left.type !== undefined)
|
|
232
|
+
result.type = left.type;
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
if ([">", "<", ">=", "<="].includes(operator)) {
|
|
236
|
+
if (first === null || second === null)
|
|
237
|
+
return scalar(yaml, this.work, false);
|
|
238
|
+
return scalar(yaml, this.work, operator === ">" ? first > second : operator === "<" ? first < second : operator === ">=" ? first >= second : first <= second);
|
|
239
|
+
}
|
|
240
|
+
if ((typeof first !== "number" && typeof first !== "bigint") || (typeof second !== "number" && typeof second !== "bigint"))
|
|
241
|
+
throw new MikeError(`cannot ${operator} ${nodeTag(left, yaml)} with ${nodeTag(right, yaml)}`);
|
|
242
|
+
if (typeof first === "bigint" && typeof second === "bigint" && operator !== "/") {
|
|
243
|
+
if (first !== BigInt.asIntN(64, first) || second !== BigInt.asIntN(64, second))
|
|
244
|
+
throw new MikeError("integer arithmetic operand is outside int64 range");
|
|
245
|
+
if (operator === "+") {
|
|
246
|
+
const sum = BigInt.asIntN(64, first + second);
|
|
247
|
+
const result = await cloneNode(left, yaml, this.work);
|
|
248
|
+
if (yaml.isScalar(result)) {
|
|
249
|
+
result.value = sum;
|
|
250
|
+
result.source = sum.toString();
|
|
251
|
+
const spelling = scalarText(left, yaml);
|
|
252
|
+
if (spelling.startsWith("0x") || spelling.startsWith("0X")) {
|
|
253
|
+
result.format = "HEX";
|
|
254
|
+
result.source = `0x${sum.toString(16).toUpperCase()}`;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
if (operator === "-")
|
|
260
|
+
return scalar(yaml, this.work, BigInt.asIntN(64, first - second));
|
|
261
|
+
if (operator === "*")
|
|
262
|
+
return scalar(yaml, this.work, BigInt.asIntN(64, first * second));
|
|
263
|
+
if (operator === "%" && second !== 0n)
|
|
264
|
+
return scalar(yaml, this.work, first % second);
|
|
265
|
+
}
|
|
266
|
+
const firstNumber = Number(first);
|
|
267
|
+
const secondNumber = Number(second);
|
|
268
|
+
return scalar(yaml, this.work, operator === "+" ? firstNumber + secondNumber : operator === "-" ? firstNumber - secondNumber : operator === "*" ? firstNumber * secondNumber : operator === "/" ? firstNumber / secondNumber : firstNumber % secondNumber);
|
|
269
|
+
}
|
|
270
|
+
async run(expression, inputs, create = false, depth = 0, omitMissing = false) {
|
|
271
|
+
this.work.depth(depth);
|
|
272
|
+
await this.work.tick();
|
|
273
|
+
const next = (body, values = inputs, writable = create, readOnly = omitMissing) => this.run(body, values, writable, depth + 1, readOnly);
|
|
274
|
+
const yaml = this.yaml;
|
|
275
|
+
if (expression.kind === "identity")
|
|
276
|
+
return inputs;
|
|
277
|
+
if (expression.kind === "group")
|
|
278
|
+
return next(expression.body);
|
|
279
|
+
if (expression.kind === "literal")
|
|
280
|
+
return inputs.map(input => this.child(scalar(yaml, this.work, expression.value), input));
|
|
281
|
+
if (expression.kind === "field") {
|
|
282
|
+
const output = [];
|
|
283
|
+
for (const base of await next(expression.base))
|
|
284
|
+
for (const key of await next(expression.key, [base], false))
|
|
285
|
+
output.push(...await this.field(base, value(key.node, yaml), create, omitMissing));
|
|
286
|
+
return output;
|
|
287
|
+
}
|
|
288
|
+
if (expression.kind === "slice") {
|
|
289
|
+
const output = [];
|
|
290
|
+
for (const input of await next(expression.base)) {
|
|
291
|
+
const base = dereference(input, yaml, this.work);
|
|
292
|
+
const index = async (bound) => {
|
|
293
|
+
const matches = await next(bound, [base], false);
|
|
294
|
+
if (matches.length !== 1)
|
|
295
|
+
throw new MikeError(`expected to find 1 number, got ${matches.length} instead`);
|
|
296
|
+
const text = String(value(matches[0].node, yaml));
|
|
297
|
+
if (!/^[+-]?[0-9]+$/u.test(text))
|
|
298
|
+
throw new MikeError(`strconv.ParseInt: parsing ${JSON.stringify(text)}: invalid syntax`);
|
|
299
|
+
const result = BigInt(text);
|
|
300
|
+
if (result !== BigInt.asIntN(64, result))
|
|
301
|
+
throw new MikeError(`strconv.ParseInt: parsing ${JSON.stringify(text)}: value out of range`);
|
|
302
|
+
return result;
|
|
303
|
+
};
|
|
304
|
+
const start = await index(expression.start);
|
|
305
|
+
const end = await index(expression.end);
|
|
306
|
+
const clamp = (offset, length) => {
|
|
307
|
+
const relative = offset < 0n ? offset + BigInt(length) : offset;
|
|
308
|
+
return relative < 0n ? 0 : relative > BigInt(length) ? length : Number(relative);
|
|
309
|
+
};
|
|
310
|
+
if (yaml.isScalar(base.node) && typeof base.node.value === "string") {
|
|
311
|
+
let length = 0;
|
|
312
|
+
for (const character of base.node.value) {
|
|
313
|
+
await this.work.tick(character.length);
|
|
314
|
+
length++;
|
|
315
|
+
}
|
|
316
|
+
const first = clamp(start, length);
|
|
317
|
+
const last = clamp(end, length);
|
|
318
|
+
const selected = [];
|
|
319
|
+
let position = 0;
|
|
320
|
+
for (const character of base.node.value) {
|
|
321
|
+
await this.work.tick(character.length);
|
|
322
|
+
if (position >= first && position < last)
|
|
323
|
+
selected.push(character);
|
|
324
|
+
position++;
|
|
325
|
+
}
|
|
326
|
+
const node = await cloneNode(base.node, yaml, this.work);
|
|
327
|
+
if (yaml.isScalar(node)) {
|
|
328
|
+
node.value = selected.join("");
|
|
329
|
+
node.source = node.value;
|
|
330
|
+
}
|
|
331
|
+
output.push(this.child(node, base));
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
const members = [];
|
|
335
|
+
if (yaml.isSeq(base.node))
|
|
336
|
+
for (const member of base.node.items) {
|
|
337
|
+
await this.work.tick();
|
|
338
|
+
members.push(member);
|
|
339
|
+
}
|
|
340
|
+
else if (yaml.isMap(base.node))
|
|
341
|
+
for (const pair of base.node.items) {
|
|
342
|
+
await this.work.tick();
|
|
343
|
+
members.push(pair.key, pair.value);
|
|
344
|
+
}
|
|
345
|
+
this.work.node();
|
|
346
|
+
const node = new yaml.YAMLSeq();
|
|
347
|
+
if (base.node.tag || !yaml.isSeq(base.node))
|
|
348
|
+
node.tag = base.node.tag ?? `tag:yaml.org,2002:${nodeTag(base.node, yaml).slice(2)}`;
|
|
349
|
+
for (let position = clamp(start, members.length); position < clamp(end, members.length); position++)
|
|
350
|
+
node.items.push(await cloneNode(members[position], yaml, this.work));
|
|
351
|
+
output.push(this.child(node, base));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return output;
|
|
355
|
+
}
|
|
356
|
+
if (expression.kind === "iterate" || expression.kind === "recursive") {
|
|
357
|
+
const output = [];
|
|
358
|
+
for (const input of inputs) {
|
|
359
|
+
const base = dereference(input, yaml, this.work);
|
|
360
|
+
if (expression.kind === "recursive")
|
|
361
|
+
output.push(input);
|
|
362
|
+
const children = [];
|
|
363
|
+
if (yaml.isMap(base.node)) {
|
|
364
|
+
if (expression.kind === "recursive")
|
|
365
|
+
base.node.items.forEach((pair, slot) => children.push(this.child(pair.value, base, base.node, slot)));
|
|
366
|
+
else
|
|
367
|
+
children.push(...(await this.entries(base)).values());
|
|
368
|
+
}
|
|
369
|
+
else if (yaml.isSeq(base.node))
|
|
370
|
+
base.node.items.forEach((node, slot) => children.push(this.child(node, base, base.node, slot)));
|
|
371
|
+
if (expression.kind === "recursive")
|
|
372
|
+
for (const child of children)
|
|
373
|
+
output.push(...await next(expression, [child]));
|
|
374
|
+
else
|
|
375
|
+
output.push(...children);
|
|
376
|
+
}
|
|
377
|
+
this.work.node(output.length);
|
|
378
|
+
return output;
|
|
379
|
+
}
|
|
380
|
+
if (expression.kind === "pipe")
|
|
381
|
+
return next(expression.right, await next(expression.left));
|
|
382
|
+
if (expression.kind === "array") {
|
|
383
|
+
if (!inputs.length)
|
|
384
|
+
return [];
|
|
385
|
+
this.work.node();
|
|
386
|
+
const node = new yaml.YAMLSeq();
|
|
387
|
+
if (expression.body)
|
|
388
|
+
for (const candidate of await next(expression.body, inputs, false))
|
|
389
|
+
node.items.push(await cloneNode(candidate.node, yaml, this.work));
|
|
390
|
+
return [this.child(node, inputs[0])];
|
|
391
|
+
}
|
|
392
|
+
if (expression.kind === "object") {
|
|
393
|
+
const output = [];
|
|
394
|
+
for (const input of inputs) {
|
|
395
|
+
this.work.node();
|
|
396
|
+
const node = new yaml.YAMLMap();
|
|
397
|
+
for (const field of expression.fields) {
|
|
398
|
+
const key = (await next(field.key, [input], false))[0];
|
|
399
|
+
const candidate = (await next(field.value, [input], false))[0];
|
|
400
|
+
if (key && candidate)
|
|
401
|
+
node.items.push(new yaml.Pair(await cloneNode(key.node, yaml, this.work), await cloneNode(candidate.node, yaml, this.work)));
|
|
402
|
+
}
|
|
403
|
+
output.push(this.child(node, input));
|
|
404
|
+
}
|
|
405
|
+
return output;
|
|
406
|
+
}
|
|
407
|
+
if (expression.kind === "binary") {
|
|
408
|
+
const operator = expression.operator;
|
|
409
|
+
if (operator === ",") {
|
|
410
|
+
const left = await next(expression.left);
|
|
411
|
+
const right = await next(expression.right);
|
|
412
|
+
this.work.node(left.length + right.length);
|
|
413
|
+
return [...left, ...right];
|
|
414
|
+
}
|
|
415
|
+
if (["=", "=c", "|=", "+=", "-=", "*=", "/="].includes(operator)) {
|
|
416
|
+
const attribute = expression.left.kind === "pipe" && expression.left.right.kind === "call" && ["tag", "style"].includes(expression.left.right.name) ? expression.left.right.name : undefined;
|
|
417
|
+
const lhs = attribute && expression.left.kind === "pipe" ? expression.left.left : expression.left;
|
|
418
|
+
const targets = await next(lhs, inputs, true);
|
|
419
|
+
const updates = operator === "|=" ? undefined : await next(expression.right, inputs, false, true);
|
|
420
|
+
for (const target of targets) {
|
|
421
|
+
const candidates = updates ?? (await next(expression.right, [target], false)).slice(0, 1);
|
|
422
|
+
for (const candidate of candidates) {
|
|
423
|
+
if (attribute) {
|
|
424
|
+
const text = String(value(candidate.node, yaml));
|
|
425
|
+
if (attribute === "tag") {
|
|
426
|
+
if (!target.node.tag || this.work.implicitTags.has(target.node))
|
|
427
|
+
this.work.implicitTags.add(target.node);
|
|
428
|
+
target.node.tag = text.startsWith("!!") ? `tag:yaml.org,2002:${text.slice(2)}` : text;
|
|
429
|
+
if (yaml.isScalar(target.node) && text === "!!str")
|
|
430
|
+
target.node.value = scalarText(target.node, yaml);
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
if (!["", "single", "double", "literal", "folded", "flow", "tagged"].includes(text))
|
|
434
|
+
throw new MikeError(`unknown style ${text}`);
|
|
435
|
+
if (yaml.isScalar(target.node))
|
|
436
|
+
target.node.type = text === "single" ? "QUOTE_SINGLE" : text === "double" ? "QUOTE_DOUBLE" : text === "literal" ? "BLOCK_LITERAL" : text === "folded" ? "BLOCK_FOLDED" : "PLAIN";
|
|
437
|
+
else if (yaml.isCollection(target.node))
|
|
438
|
+
target.node.flow = text === "flow";
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
const updated = operator.length === 2 && operator !== "|=" && operator !== "=c" ? await this.binary(operator[0], target.node, candidate.node) : candidate.node;
|
|
443
|
+
await replace(target, updated, yaml, this.work, operator === "=c");
|
|
444
|
+
if (operator === "=c")
|
|
445
|
+
target.node.tag = `tag:yaml.org,2002:${nodeTag(target.node, yaml).slice(2)}`;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return inputs.map(input => input.isDocumentRoot ? { ...input, node: input.document.doc.contents } : input);
|
|
450
|
+
}
|
|
451
|
+
const readOnly = omitMissing || ["+", "==", "!="].includes(operator);
|
|
452
|
+
const left = await next(expression.left, inputs, false, readOnly);
|
|
453
|
+
if (operator === "//") {
|
|
454
|
+
const matches = left.filter(candidate => truth(candidate.node, yaml));
|
|
455
|
+
return matches.length ? matches : next(expression.right, inputs, false);
|
|
456
|
+
}
|
|
457
|
+
const right = await next(expression.right, inputs, false, readOnly);
|
|
458
|
+
const output = [];
|
|
459
|
+
if (operator === "+" && (!left.length || !right.length))
|
|
460
|
+
return left.length ? left : right;
|
|
461
|
+
if ((operator === "==" || operator === "!=") && inputs.length && (!left.length || !right.length)) {
|
|
462
|
+
const candidates = left.length ? left : right.length ? right : [inputs[0]];
|
|
463
|
+
for (const candidate of candidates) {
|
|
464
|
+
const equal = !left.length && !right.length || nodeTag(candidate.node, yaml) === "!!null";
|
|
465
|
+
output.push(this.child(scalar(yaml, this.work, operator === "==" ? equal : !equal), candidate));
|
|
466
|
+
}
|
|
467
|
+
return output;
|
|
468
|
+
}
|
|
469
|
+
for (const first of left)
|
|
470
|
+
for (const second of right) {
|
|
471
|
+
const node = operator === "and" || operator === "or" ? scalar(yaml, this.work, operator === "and" ? truth(first.node, yaml) && truth(second.node, yaml) : truth(first.node, yaml) || truth(second.node, yaml)) : await this.binary(operator, first.node, second.node);
|
|
472
|
+
output.push(this.child(node, first));
|
|
473
|
+
}
|
|
474
|
+
return output;
|
|
475
|
+
}
|
|
476
|
+
if (expression.kind !== "call")
|
|
477
|
+
throw new MikeError("bad expression, please check expression syntax");
|
|
478
|
+
const output = [];
|
|
479
|
+
for (const input of inputs) {
|
|
480
|
+
const base = dereference(input, yaml, this.work);
|
|
481
|
+
const name = expression.name;
|
|
482
|
+
if (name === "select") {
|
|
483
|
+
if (!expression.args[0])
|
|
484
|
+
throw new MikeError("bad expression, please check expression syntax");
|
|
485
|
+
if ((await next(expression.args[0], [input], false)).some(candidate => truth(candidate.node, yaml)))
|
|
486
|
+
output.push(input);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (name === "map") {
|
|
490
|
+
const members = await next({ kind: "iterate" }, [input], false);
|
|
491
|
+
const node = new yaml.YAMLSeq();
|
|
492
|
+
this.work.node();
|
|
493
|
+
for (const member of members)
|
|
494
|
+
for (const result of await next(expression.args[0], [member], false))
|
|
495
|
+
node.items.push(await cloneNode(result.node, yaml, this.work));
|
|
496
|
+
output.push(this.child(node, input));
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
if (name === "del") {
|
|
500
|
+
for (const candidate of (await next(expression.args[0], [input], false)).reverse())
|
|
501
|
+
if (candidate.parent && candidate.slot !== undefined)
|
|
502
|
+
candidate.parent.items.splice(candidate.slot, 1);
|
|
503
|
+
output.push(input);
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (name === "env" || name === "strenv") {
|
|
507
|
+
const key = expression.args[0];
|
|
508
|
+
if (key?.kind !== "literal")
|
|
509
|
+
throw new MikeError("bad expression, please check expression syntax");
|
|
510
|
+
const text = this.work.context.env[String(key.value)] ?? "";
|
|
511
|
+
if (name === "strenv")
|
|
512
|
+
output.push(this.child(scalar(yaml, this.work, text), input));
|
|
513
|
+
else {
|
|
514
|
+
if (!text)
|
|
515
|
+
throw new MikeError(`value for env variable '${String(key.value)}' not provided in env()`);
|
|
516
|
+
const docs = await decodeDocuments(text, "<env>", 0, "yaml", yaml, this.work);
|
|
517
|
+
output.push(this.child(docs[0].doc.contents, input));
|
|
518
|
+
}
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
let result;
|
|
522
|
+
if (name === "tag" || name === "type")
|
|
523
|
+
result = nodeTag(base.node, yaml);
|
|
524
|
+
else if (name === "kind")
|
|
525
|
+
result = yaml.isMap(base.node) ? "map" : yaml.isSeq(base.node) ? "seq" : "scalar";
|
|
526
|
+
else if (name === "documentIndex" || name === "di")
|
|
527
|
+
result = BigInt(input.document.documentIndex);
|
|
528
|
+
else if (name === "fileIndex" || name === "fi")
|
|
529
|
+
result = BigInt(input.document.fileIndex);
|
|
530
|
+
else if (name === "filename")
|
|
531
|
+
result = input.document.filename;
|
|
532
|
+
else if (name === "not")
|
|
533
|
+
result = !truth(base.node, yaml);
|
|
534
|
+
else if (name === "length") {
|
|
535
|
+
let length = yaml.isCollection(base.node) ? base.node.items.length : 0;
|
|
536
|
+
if (yaml.isScalar(base.node) && nodeTag(base.node, yaml) !== "!!null") {
|
|
537
|
+
const text = scalarText(base.node, yaml);
|
|
538
|
+
await this.work.tick(text.length);
|
|
539
|
+
length = Buffer.byteLength(text);
|
|
540
|
+
}
|
|
541
|
+
result = BigInt(length);
|
|
542
|
+
}
|
|
543
|
+
else if (name === "has") {
|
|
544
|
+
const key = (await next(expression.args[0], [input], false))[0];
|
|
545
|
+
result = yaml.isMap(base.node) ? base.node.items.some(pair => yaml.isScalar(pair.key) && String(pair.key.value) === String(value(key.node, yaml))) : yaml.isSeq(base.node) && Number(value(key.node, yaml)) < base.node.items.length;
|
|
546
|
+
}
|
|
547
|
+
else if (name === "keys") {
|
|
548
|
+
const node = new yaml.YAMLSeq();
|
|
549
|
+
this.work.node();
|
|
550
|
+
if (yaml.isMap(base.node))
|
|
551
|
+
for (const pair of base.node.items)
|
|
552
|
+
node.items.push(await cloneNode(pair.key, yaml, this.work));
|
|
553
|
+
else if (yaml.isSeq(base.node))
|
|
554
|
+
base.node.items.forEach((_, index) => node.items.push(scalar(yaml, this.work, BigInt(index))));
|
|
555
|
+
output.push(this.child(node, input));
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
else if (name === "style")
|
|
559
|
+
result = yaml.isScalar(base.node) ? base.node.type === "QUOTE_SINGLE" ? "single" : base.node.type === "QUOTE_DOUBLE" ? "double" : base.node.type === "BLOCK_FOLDED" ? "folded" : base.node.type === "BLOCK_LITERAL" ? "literal" : "" : yaml.isCollection(base.node) && base.node.flow ? "flow" : "";
|
|
560
|
+
output.push(this.child(scalar(yaml, this.work, result), input));
|
|
561
|
+
}
|
|
562
|
+
return output;
|
|
563
|
+
}
|
|
564
|
+
}
|