@poe-platform/safe-bash 0.1.810 → 0.1.812
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audio-ast/flac-source.d.ts +13 -0
- package/dist/audio-ast/index.d.ts +2 -0
- package/dist/audio-ast/index.js +253 -179
- package/dist/audio-ast/vorbis.d.ts +14 -0
- package/dist/image-ast/index.js +1 -1
- package/dist/json-ast/backed-json-parser.d.ts +12 -1
- package/dist/json-ast/index.d.ts +1 -1
- package/dist/office-xml/index.d.ts +1 -0
- package/dist/office-xml/retained-xml-edits.d.ts +22 -0
- package/dist/pdf-ast/cos/qpdf-json-document.d.ts +2 -1
- package/dist/pdf-ast/cos/value-parser.d.ts +23 -2
- package/dist/pdf-ast/extract/retained-form-field-details.d.ts +20 -0
- package/dist/pdf-ast/extract/retained-form-fields.d.ts +17 -4
- package/dist/pdf-ast/index.d.ts +1 -0
- package/dist/pdf-ast/index.js +844 -384
- package/dist/pdf-ast/retained-document.d.ts +6 -0
- package/dist/safe-bash/audio-ast.browser.js +3 -1
- package/dist/safe-bash/chunks/{chunk-65TFMAZU.js → chunk-BUYRKFW2.js} +8 -35
- package/dist/safe-bash/chunks/{chunk-ZA5FQ34E.js → chunk-TPG55BAQ.js} +0 -2
- package/dist/safe-bash/command-chunks/{biff-ORSHM4YX-QYPGRDAZ.js → biff-YKPDH35C-MVQIWNKV.js} +2192 -2155
- package/dist/safe-bash/command-chunks/{chunk-HEHGHIE2.js → chunk-22MOB45U.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-6DEWZMOL.js → chunk-2CORNDGF.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-DCD32BEY.js → chunk-2JSDKQ4J.js} +201 -84
- package/dist/safe-bash/command-chunks/{chunk-6UHGIWFX.js → chunk-2ZFLMWOX.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-HONWGFDA.js → chunk-33YCKZZX.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-AXWPJRY6.js → chunk-36XGIPOG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-D5AYP2UM.js → chunk-3Q247UDJ.js} +26 -16
- package/dist/safe-bash/command-chunks/{chunk-32ADKP5E.js → chunk-456PHA3L.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-UJXP3T6R.js → chunk-4CKFNXRN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5L6GHFRW.js → chunk-554Z6IKP.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-ORZRWT62.js → chunk-56NYSX65.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-53JP3S6H.js → chunk-5HPU7D36.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-HARUYHH7.js → chunk-5HUICAWD.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IC5GJI7E.js → chunk-5Q22ZLNC.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-YO3V5RLY.js → chunk-6CCQI6XZ.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-EO2IVGV7.js → chunk-6M6TM5Z5.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-Z54Z3KRN.js → chunk-6QBMND4A.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-INX4JMQ6.js → chunk-6VPQ3CDZ.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-VGXVN3BX.js → chunk-7GKKMNL6.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-TZJC67W3.js → chunk-7PVHO47B.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-CM3C7AXJ.js → chunk-A2CLZMQZ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ASR27KHW.js → chunk-A5FZBR7X.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DMDHE5KC.js → chunk-AHA6IWAJ.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-PTZ55XXN.js → chunk-APEWTWCC.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-YUVH6CE4.js → chunk-ATTWQVR2.js} +17 -17
- package/dist/safe-bash/command-chunks/{chunk-2VCKUNDZ.js → chunk-B2C3UPJS.js} +27 -17
- package/dist/safe-bash/command-chunks/{chunk-JON5DB3Z.js → chunk-B5LDP7AA.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-YTFWPJ3F.js → chunk-CJQSAATC.js} +26 -26
- package/dist/safe-bash/command-chunks/{chunk-CHJL6JMU.js → chunk-COKYZUBW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KCTV4NVX.js → chunk-CRV2Q3PB.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-V3WXPCKN.js → chunk-CV7M2QJU.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-VPDSQPSN.js → chunk-DM2CPMB4.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-3DTDMEOP.js → chunk-EAGIJ4VW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-JW6CMBF2.js → chunk-EHSM5ZQS.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-WIOH7ZQN.js → chunk-ENT3IV2G.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-5IE4LJGB.js → chunk-EUT24Y5Z.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-WC2OCF4H.js → chunk-FDCIPJBQ.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-COKZFXHG.js → chunk-FIIAYCWS.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-MWVFP2HY.js → chunk-GEM47B2P.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-EHL6B34L.js → chunk-HDJVJTCK.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-JMM3MNAY.js → chunk-HKATEVAP.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-VWY3EAVQ.js → chunk-HTVIYLVB.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-CHR2OD2U.js → chunk-HWQ2UHMT.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-Z4QJMDK3.js → chunk-IT7TAC3F.js} +16 -16
- package/dist/safe-bash/command-chunks/{chunk-EWS4KYJE.js → chunk-JFYWVQ4V.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-ZCX63QWA.js → chunk-JOCFI7TG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-F5WTH4O4.js → chunk-JQVHUSDD.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-O4VJEGL6.js → chunk-K5GB2YMN.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-27C3NT5V.js → chunk-KB7DUBVL.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-4DZ32PI7.js → chunk-KCOJA7EM.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-CAXJ4RLF.js → chunk-KJ4XXZIL.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-U6QHTC5J.js → chunk-L5MCW6CM.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-LVL3A7YE.js → chunk-LCZDBW55.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-DJVRDUCA.js → chunk-LXLLA4PM.js} +17 -17
- package/dist/safe-bash/command-chunks/{chunk-K7AGAS3K.js → chunk-M7QE2MN7.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-SWT6ILF2.js → chunk-MPUHH2KR.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-3ZWBBS6U.js → chunk-NARD63DY.js} +437 -34
- package/dist/safe-bash/command-chunks/{chunk-DC3OJLRB.js → chunk-NQDIT667.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-LWZVDDJA.js → chunk-NUGQQDGE.js} +5 -1
- package/dist/safe-bash/command-chunks/{chunk-MFLQZLFR.js → chunk-OA75SGN2.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-5LATYOF7.js → chunk-OEJM666F.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-AF25YYIO.js → chunk-PMAM4N33.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-KMMAJ6H6.js → chunk-PNGDJA6M.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-62BHPSKJ.js → chunk-Q6S57NOQ.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-KJ3PEDI2.js → chunk-Q73EMLLZ.js} +146 -4
- package/dist/safe-bash/command-chunks/{chunk-FXKBM5KJ.js → chunk-QC5RMGSA.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-UQ6UIZMM.js → chunk-QD7ZRDUN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-JHUYZZGV.js → chunk-QYMEASQ6.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-3GY5VDIX.js → chunk-QZZ73J2O.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-S2CYIGWH.js → chunk-R6EGGK5M.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-7AVN3OBH.js → chunk-RHYJVTJO.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-EWGDSO6U.js → chunk-RID6VYS3.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-MMBRBANA.js → chunk-RNSKXOG3.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-D3ZRZTY5.js → chunk-RQIQ75W5.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-DWKQPLRT.js → chunk-RRL3Y562.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-NXCMXD74.js → chunk-S6R3IB36.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XUPKFHAQ.js → chunk-SDTPO2VV.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-PIAGKRFW.js → chunk-SPLOIABU.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-Z5QOVRVH.js → chunk-SU26FZLJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-WLTJDNSQ.js → chunk-TVH4JORU.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-6XVMWFHD.js → chunk-TW73OXPR.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-SFO43CID.js → chunk-UAXSE3XE.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-K35BSUHO.js → chunk-UYWSIIUX.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-2E2YEDVB.js → chunk-W5YSINXC.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-EYNT4OEJ.js → chunk-WGG6G2KG.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-DVQBZXMQ.js → chunk-WJCN2IXI.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-XBZ4ZWGL.js → chunk-WVMHRNXZ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-7GXUCQI4.js → chunk-WXRYDALR.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-S4IIOSRA.js → chunk-X7FA7ZD5.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-DPR5CYQV.js → chunk-XITDDJFT.js} +2 -0
- package/dist/safe-bash/command-chunks/{chunk-SFCERNHU.js → chunk-XPD636C4.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-HYDWQLJ3.js → chunk-XRVKWGVQ.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-ZEPDT6I5.js → chunk-XVLWZTPY.js} +249 -51
- package/dist/safe-bash/command-chunks/{chunk-3UJWHRK4.js → chunk-XVP6V5K3.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-KTI3BULE.js → chunk-XZ2FWFNV.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-QK3CHRGL.js → chunk-Y4EYCZFT.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-GTWVMFBK.js → chunk-YORJDX4V.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-H6F5SN2N.js → chunk-YSMNXMAO.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-SE5SJ4JT.js → chunk-Z2JW6M2D.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-WH3TIOTS.js → chunk-ZEGNRZV2.js} +9 -2
- package/dist/safe-bash/command-chunks/{chunk-BYZUOF6X.js → chunk-ZEX53S5I.js} +4010 -3980
- package/dist/safe-bash/command-chunks/{chunk-HQYFRQ5W.js → chunk-ZIIO6GRY.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-NTRZMQZP.js → chunk-ZMHEGDU2.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-EYBXHGA6.js → chunk-ZXR6LXV5.js} +2 -2
- package/dist/safe-bash/command-chunks/{command-engine-BEWABZ75.js → command-engine-BCUQGJJ4.js} +58 -21
- package/dist/safe-bash/command-chunks/{engine-MEPOXIXT-WZMRHACG.js → engine-LAUEWYSQ-DQCEI5HE.js} +1 -1
- package/dist/safe-bash/command-chunks/pdf-XHHFTOT4-UJJYOYJ2.js +573 -0
- package/dist/safe-bash/commands/diff-patch/index.js +0 -3
- package/dist/safe-bash/commands/diff3/index.js +0 -2
- package/dist/safe-bash/full-core.browser.js +2 -2
- package/dist/safe-bash/plugins/index.browser.js +2 -2
- package/dist/safe-bash/plugins/index.js +3 -1
- package/dist/safe-bash/plugins/portable-commands.d.ts +1 -1
- package/dist/safe-bash/plugins/portable-commands.js +5 -3
- package/dist/safe-bash/registry-entry.browser.js +1 -1
- package/dist/safe-bash-command-apply-patch/apply.js +4 -4
- package/dist/safe-bash-command-apply-patch/index.js +4 -4
- package/dist/safe-bash-command-apply-patch/matcher.js +2 -2
- package/dist/safe-bash-command-apply-patch/parser.js +2 -2
- package/dist/safe-bash-command-apply-patch/shared.d.ts +2 -0
- package/dist/safe-bash-command-apply-patch/shared.js +1 -1
- package/dist/safe-bash-command-diff/index.js +0 -2
- package/dist/safe-bash-command-diff3/index.js +830 -56
- package/dist/safe-bash-command-ffmpeg/index.js +1 -1
- package/dist/safe-bash-command-ffprobe/index.js +2 -2
- package/dist/safe-bash-command-ffprobe/media.js +2 -2
- package/dist/safe-bash-command-html-to-markdown/index.js +75 -21
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/execution.d.ts +2 -2
- package/dist/safe-bash-command-pandoc/index.d.ts +1 -1
- package/dist/safe-bash-command-pandoc/index.js +14 -14
- package/dist/safe-bash-command-pandoc/lua-filters.js +2 -2
- package/dist/safe-bash-command-pandoc/types.d.ts +17 -2
- package/dist/safe-bash-command-patch/index.js +2 -2
- package/dist/safe-bash-command-patch/patch-publication.js +1 -1
- package/dist/safe-bash-command-patch/patch.js +2 -2
- package/dist/safe-bash-command-pdftk/index.js +649 -265
- package/dist/safe-bash-command-pptx/command-engine.d.ts +12 -3
- package/dist/safe-bash-command-pptx/engine.d.ts +2 -2
- package/dist/safe-bash-command-pptx/engine.js +1 -1
- package/dist/safe-bash-command-qpdf/index.js +115 -9
- package/dist/safe-bash-command-soffice/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +2 -2
- package/dist/safe-bash-command-xq/index.js +45 -29
- package/dist/safe-bash-diff-engine/document.d.ts +2 -1
- package/dist/safe-bash-diff-engine/document.js +7 -4
- package/dist/safe-bash-presentation-engine/accessibility.js +30 -30
- package/dist/safe-bash-presentation-engine/animation-editing.js +15 -15
- package/dist/safe-bash-presentation-engine/animations.js +15 -15
- package/dist/safe-bash-presentation-engine/backgrounds.js +16 -16
- package/dist/safe-bash-presentation-engine/bytes.js +3 -3
- package/dist/safe-bash-presentation-engine/chart-editing.js +33 -33
- package/dist/safe-bash-presentation-engine/chart-object-operations.js +24 -24
- package/dist/safe-bash-presentation-engine/charts.js +30 -30
- package/dist/safe-bash-presentation-engine/command-placeholder.js +56 -55
- package/dist/safe-bash-presentation-engine/comments.js +16 -16
- package/dist/safe-bash-presentation-engine/connector-operations.js +31 -31
- package/dist/safe-bash-presentation-engine/connectors.js +28 -28
- package/dist/safe-bash-presentation-engine/content-types.js +4 -4
- package/dist/safe-bash-presentation-engine/creation.js +6 -6
- package/dist/safe-bash-presentation-engine/diff.js +31 -31
- package/dist/safe-bash-presentation-engine/drawing-format.js +19 -19
- package/dist/safe-bash-presentation-engine/drawing-operations.js +30 -30
- package/dist/safe-bash-presentation-engine/drawing-schema.js +20 -20
- package/dist/safe-bash-presentation-engine/equations.js +16 -16
- package/dist/safe-bash-presentation-engine/errors.js +2 -2
- package/dist/safe-bash-presentation-engine/fields.js +16 -16
- package/dist/safe-bash-presentation-engine/font-metrics.js +3 -3
- package/dist/safe-bash-presentation-engine/image-extraction.js +19 -19
- package/dist/safe-bash-presentation-engine/image-formatting.js +31 -31
- package/dist/safe-bash-presentation-engine/image-insertion.js +17 -17
- package/dist/safe-bash-presentation-engine/image-replacement.js +20 -20
- package/dist/safe-bash-presentation-engine/image-value.js +4 -4
- package/dist/safe-bash-presentation-engine/images.js +18 -18
- package/dist/safe-bash-presentation-engine/index.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/index.js +99 -95
- package/dist/safe-bash-presentation-engine/layouts.js +15 -15
- package/dist/safe-bash-presentation-engine/length.js +3 -3
- package/dist/safe-bash-presentation-engine/links.js +15 -15
- package/dist/safe-bash-presentation-engine/masters.js +14 -14
- package/dist/safe-bash-presentation-engine/media-editing.js +23 -23
- package/dist/safe-bash-presentation-engine/media-extraction.js +16 -16
- package/dist/safe-bash-presentation-engine/media.js +15 -15
- package/dist/safe-bash-presentation-engine/memberships.js +14 -14
- package/dist/safe-bash-presentation-engine/notes.js +15 -15
- package/dist/safe-bash-presentation-engine/ole-enum.js +4 -4
- package/dist/safe-bash-presentation-engine/ole-insertion.js +19 -19
- package/dist/safe-bash-presentation-engine/opaque-objects.js +9 -9
- package/dist/safe-bash-presentation-engine/package-reader.js +5 -5
- package/dist/safe-bash-presentation-engine/package-tools.js +15 -15
- package/dist/safe-bash-presentation-engine/package-uri.js +3 -3
- package/dist/safe-bash-presentation-engine/package-writer.js +4 -4
- package/dist/safe-bash-presentation-engine/presentation-model.js +55 -54
- package/dist/safe-bash-presentation-engine/presentation-settings.js +13 -13
- package/dist/safe-bash-presentation-engine/properties.js +15 -15
- package/dist/safe-bash-presentation-engine/relationships.js +4 -4
- package/dist/safe-bash-presentation-engine/resource-limits.js +1 -1
- package/dist/safe-bash-presentation-engine/retained-inspection.js +12 -12
- package/dist/safe-bash-presentation-engine/retained-package.js +4 -4
- package/dist/safe-bash-presentation-engine/retained-slide-publication.d.ts +24 -0
- package/dist/safe-bash-presentation-engine/retained-slide-settings.d.ts +15 -0
- package/dist/safe-bash-presentation-engine/retained-text.js +17 -17
- package/dist/safe-bash-presentation-engine/sanitize.js +16 -16
- package/dist/safe-bash-presentation-engine/selectors.js +10 -10
- package/dist/safe-bash-presentation-engine/shape-groups.js +30 -30
- package/dist/safe-bash-presentation-engine/shape-operations.js +29 -29
- package/dist/safe-bash-presentation-engine/shape-path-operations.js +31 -31
- package/dist/safe-bash-presentation-engine/shape-paths.js +15 -15
- package/dist/safe-bash-presentation-engine/shape-presets.js +3 -3
- package/dist/safe-bash-presentation-engine/shape-selection.js +30 -30
- package/dist/safe-bash-presentation-engine/shape-transforms.js +17 -17
- package/dist/safe-bash-presentation-engine/shapes.js +26 -26
- package/dist/safe-bash-presentation-engine/slide-copy.js +16 -16
- package/dist/safe-bash-presentation-engine/slide-import.js +17 -17
- package/dist/safe-bash-presentation-engine/slide-merge-split.js +19 -19
- package/dist/safe-bash-presentation-engine/slide-model.js +42 -42
- package/dist/safe-bash-presentation-engine/slide-removal.js +17 -17
- package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +9 -9
- package/dist/safe-bash-presentation-engine/slides.d.ts +3 -0
- package/dist/safe-bash-presentation-engine/slides.js +24 -16
- package/dist/safe-bash-presentation-engine/table-operations.js +32 -32
- package/dist/safe-bash-presentation-engine/table-spans.js +31 -31
- package/dist/safe-bash-presentation-engine/tables.js +30 -30
- package/dist/safe-bash-presentation-engine/tags.js +15 -15
- package/dist/safe-bash-presentation-engine/template-bindings.js +32 -32
- package/dist/safe-bash-presentation-engine/template-repeat.js +39 -39
- package/dist/safe-bash-presentation-engine/text-fitting.js +26 -26
- package/dist/safe-bash-presentation-engine/text-frames.js +26 -26
- package/dist/safe-bash-presentation-engine/text-paragraphs.js +26 -26
- package/dist/safe-bash-presentation-engine/text-reading.js +11 -11
- package/dist/safe-bash-presentation-engine/text-replacement.js +16 -16
- package/dist/safe-bash-presentation-engine/text-runs.js +19 -19
- package/dist/safe-bash-presentation-engine/themes.js +15 -15
- package/dist/safe-bash-presentation-engine/transitions.js +15 -15
- package/dist/safe-bash-presentation-engine/validation.js +9 -9
- package/dist/safe-bash-presentation-engine/xml-parts.js +15 -15
- package/dist/safe-bash-presentation-engine/xml-view.js +3 -3
- package/dist/safe-bash-presentation-engine/xml.js +3 -3
- package/dist/safe-bash-xml-engine/json.d.ts +1 -0
- package/dist/safe-bash-xml-engine/json.js +203 -0
- package/dist/safe-bash-xml-engine/stored-json.d.ts +5 -0
- package/dist/spreadsheet-engine/rendering/print/bidi-runs.d.ts +5 -0
- package/dist/spreadsheet-engine/rendering/print/bidi-runs.js +35 -0
- package/dist/spreadsheet-engine/rendering/print/control-bidi.d.ts +8 -0
- package/dist/spreadsheet-engine/rendering/print/control-bidi.js +80 -0
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +4 -4
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +76 -30
- package/dist/spreadsheet-format-xls/biff-encryption.js +1 -1
- package/dist/spreadsheet-format-xls/biff-metadata.d.ts +1 -0
- package/dist/spreadsheet-format-xls/biff-metadata.js +2 -2
- package/dist/spreadsheet-format-xls/biff-property-bytes.d.ts +4 -1
- package/dist/spreadsheet-format-xls/biff-property-bytes.js +1 -1
- package/dist/spreadsheet-format-xls/biff-range.js +1 -1
- package/dist/spreadsheet-format-xls/biff-write-metadata.js +10 -1
- package/package.json +5 -2
- package/dist/safe-bash/command-chunks/pdf-LOZAXXS6-ERI57IAV.js +0 -557
|
@@ -961,7 +961,785 @@ function compareDiff3(inputs, invocation, limits = diff3DefaultLimits, signal) {
|
|
|
961
961
|
}
|
|
962
962
|
|
|
963
963
|
// packages/safe-bash-command-diff3/src/command.ts
|
|
964
|
-
import {
|
|
964
|
+
import { resolvePath } from "../safe-bash-contracts/index.js";
|
|
965
|
+
import { Budget as ReadBudget, inspect, ToolError } from "../safe-bash-diff-engine/shared.js";
|
|
966
|
+
|
|
967
|
+
// packages/safe-bash-command-diff3/src/stored.ts
|
|
968
|
+
import { PagedStorage } from "@poe-platform/safe-fs/storage";
|
|
969
|
+
import { IndexedDocument, closeDocumentResources } from "../safe-bash-diff-engine/document.js";
|
|
970
|
+
import { monotonicNow, yieldTurn } from "../safe-bash-contracts/yield.js";
|
|
971
|
+
var StoredWork = class extends Budget {
|
|
972
|
+
constructor(context, behaviorLimits, charge, retain) {
|
|
973
|
+
super(behaviorLimits, context.signal);
|
|
974
|
+
this.context = context;
|
|
975
|
+
this.behaviorLimits = behaviorLimits;
|
|
976
|
+
this.charge = charge;
|
|
977
|
+
this.retain = retain;
|
|
978
|
+
this.storage = new PagedStorage(context, 8);
|
|
979
|
+
this.resources.push(this.storage);
|
|
980
|
+
}
|
|
981
|
+
context;
|
|
982
|
+
behaviorLimits;
|
|
983
|
+
charge;
|
|
984
|
+
retain;
|
|
985
|
+
storage;
|
|
986
|
+
resources = [];
|
|
987
|
+
nextYield = 4096;
|
|
988
|
+
nextTime = 0;
|
|
989
|
+
reserved = false;
|
|
990
|
+
admit(resource, amount) {
|
|
991
|
+
if (resource === "work") this.charge?.(amount);
|
|
992
|
+
super.admit(resource, amount);
|
|
993
|
+
}
|
|
994
|
+
step(amount = 1) {
|
|
995
|
+
this.admit("work", amount);
|
|
996
|
+
}
|
|
997
|
+
checkpoint() {
|
|
998
|
+
this.context.signal.throwIfAborted();
|
|
999
|
+
if (this.work < this.nextYield) return;
|
|
1000
|
+
this.nextYield = this.work + 4096;
|
|
1001
|
+
const now = monotonicNow();
|
|
1002
|
+
if (now < this.nextTime) return;
|
|
1003
|
+
this.nextTime = now + 16;
|
|
1004
|
+
return yieldTurn(this.context.signal);
|
|
1005
|
+
}
|
|
1006
|
+
reserve() {
|
|
1007
|
+
if (this.reserved) return;
|
|
1008
|
+
this.retain?.(1024 * 1024);
|
|
1009
|
+
this.admit("retainedBytes", 1024 * 1024);
|
|
1010
|
+
this.reserved = true;
|
|
1011
|
+
}
|
|
1012
|
+
async load(source) {
|
|
1013
|
+
const document = new IndexedDocument(this, 2);
|
|
1014
|
+
this.resources.push(document);
|
|
1015
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
1016
|
+
try {
|
|
1017
|
+
const first = await iterator.next();
|
|
1018
|
+
if (!first.done) {
|
|
1019
|
+
this.reserve();
|
|
1020
|
+
await document.load({ async *[Symbol.asyncIterator]() {
|
|
1021
|
+
yield first.value;
|
|
1022
|
+
for (; ; ) {
|
|
1023
|
+
const next = await iterator.next();
|
|
1024
|
+
if (next.done) break;
|
|
1025
|
+
yield next.value;
|
|
1026
|
+
}
|
|
1027
|
+
} });
|
|
1028
|
+
}
|
|
1029
|
+
} finally {
|
|
1030
|
+
await iterator.return?.();
|
|
1031
|
+
}
|
|
1032
|
+
this.admit("tokens", document.length);
|
|
1033
|
+
return document;
|
|
1034
|
+
}
|
|
1035
|
+
output() {
|
|
1036
|
+
const output = new StoredOutput(this);
|
|
1037
|
+
this.resources.push(output);
|
|
1038
|
+
return output;
|
|
1039
|
+
}
|
|
1040
|
+
async close() {
|
|
1041
|
+
try {
|
|
1042
|
+
await closeDocumentResources(this.resources);
|
|
1043
|
+
} finally {
|
|
1044
|
+
this.dispose();
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
var Numbers = class _Numbers {
|
|
1049
|
+
constructor(work, length, position) {
|
|
1050
|
+
this.work = work;
|
|
1051
|
+
this.length = length;
|
|
1052
|
+
this.position = position ?? work.storage.allocate(length * 8);
|
|
1053
|
+
}
|
|
1054
|
+
work;
|
|
1055
|
+
length;
|
|
1056
|
+
position;
|
|
1057
|
+
async get(index) {
|
|
1058
|
+
if (index < 0 || index >= this.length) return 0;
|
|
1059
|
+
const checkpoint = this.work.checkpoint();
|
|
1060
|
+
if (checkpoint) await checkpoint;
|
|
1061
|
+
const bytes = await this.work.storage.read(this.position + index * 8, 8);
|
|
1062
|
+
return new DataView(bytes.buffer, bytes.byteOffset, 8).getFloat64(0, true);
|
|
1063
|
+
}
|
|
1064
|
+
async set(index, value) {
|
|
1065
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= this.length) throw new RangeError("Diff3 vector index");
|
|
1066
|
+
const bytes = new Uint8Array(8);
|
|
1067
|
+
new DataView(bytes.buffer).setFloat64(0, value, true);
|
|
1068
|
+
await this.work.storage.write(this.position + index * 8, bytes);
|
|
1069
|
+
const checkpoint = this.work.checkpoint();
|
|
1070
|
+
if (checkpoint) await checkpoint;
|
|
1071
|
+
}
|
|
1072
|
+
slice(start, end) {
|
|
1073
|
+
return new _Numbers(this.work, end - start, this.position + start * 8);
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
var Edits = class {
|
|
1077
|
+
length = 0;
|
|
1078
|
+
cells;
|
|
1079
|
+
constructor(work, capacity) {
|
|
1080
|
+
this.cells = new Numbers(work, capacity * 4);
|
|
1081
|
+
}
|
|
1082
|
+
async push(edit) {
|
|
1083
|
+
const values = [edit.base.start, edit.base.end, edit.variant.start, edit.variant.end];
|
|
1084
|
+
for (let i = 0; i < 4; i++) await this.cells.set(this.length * 4 + i, values[i]);
|
|
1085
|
+
this.length++;
|
|
1086
|
+
}
|
|
1087
|
+
async get(index) {
|
|
1088
|
+
if (index >= this.length) return void 0;
|
|
1089
|
+
return {
|
|
1090
|
+
base: { start: await this.cells.get(index * 4), end: await this.cells.get(index * 4 + 1) },
|
|
1091
|
+
variant: { start: await this.cells.get(index * 4 + 2), end: await this.cells.get(index * 4 + 3) }
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
async *[Symbol.asyncIterator]() {
|
|
1095
|
+
for (let index = 0; index < this.length; index++) yield await this.get(index);
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
var kinds = ["left", "right", "identical", "adjacent", "conflict"];
|
|
1099
|
+
var Regions = class {
|
|
1100
|
+
length = 0;
|
|
1101
|
+
cells;
|
|
1102
|
+
constructor(work, capacity) {
|
|
1103
|
+
this.cells = new Numbers(work, capacity * 7);
|
|
1104
|
+
}
|
|
1105
|
+
async push(region) {
|
|
1106
|
+
const values = [kinds.indexOf(region.kind), region.base.start, region.base.end, region.left.start, region.left.end, region.right.start, region.right.end];
|
|
1107
|
+
for (let i = 0; i < 7; i++) await this.cells.set(this.length * 7 + i, values[i]);
|
|
1108
|
+
this.length++;
|
|
1109
|
+
}
|
|
1110
|
+
async *iterate(reverse) {
|
|
1111
|
+
for (let i = 0; i < this.length; i++) {
|
|
1112
|
+
const offset2 = (reverse ? this.length - i - 1 : i) * 7;
|
|
1113
|
+
yield {
|
|
1114
|
+
kind: kinds[await this.cells.get(offset2)],
|
|
1115
|
+
base: { start: await this.cells.get(offset2 + 1), end: await this.cells.get(offset2 + 2) },
|
|
1116
|
+
left: { start: await this.cells.get(offset2 + 3), end: await this.cells.get(offset2 + 4) },
|
|
1117
|
+
right: { start: await this.cells.get(offset2 + 5), end: await this.cells.get(offset2 + 6) }
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
async function storedLine(document, index) {
|
|
1123
|
+
const line = await document.line(index);
|
|
1124
|
+
const last = await document.data.read(8 + line.end - 1, 1);
|
|
1125
|
+
return { document, start: line.start, end: line.end, terminated: last[0] === 10 };
|
|
1126
|
+
}
|
|
1127
|
+
async function bodyEnd(line, options) {
|
|
1128
|
+
const end = line.end - Number(line.terminated);
|
|
1129
|
+
if (options.stripTrailingCR && line.terminated && end > line.start && (await line.document.data.read(8 + end - 1, 1))[0] === 13) return end - 1;
|
|
1130
|
+
return end;
|
|
1131
|
+
}
|
|
1132
|
+
async function equalStoredLines(a, b, options, work) {
|
|
1133
|
+
work.step();
|
|
1134
|
+
const endA = await bodyEnd(a, options), endB = await bodyEnd(b, options);
|
|
1135
|
+
if (a.terminated !== b.terminated || endA - a.start !== endB - b.start) return false;
|
|
1136
|
+
for (let offset2 = 0; offset2 < endA - a.start; offset2 += 16384) {
|
|
1137
|
+
const size = Math.min(16384, endA - a.start - offset2);
|
|
1138
|
+
const left = await a.document.data.read(8 + a.start + offset2, size), right = await b.document.data.read(8 + b.start + offset2, size);
|
|
1139
|
+
work.step(size);
|
|
1140
|
+
for (let i = 0; i < size; i++) if (left[i] !== right[i]) return false;
|
|
1141
|
+
const checkpoint = work.checkpoint();
|
|
1142
|
+
if (checkpoint) await checkpoint;
|
|
1143
|
+
}
|
|
1144
|
+
return true;
|
|
1145
|
+
}
|
|
1146
|
+
var StoredOutput = class {
|
|
1147
|
+
constructor(work) {
|
|
1148
|
+
this.work = work;
|
|
1149
|
+
this.data = new PagedStorage(work.context, 2);
|
|
1150
|
+
}
|
|
1151
|
+
work;
|
|
1152
|
+
data;
|
|
1153
|
+
size = 0;
|
|
1154
|
+
async append(bytes) {
|
|
1155
|
+
if (bytes.length) this.work.reserve();
|
|
1156
|
+
await this.data.append(bytes);
|
|
1157
|
+
this.size += bytes.length;
|
|
1158
|
+
const checkpoint = this.work.checkpoint();
|
|
1159
|
+
if (checkpoint) await checkpoint;
|
|
1160
|
+
}
|
|
1161
|
+
async *bytes() {
|
|
1162
|
+
for (let offset2 = 0; offset2 < this.size; offset2 += 16384) yield await this.data.read(8 + offset2, Math.min(16384, this.size - offset2));
|
|
1163
|
+
}
|
|
1164
|
+
close() {
|
|
1165
|
+
return this.data.close();
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
// packages/safe-bash-command-diff3/src/stored-alignment.ts
|
|
1170
|
+
import { IntegerTable } from "@poe-platform/safe-fs/storage";
|
|
1171
|
+
async function equivalences2(files, options, work) {
|
|
1172
|
+
const buckets = new IntegerTable(work.storage, 256);
|
|
1173
|
+
const count = files.reduce((sum, file) => sum + file.length, 0);
|
|
1174
|
+
const records = new Numbers(work, count * 4);
|
|
1175
|
+
let next = 1;
|
|
1176
|
+
const result = [];
|
|
1177
|
+
for (let file = 0; file < files.length; file++) {
|
|
1178
|
+
const document = files[file], keys = new Numbers(work, document.length);
|
|
1179
|
+
result.push(keys);
|
|
1180
|
+
for (let index = 0; index < document.length; index++) {
|
|
1181
|
+
const line = await storedLine(document, index), end = await bodyEnd(line, options);
|
|
1182
|
+
let hash = line.terminated ? 2166136261 : 2166136260;
|
|
1183
|
+
for await (const bytes of document.range(line.start, end)) {
|
|
1184
|
+
for (const byte of bytes) hash = Math.imul(hash ^ byte, 16777619) >>> 0;
|
|
1185
|
+
}
|
|
1186
|
+
const bucket = BigInt(hash), head = Number(await buckets.get(bucket) ?? 0n);
|
|
1187
|
+
let match = 0;
|
|
1188
|
+
for (let key = head; key; key = await records.get((key - 1) * 4 + 3)) {
|
|
1189
|
+
const offset2 = (key - 1) * 4;
|
|
1190
|
+
if (hash !== await records.get(offset2)) continue;
|
|
1191
|
+
const other = await storedLine(files[await records.get(offset2 + 1)], await records.get(offset2 + 2));
|
|
1192
|
+
if (await equalStoredLines(line, other, options, work)) {
|
|
1193
|
+
match = key;
|
|
1194
|
+
break;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
if (!match) {
|
|
1198
|
+
match = next++;
|
|
1199
|
+
const values = [hash, file, index, head];
|
|
1200
|
+
for (let i = 0; i < 4; i++) await records.set((match - 1) * 4 + i, values[i]);
|
|
1201
|
+
await buckets.set(bucket, BigInt(match));
|
|
1202
|
+
}
|
|
1203
|
+
await keys.set(index, match);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
return result;
|
|
1207
|
+
}
|
|
1208
|
+
async function alignStoredPair(base, variant, options, work) {
|
|
1209
|
+
const total = base.length + variant.length, previousCells = work.graphCells;
|
|
1210
|
+
const edits = new Edits(work, total);
|
|
1211
|
+
try {
|
|
1212
|
+
if (total > 1073741823) throw new Diff3Error("LIMIT", "Signed edit graph index limit exceeded", "graphCells");
|
|
1213
|
+
work.admit("graphCells", 24 * total + 16);
|
|
1214
|
+
work.step(total);
|
|
1215
|
+
if (total === 0) return edits;
|
|
1216
|
+
const [allA, allB] = await equivalences2([variant, base], options, work);
|
|
1217
|
+
let prefix = 0, suffix = 0;
|
|
1218
|
+
while (prefix < Math.min(allA.length, allB.length) && await allA.get(prefix) === await allB.get(prefix)) {
|
|
1219
|
+
work.step();
|
|
1220
|
+
prefix++;
|
|
1221
|
+
}
|
|
1222
|
+
if (prefix === allA.length && prefix === allB.length) return edits;
|
|
1223
|
+
while (suffix < Math.min(allA.length, allB.length) - prefix && await allA.get(allA.length - suffix - 1) === await allB.get(allB.length - suffix - 1)) {
|
|
1224
|
+
work.step();
|
|
1225
|
+
suffix++;
|
|
1226
|
+
}
|
|
1227
|
+
const low = Math.max(0, prefix - 100), highA = Math.min(allA.length, allA.length - suffix + 100), highB = Math.min(allB.length, allB.length - suffix + 100);
|
|
1228
|
+
const keys = [allA.slice(low, highA), allB.slice(low, highB)];
|
|
1229
|
+
const changed = keys.map((list) => new Numbers(work, list.length + 1));
|
|
1230
|
+
const [a, b] = await discard2(keys, changed, total, work);
|
|
1231
|
+
const width = a.length + b.length + 3, origin = b.length + 1;
|
|
1232
|
+
const forward = new Numbers(work, width), backward = new Numbers(work, width);
|
|
1233
|
+
const pending = new Numbers(work, (total + 1) * 4);
|
|
1234
|
+
let pendingLength = 0;
|
|
1235
|
+
const push = async (x0, x1, y0, y1) => {
|
|
1236
|
+
for (const value of [x0, x1, y0, y1]) await pending.set(pendingLength++, value);
|
|
1237
|
+
};
|
|
1238
|
+
await push(0, a.length, 0, b.length);
|
|
1239
|
+
while (pendingLength) {
|
|
1240
|
+
work.step();
|
|
1241
|
+
const yEnd = await pending.get(--pendingLength), yStart = await pending.get(--pendingLength);
|
|
1242
|
+
const xEnd = await pending.get(--pendingLength), xStart = await pending.get(--pendingLength);
|
|
1243
|
+
let x0 = xStart, x1 = xEnd, y0 = yStart, y1 = yEnd;
|
|
1244
|
+
while (x0 < x1 && y0 < y1 && await a.keys.get(x0) === await b.keys.get(y0)) {
|
|
1245
|
+
work.step();
|
|
1246
|
+
x0++;
|
|
1247
|
+
y0++;
|
|
1248
|
+
}
|
|
1249
|
+
while (x0 < x1 && y0 < y1 && await a.keys.get(x1 - 1) === await b.keys.get(y1 - 1)) {
|
|
1250
|
+
work.step();
|
|
1251
|
+
x1--;
|
|
1252
|
+
y1--;
|
|
1253
|
+
}
|
|
1254
|
+
if (x0 === x1 || y0 === y1) {
|
|
1255
|
+
for (let x3 = x0; x3 < x1; x3++) {
|
|
1256
|
+
work.step();
|
|
1257
|
+
await changed[0].set(await a.indices.get(x3), 1);
|
|
1258
|
+
}
|
|
1259
|
+
for (let y3 = y0; y3 < y1; y3++) {
|
|
1260
|
+
work.step();
|
|
1261
|
+
await changed[1].set(await b.indices.get(y3), 1);
|
|
1262
|
+
}
|
|
1263
|
+
continue;
|
|
1264
|
+
}
|
|
1265
|
+
const [x2, y2] = await midpoint2(x0, x1, y0, y1, a, b, forward, backward, origin, work);
|
|
1266
|
+
if (x2 === x0 && y2 === y0 || x2 === x1 && y2 === y1) throw new Diff3Error("ALIGNMENT", "Non-progressing comparison partition");
|
|
1267
|
+
await push(x2, x1, y2, y1);
|
|
1268
|
+
await push(x0, x2, y0, y2);
|
|
1269
|
+
}
|
|
1270
|
+
await shift2(keys, changed, work);
|
|
1271
|
+
let x = 0, y = 0;
|
|
1272
|
+
while (x < keys[0].length || y < keys[1].length) {
|
|
1273
|
+
work.step();
|
|
1274
|
+
if (await changed[0].get(x) || await changed[1].get(y)) {
|
|
1275
|
+
const startX = x, startY = y;
|
|
1276
|
+
while (await changed[0].get(x)) {
|
|
1277
|
+
work.step();
|
|
1278
|
+
x++;
|
|
1279
|
+
}
|
|
1280
|
+
while (await changed[1].get(y)) {
|
|
1281
|
+
work.step();
|
|
1282
|
+
y++;
|
|
1283
|
+
}
|
|
1284
|
+
work.admit("graphCells", 4);
|
|
1285
|
+
await edits.push({ base: { start: low + startY, end: low + y }, variant: { start: low + startX, end: low + x } });
|
|
1286
|
+
} else {
|
|
1287
|
+
x++;
|
|
1288
|
+
y++;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
return edits;
|
|
1292
|
+
} finally {
|
|
1293
|
+
work.graphCells = previousCells + edits.length * 4;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
async function discard2(keys, changed, total, work) {
|
|
1297
|
+
const counts = keys.map(() => new Numbers(work, total + 1));
|
|
1298
|
+
for (let file = 0; file < 2; file++) {
|
|
1299
|
+
for (let i = 0; i < keys[file].length; i++) {
|
|
1300
|
+
work.step();
|
|
1301
|
+
const key = await keys[file].get(i);
|
|
1302
|
+
await counts[file].set(key, await counts[file].get(key) + 1);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
const results = [];
|
|
1306
|
+
for (let file = 0; file < 2; file++) {
|
|
1307
|
+
const list = keys[file], marks = new Numbers(work, list.length);
|
|
1308
|
+
const threshold = 5 * 2 ** Math.max(0, Math.floor(Math.log2(Math.max(1, list.length)) / 2) - 3);
|
|
1309
|
+
for (let i = 0; i < list.length; i++) {
|
|
1310
|
+
work.step();
|
|
1311
|
+
const count = await counts[1 - file].get(await list.get(i));
|
|
1312
|
+
await marks.set(i, count === 0 ? 1 : count > threshold ? 2 : 0);
|
|
1313
|
+
}
|
|
1314
|
+
for (let start = 0; start < marks.length; ) {
|
|
1315
|
+
work.step();
|
|
1316
|
+
if (await marks.get(start) !== 1) {
|
|
1317
|
+
if (await marks.get(start) === 2) await marks.set(start, 0);
|
|
1318
|
+
start++;
|
|
1319
|
+
continue;
|
|
1320
|
+
}
|
|
1321
|
+
let end = start + 1;
|
|
1322
|
+
while (end < marks.length && await marks.get(end) !== 0) {
|
|
1323
|
+
work.step();
|
|
1324
|
+
end++;
|
|
1325
|
+
}
|
|
1326
|
+
while (await marks.get(end - 1) === 2) {
|
|
1327
|
+
work.step();
|
|
1328
|
+
await marks.set(--end, 0);
|
|
1329
|
+
}
|
|
1330
|
+
let provisional = 0;
|
|
1331
|
+
for (let i = start; i < end; i++) {
|
|
1332
|
+
work.step();
|
|
1333
|
+
provisional += Number(await marks.get(i) === 2);
|
|
1334
|
+
}
|
|
1335
|
+
const length = end - start;
|
|
1336
|
+
if (provisional > Math.floor(length / 4)) {
|
|
1337
|
+
for (let i = start; i < end; i++) {
|
|
1338
|
+
work.step();
|
|
1339
|
+
if (await marks.get(i) === 2) await marks.set(i, 0);
|
|
1340
|
+
}
|
|
1341
|
+
} else {
|
|
1342
|
+
const minimum = length < 4 ? 2 : 2 ** (Math.floor(Math.log2(length) / 2) - 1) + 1;
|
|
1343
|
+
for (let i = start; i < end; ) {
|
|
1344
|
+
work.step();
|
|
1345
|
+
if (await marks.get(i) !== 2) {
|
|
1346
|
+
i++;
|
|
1347
|
+
continue;
|
|
1348
|
+
}
|
|
1349
|
+
let j = i + 1;
|
|
1350
|
+
while (j < end && await marks.get(j) === 2) {
|
|
1351
|
+
work.step();
|
|
1352
|
+
j++;
|
|
1353
|
+
}
|
|
1354
|
+
if (j - i >= minimum) for (let k = i; k < j; k++) {
|
|
1355
|
+
work.step();
|
|
1356
|
+
await marks.set(k, 0);
|
|
1357
|
+
}
|
|
1358
|
+
i = j;
|
|
1359
|
+
}
|
|
1360
|
+
for (const direction of [1, -1]) {
|
|
1361
|
+
let consecutive = 0;
|
|
1362
|
+
for (let distance = 0; distance < length; distance++) {
|
|
1363
|
+
work.step();
|
|
1364
|
+
const i = direction === 1 ? start + distance : end - distance - 1;
|
|
1365
|
+
if (distance >= 8 && await marks.get(i) === 1) break;
|
|
1366
|
+
if (await marks.get(i) === 2) {
|
|
1367
|
+
await marks.set(i, 0);
|
|
1368
|
+
consecutive = 0;
|
|
1369
|
+
} else consecutive = await marks.get(i) === 1 ? consecutive + 1 : 0;
|
|
1370
|
+
if (consecutive === 3) break;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
start = end;
|
|
1375
|
+
}
|
|
1376
|
+
const result = { keys: new Numbers(work, list.length), indices: new Numbers(work, list.length), length: 0 };
|
|
1377
|
+
for (let index = 0; index < list.length; index++) {
|
|
1378
|
+
work.step();
|
|
1379
|
+
if (await marks.get(index)) await changed[file].set(index, 1);
|
|
1380
|
+
else {
|
|
1381
|
+
await result.keys.set(result.length, await list.get(index));
|
|
1382
|
+
await result.indices.set(result.length, index);
|
|
1383
|
+
result.length++;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
results.push(result);
|
|
1387
|
+
}
|
|
1388
|
+
return results;
|
|
1389
|
+
}
|
|
1390
|
+
async function midpoint2(x0, x1, y0, y1, a, b, f, r, origin, work) {
|
|
1391
|
+
const first = x0 - y0, last = x1 - y1, min = x0 - y1, max = x1 - y0;
|
|
1392
|
+
let fLow = first, fHigh = first, rLow = last, rHigh = last;
|
|
1393
|
+
await f.set(origin + first, x0);
|
|
1394
|
+
await r.set(origin + last, x1);
|
|
1395
|
+
const odd = (first - last) % 2 !== 0;
|
|
1396
|
+
for (; ; ) {
|
|
1397
|
+
work.step();
|
|
1398
|
+
if (fLow > min) {
|
|
1399
|
+
fLow--;
|
|
1400
|
+
await f.set(origin + fLow - 1, -1);
|
|
1401
|
+
} else fLow++;
|
|
1402
|
+
if (fHigh < max) {
|
|
1403
|
+
fHigh++;
|
|
1404
|
+
await f.set(origin + fHigh + 1, -1);
|
|
1405
|
+
} else fHigh--;
|
|
1406
|
+
for (let diagonal = fHigh; diagonal >= fLow; diagonal -= 2) {
|
|
1407
|
+
work.step();
|
|
1408
|
+
const left = await f.get(origin + diagonal - 1), right = await f.get(origin + diagonal + 1);
|
|
1409
|
+
let x = left < right ? right : left + 1, y = x - diagonal;
|
|
1410
|
+
while (x < x1 && y < y1 && await a.keys.get(x) === await b.keys.get(y)) {
|
|
1411
|
+
work.step();
|
|
1412
|
+
x++;
|
|
1413
|
+
y++;
|
|
1414
|
+
}
|
|
1415
|
+
await f.set(origin + diagonal, x);
|
|
1416
|
+
if (odd && diagonal >= rLow && diagonal <= rHigh && await r.get(origin + diagonal) <= x) return [x, y];
|
|
1417
|
+
}
|
|
1418
|
+
if (rLow > min) {
|
|
1419
|
+
rLow--;
|
|
1420
|
+
await r.set(origin + rLow - 1, 2147483647);
|
|
1421
|
+
} else rLow++;
|
|
1422
|
+
if (rHigh < max) {
|
|
1423
|
+
rHigh++;
|
|
1424
|
+
await r.set(origin + rHigh + 1, 2147483647);
|
|
1425
|
+
} else rHigh--;
|
|
1426
|
+
for (let diagonal = rHigh; diagonal >= rLow; diagonal -= 2) {
|
|
1427
|
+
work.step();
|
|
1428
|
+
const left = await r.get(origin + diagonal - 1), right = await r.get(origin + diagonal + 1);
|
|
1429
|
+
let x = left < right ? left : right - 1, y = x - diagonal;
|
|
1430
|
+
while (x > x0 && y > y0 && await a.keys.get(x - 1) === await b.keys.get(y - 1)) {
|
|
1431
|
+
work.step();
|
|
1432
|
+
x--;
|
|
1433
|
+
y--;
|
|
1434
|
+
}
|
|
1435
|
+
await r.set(origin + diagonal, x);
|
|
1436
|
+
if (!odd && diagonal >= fLow && diagonal <= fHigh && x <= await f.get(origin + diagonal)) return [x, y];
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
async function shift2(keys, changed, work) {
|
|
1441
|
+
for (let file = 0; file < 2; file++) {
|
|
1442
|
+
const list = keys[file], own = changed[file], other = changed[1 - file];
|
|
1443
|
+
let i = 0, j = 0;
|
|
1444
|
+
while (i < list.length) {
|
|
1445
|
+
work.step();
|
|
1446
|
+
if (!await own.get(i)) {
|
|
1447
|
+
while (await other.get(j)) {
|
|
1448
|
+
work.step();
|
|
1449
|
+
j++;
|
|
1450
|
+
}
|
|
1451
|
+
i++;
|
|
1452
|
+
j++;
|
|
1453
|
+
continue;
|
|
1454
|
+
}
|
|
1455
|
+
let start = i;
|
|
1456
|
+
while (await own.get(i)) {
|
|
1457
|
+
work.step();
|
|
1458
|
+
i++;
|
|
1459
|
+
}
|
|
1460
|
+
while (await other.get(j)) {
|
|
1461
|
+
work.step();
|
|
1462
|
+
j++;
|
|
1463
|
+
}
|
|
1464
|
+
let corresponding, length;
|
|
1465
|
+
do {
|
|
1466
|
+
work.step();
|
|
1467
|
+
length = i - start;
|
|
1468
|
+
while (start > 0 && await list.get(start - 1) === await list.get(i - 1)) {
|
|
1469
|
+
work.step();
|
|
1470
|
+
await own.set(--start, 1);
|
|
1471
|
+
await own.set(--i, 0);
|
|
1472
|
+
while (start > 0 && await own.get(start - 1)) {
|
|
1473
|
+
work.step();
|
|
1474
|
+
start--;
|
|
1475
|
+
}
|
|
1476
|
+
do {
|
|
1477
|
+
work.step();
|
|
1478
|
+
j--;
|
|
1479
|
+
} while (j >= 0 && await other.get(j));
|
|
1480
|
+
}
|
|
1481
|
+
corresponding = await other.get(j - 1) ? i : list.length;
|
|
1482
|
+
while (i < list.length && await list.get(start) === await list.get(i)) {
|
|
1483
|
+
work.step();
|
|
1484
|
+
await own.set(start++, 0);
|
|
1485
|
+
await own.set(i++, 1);
|
|
1486
|
+
while (await own.get(i)) {
|
|
1487
|
+
work.step();
|
|
1488
|
+
i++;
|
|
1489
|
+
}
|
|
1490
|
+
do {
|
|
1491
|
+
work.step();
|
|
1492
|
+
j++;
|
|
1493
|
+
if (await other.get(j)) corresponding = i;
|
|
1494
|
+
} while (await other.get(j));
|
|
1495
|
+
}
|
|
1496
|
+
} while (length !== i - start);
|
|
1497
|
+
while (corresponding < i) {
|
|
1498
|
+
work.step();
|
|
1499
|
+
await own.set(--start, 1);
|
|
1500
|
+
await own.set(--i, 0);
|
|
1501
|
+
do {
|
|
1502
|
+
work.step();
|
|
1503
|
+
j--;
|
|
1504
|
+
} while (j >= 0 && await other.get(j));
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
// packages/safe-bash-command-diff3/src/stored-regions.ts
|
|
1511
|
+
async function alignStoredRegions(files, left, right, options, budget) {
|
|
1512
|
+
const streams = [left, right], offsets = [0, 0], delta = [0, 0], result = new Regions(budget, left.length + right.length);
|
|
1513
|
+
while (offsets[0] < left.length || offsets[1] < right.length) {
|
|
1514
|
+
budget.admit("work", 1);
|
|
1515
|
+
const nextLeft = await left.get(offsets[0]), nextRight = await right.get(offsets[1]);
|
|
1516
|
+
const firstSide = nextRight === void 0 || nextLeft !== void 0 && nextLeft.base.start <= nextRight.base.start ? 0 : 1;
|
|
1517
|
+
const first = await streams[firstSide].get(offsets[firstSide]);
|
|
1518
|
+
const start = first.base.start;
|
|
1519
|
+
let end = first.base.end;
|
|
1520
|
+
const initialDelta = [...delta], seen = [false, false];
|
|
1521
|
+
let overlap = false;
|
|
1522
|
+
const last = [void 0, void 0];
|
|
1523
|
+
for (; ; ) {
|
|
1524
|
+
budget.admit("work", 1);
|
|
1525
|
+
const a = await left.get(offsets[0]), b = await right.get(offsets[1]);
|
|
1526
|
+
const side = b === void 0 || a !== void 0 && a.base.start <= b.base.start ? 0 : 1;
|
|
1527
|
+
const edit = await streams[side].get(offsets[side]);
|
|
1528
|
+
if (!edit || edit.base.start > end) break;
|
|
1529
|
+
const other = last[1 - side];
|
|
1530
|
+
if (other) {
|
|
1531
|
+
const aEmpty = edit.base.start === edit.base.end, bEmpty = other.start === other.end;
|
|
1532
|
+
overlap ||= aEmpty && bEmpty ? edit.base.start === other.start : aEmpty ? edit.base.start > other.start && edit.base.start < other.end : bEmpty ? other.start > edit.base.start && other.start < edit.base.end : edit.base.start < other.end && other.start < edit.base.end;
|
|
1533
|
+
}
|
|
1534
|
+
last[side] = edit.base;
|
|
1535
|
+
seen[side] = true;
|
|
1536
|
+
end = Math.max(end, edit.base.end);
|
|
1537
|
+
delta[side] = edit.variant.end - edit.base.end;
|
|
1538
|
+
offsets[side]++;
|
|
1539
|
+
}
|
|
1540
|
+
const base = { start, end };
|
|
1541
|
+
const l = { start: start + initialDelta[0], end: end + delta[0] }, r = { start: start + initialDelta[1], end: end + delta[1] };
|
|
1542
|
+
let kind2 = !seen[0] ? "right" : !seen[1] ? "left" : overlap ? "conflict" : "adjacent";
|
|
1543
|
+
if (seen[0] && seen[1] && l.end - l.start === r.end - r.start) {
|
|
1544
|
+
let identical = true;
|
|
1545
|
+
for (let index = 0; index < l.end - l.start; index++) {
|
|
1546
|
+
if (!await equalStoredLines(await storedLine(files.left, l.start + index), await storedLine(files.right, r.start + index), options, budget)) {
|
|
1547
|
+
identical = false;
|
|
1548
|
+
break;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
if (identical) kind2 = "identical";
|
|
1552
|
+
}
|
|
1553
|
+
budget.admit("graphCells", 7);
|
|
1554
|
+
await result.push({ kind: kind2, base, left: l, right: r });
|
|
1555
|
+
}
|
|
1556
|
+
return result;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
// packages/safe-bash-command-diff3/src/stored-behavior.ts
|
|
1560
|
+
async function compareStoredDiff3(inputs, options, work) {
|
|
1561
|
+
const out = work.output(), err = work.output();
|
|
1562
|
+
let outputBytes = 0;
|
|
1563
|
+
const emit = async (bytes, destination = out) => {
|
|
1564
|
+
work.step(bytes.length + 1);
|
|
1565
|
+
if (bytes.length > work.behaviorLimits.outputBytes - outputBytes) throw new Diff3Error("LIMIT", "Output byte limit exceeded");
|
|
1566
|
+
outputBytes += bytes.length;
|
|
1567
|
+
await destination.append(bytes);
|
|
1568
|
+
};
|
|
1569
|
+
const literal = async (value, destination = out) => {
|
|
1570
|
+
work.step(value.length * 4);
|
|
1571
|
+
if (value.length) work.reserve();
|
|
1572
|
+
for (let start = 0; start < value.length; ) {
|
|
1573
|
+
let end = Math.min(start + 4096, value.length);
|
|
1574
|
+
const unit = value.charCodeAt(end - 1);
|
|
1575
|
+
if (end < value.length && unit >= 55296 && unit <= 56319) end--;
|
|
1576
|
+
await emit(new TextEncoder().encode(value.slice(start, end)), destination);
|
|
1577
|
+
start = end;
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
if (options.information) {
|
|
1581
|
+
await literal(options.information === "version" ? "diff3 (safe-bash; GNU diffutils 3.12 qualified profile)\n" : "Usage: diff3 [OPTION]... OURS BASE THEIRS\nReports, -m merge, -A/-e/-E/-3/-x/-X ed scripts; -a -T -L -i --strip-trailing-cr.\nNo external diff/ed programs. One stdin operand in any position. Ed labels must be single-line.\n");
|
|
1582
|
+
return { stdout: out, stderr: err, exitCode: 0, outputBytes };
|
|
1583
|
+
}
|
|
1584
|
+
const report = !options.selector && !options.merge;
|
|
1585
|
+
const preferredCommon = report ? 2 : 1;
|
|
1586
|
+
const common = options.files[preferredCommon] === "-" ? 3 - preferredCommon : preferredCommon;
|
|
1587
|
+
const other = 3 - common;
|
|
1588
|
+
let identical = true;
|
|
1589
|
+
for (const input of inputs.slice(1)) {
|
|
1590
|
+
if (input.size !== inputs[0].size || input.length !== inputs[0].length) {
|
|
1591
|
+
identical = false;
|
|
1592
|
+
break;
|
|
1593
|
+
}
|
|
1594
|
+
for (let index = 0; index < input.length; index++) {
|
|
1595
|
+
if (!await input.equal(index, inputs[0], index)) {
|
|
1596
|
+
identical = false;
|
|
1597
|
+
break;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
if (!identical) break;
|
|
1601
|
+
}
|
|
1602
|
+
if (!identical && !options.text && inputs.some((input) => input.binary)) throw new Diff3Error("BINARY", "Binary input requires text comparison");
|
|
1603
|
+
const documents = { base: inputs[common], left: inputs[0], right: inputs[other] };
|
|
1604
|
+
const leftEdits = await alignStoredPair(documents.base, documents.left, options, work);
|
|
1605
|
+
const rightEdits = await alignStoredPair(documents.base, documents.right, options, work);
|
|
1606
|
+
const regions = await alignStoredRegions(documents, leftEdits, rightEdits, options, work);
|
|
1607
|
+
const analysis = { files: documents, leftEdits, rightEdits, regions };
|
|
1608
|
+
const files = inputs;
|
|
1609
|
+
const labels = options.files.map((file, i) => options.labels?.[i] ?? file);
|
|
1610
|
+
const line = async (token, mode) => {
|
|
1611
|
+
const end = mode === "source" ? token.end : await bodyEnd(token, options);
|
|
1612
|
+
for await (const bytes of token.document.range(token.start, end)) await emit(bytes);
|
|
1613
|
+
if (mode !== "source" && token.terminated) await literal("\n");
|
|
1614
|
+
if (!token.terminated && (mode === "ed" || mode === "report")) await literal("\n");
|
|
1615
|
+
if (!token.terminated && mode === "report") await literal("\\n");
|
|
1616
|
+
};
|
|
1617
|
+
const range = async (file, address2, mode) => {
|
|
1618
|
+
let dots = false;
|
|
1619
|
+
for (let i = address2.start; i < address2.end; i++) {
|
|
1620
|
+
work.step();
|
|
1621
|
+
const token = await storedLine(files[file], i);
|
|
1622
|
+
if (mode === "report") await literal(options.initialTab ? " " : " ");
|
|
1623
|
+
if (mode === "ed" && (await token.document.data.read(8 + token.start, 1))[0] === 46) {
|
|
1624
|
+
await literal(".");
|
|
1625
|
+
dots = true;
|
|
1626
|
+
}
|
|
1627
|
+
await line(token, mode);
|
|
1628
|
+
}
|
|
1629
|
+
return dots;
|
|
1630
|
+
};
|
|
1631
|
+
const address = (r) => r.start === r.end ? `${r.start}a` : `${r.start + 1}${r.end > r.start + 1 ? `,${r.end}` : ""}c`;
|
|
1632
|
+
let conflict = false;
|
|
1633
|
+
if (!report && !options.merge) {
|
|
1634
|
+
for (const edits of [analysis.leftEdits, analysis.rightEdits]) for await (const edit of edits) {
|
|
1635
|
+
const variant = edits === analysis.leftEdits ? analysis.files.left : analysis.files.right;
|
|
1636
|
+
for (const [tokens, r] of [[analysis.files.base, edit.base], [variant, edit.variant]]) {
|
|
1637
|
+
if (r.end > r.start && !(await storedLine(tokens, r.end - 1)).terminated) await literal("diff3: No newline at end of file\n", err);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
let cursor = 0;
|
|
1642
|
+
const orderedRegions = analysis.regions.iterate(!options.merge && !report);
|
|
1643
|
+
for await (const region of orderedRegions) {
|
|
1644
|
+
work.step();
|
|
1645
|
+
const ranges = [];
|
|
1646
|
+
ranges[0] = region.left;
|
|
1647
|
+
ranges[other] = region.right;
|
|
1648
|
+
ranges[common] = region.base;
|
|
1649
|
+
const base = ranges[1], theirs = ranges[2];
|
|
1650
|
+
const different = region.kind === "left" ? 1 : region.kind === "right" ? other + 1 : region.kind === "identical" ? common + 1 : 0;
|
|
1651
|
+
if (report) {
|
|
1652
|
+
await literal(`====${different || ""}
|
|
1653
|
+
`);
|
|
1654
|
+
const sequence = different === 2 ? [0, 2, 1] : [0, 1, 2];
|
|
1655
|
+
for (let i = 0; i < sequence.length; i++) {
|
|
1656
|
+
const file = sequence[i];
|
|
1657
|
+
await literal(`${file + 1}:${address(ranges[file])}
|
|
1658
|
+
`);
|
|
1659
|
+
if (different === 0 || file === different - 1 || i === 1 && different !== 1 || i === 2 && different === 1) await range(file, ranges[file], "report");
|
|
1660
|
+
}
|
|
1661
|
+
continue;
|
|
1662
|
+
}
|
|
1663
|
+
const selector = options.selector;
|
|
1664
|
+
const flagged = different === 0 && (selector === "A" || selector === "E" || selector === "X") || different === 2 && selector === "A";
|
|
1665
|
+
const replace = different === 3 && ["A", "E", "e", "3"].includes(selector) || different === 0 && ["e", "x"].includes(selector);
|
|
1666
|
+
if (options.merge) {
|
|
1667
|
+
await range(0, { start: cursor, end: region.left.start }, "source");
|
|
1668
|
+
if (flagged) {
|
|
1669
|
+
conflict = true;
|
|
1670
|
+
if (different === 2) {
|
|
1671
|
+
await literal(`<<<<<<< ${labels[1]}
|
|
1672
|
+
`);
|
|
1673
|
+
await range(1, base, "changed");
|
|
1674
|
+
} else {
|
|
1675
|
+
await literal(`<<<<<<< ${labels[0]}
|
|
1676
|
+
`);
|
|
1677
|
+
await range(0, region.left, "changed");
|
|
1678
|
+
if (selector === "A") {
|
|
1679
|
+
await literal(`||||||| ${labels[1]}
|
|
1680
|
+
`);
|
|
1681
|
+
await range(1, base, "changed");
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
await literal("=======\n");
|
|
1685
|
+
await range(2, theirs, "changed");
|
|
1686
|
+
await literal(`>>>>>>> ${labels[2]}
|
|
1687
|
+
`);
|
|
1688
|
+
} else await range(replace ? 2 : 0, replace ? theirs : region.left, replace ? "changed" : "source");
|
|
1689
|
+
cursor = region.left.end;
|
|
1690
|
+
} else if (replace) {
|
|
1691
|
+
if (theirs.start === theirs.end) {
|
|
1692
|
+
if (region.left.start !== region.left.end) await literal(address(region.left).slice(0, -1) + "d\n");
|
|
1693
|
+
} else {
|
|
1694
|
+
await literal(address(region.left) + "\n");
|
|
1695
|
+
const dots = await range(2, theirs, "ed");
|
|
1696
|
+
await literal(".\n");
|
|
1697
|
+
if (dots) {
|
|
1698
|
+
const start = region.left.start + 1, end = region.left.start + theirs.end - theirs.start;
|
|
1699
|
+
await literal(`${start}${end > start ? `,${end}` : ""}s/^\\.//
|
|
1700
|
+
`);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
} else if (flagged) {
|
|
1704
|
+
conflict = true;
|
|
1705
|
+
await literal(`${region.left.end}a
|
|
1706
|
+
`);
|
|
1707
|
+
let dots = false;
|
|
1708
|
+
if (different !== 2) {
|
|
1709
|
+
if (selector === "A") {
|
|
1710
|
+
await literal(`||||||| ${labels[1]}
|
|
1711
|
+
`);
|
|
1712
|
+
dots = await range(1, base, "ed");
|
|
1713
|
+
}
|
|
1714
|
+
await literal("=======\n");
|
|
1715
|
+
dots = await range(2, theirs, "ed") || dots;
|
|
1716
|
+
}
|
|
1717
|
+
await literal(`>>>>>>> ${labels[2]}
|
|
1718
|
+
.
|
|
1719
|
+
`);
|
|
1720
|
+
if (dots) await literal(`${region.left.end + 2},${region.left.end + base.end - base.start + theirs.end - theirs.start + 2}s/^\\.//
|
|
1721
|
+
`);
|
|
1722
|
+
await literal(`${region.left.start}a
|
|
1723
|
+
<<<<<<< ${labels[different === 2 ? 1 : 0]}
|
|
1724
|
+
`);
|
|
1725
|
+
if (different === 2) {
|
|
1726
|
+
const baseDots = await range(1, base, "ed");
|
|
1727
|
+
await literal("=======\n.\n");
|
|
1728
|
+
if (baseDots) {
|
|
1729
|
+
const start = region.left.start + 2, end = region.left.start + base.end - base.start + 1;
|
|
1730
|
+
await literal(`${start}${end > start ? `,${end}` : ""}s/^\\.//
|
|
1731
|
+
`);
|
|
1732
|
+
}
|
|
1733
|
+
} else await literal(".\n");
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
if (options.merge) await range(0, { start: cursor, end: files[0].length }, "source");
|
|
1737
|
+
else if (!report && options.writeQuit) await literal("w\nq\n");
|
|
1738
|
+
return { stdout: out, stderr: err, exitCode: options.merge && conflict ? 1 : 0, outputBytes };
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
// packages/safe-bash-command-diff3/src/command.ts
|
|
1742
|
+
import { yieldTurn as yieldTurn2 } from "../safe-bash-contracts/yield.js";
|
|
965
1743
|
import { commandRuntimeIdentity, getCommandArguments } from "../safe-bash-contracts/command.js";
|
|
966
1744
|
import { FsError } from "../safe-bash-contracts/errors.js";
|
|
967
1745
|
import { readBytes, writeBytes } from "../safe-bash-contracts/io.js";
|
|
@@ -977,7 +1755,8 @@ async function executeDiff3(context, configuration, invocation) {
|
|
|
977
1755
|
let closing;
|
|
978
1756
|
let accepting = true;
|
|
979
1757
|
let inputBytes = 0, decodedBytes = 0, outputBytes = 0, retained = 0, metadataRetained = 0, peakRetained = 0, peakGraphCells = 0, work = 0;
|
|
980
|
-
const
|
|
1758
|
+
const inputs = [];
|
|
1759
|
+
let stored;
|
|
981
1760
|
const cleanup = () => {
|
|
982
1761
|
if (closing) return closing;
|
|
983
1762
|
accepting = false;
|
|
@@ -989,10 +1768,10 @@ async function executeDiff3(context, configuration, invocation) {
|
|
|
989
1768
|
controller.abort(new Diff3Error("CLOSED", "Diff3 invocation closed"));
|
|
990
1769
|
void (async () => {
|
|
991
1770
|
await Promise.allSettled([task]);
|
|
992
|
-
|
|
1771
|
+
inputs.length = 0;
|
|
993
1772
|
retained = 0;
|
|
994
1773
|
context.signal.removeEventListener("abort", abort);
|
|
995
|
-
const results = await Promise.allSettled([stdout?.close(), stderr?.close()]);
|
|
1774
|
+
const results = await Promise.allSettled([stdout?.close(), stderr?.close(), stored?.close()]);
|
|
996
1775
|
const errors = results.filter((result2) => result2.status === "rejected").map((result2) => result2.reason);
|
|
997
1776
|
if (errors.length) throw new AggregateError(errors, "Diff3 output cleanup failed");
|
|
998
1777
|
})().then(resolve, reject);
|
|
@@ -1015,7 +1794,7 @@ async function executeDiff3(context, configuration, invocation) {
|
|
|
1015
1794
|
retained += amount;
|
|
1016
1795
|
peakRetained = Math.max(peakRetained, retained);
|
|
1017
1796
|
};
|
|
1018
|
-
const result = (exitCode) => ({ exitCode, accounting: { inputBytes, decodedBytes, outputBytes, retainedBytes: 0, peakRetainedBytes: peakRetained, graphCells: 0, peakGraphCells, tokens: 0, work } });
|
|
1797
|
+
const result = (exitCode) => ({ exitCode, accounting: { inputBytes, decodedBytes, outputBytes, retainedBytes: 0, peakRetainedBytes: peakRetained, graphCells: 0, peakGraphCells: Math.max(peakGraphCells, stored?.peakGraphCells ?? 0), tokens: 0, work } });
|
|
1019
1798
|
task = Promise.resolve().then(async () => {
|
|
1020
1799
|
if (!accepting) throw new Diff3Error("CLOSED", "Diff3 invocation closed");
|
|
1021
1800
|
context.signal.addEventListener("abort", abort, { once: true });
|
|
@@ -1057,15 +1836,27 @@ async function executeDiff3(context, configuration, invocation) {
|
|
|
1057
1836
|
charge(value.length * 4 + 1);
|
|
1058
1837
|
metadataRetained = retained;
|
|
1059
1838
|
}
|
|
1839
|
+
const { registerCleanup: ignoredCleanup, ...storageContext } = context;
|
|
1840
|
+
stored = new StoredWork({ ...storageContext, signal }, limits, charge, hold);
|
|
1060
1841
|
if (!options.information) for (const file of options.files) {
|
|
1061
|
-
await
|
|
1842
|
+
await yieldTurn2(signal);
|
|
1062
1843
|
signal.throwIfAborted();
|
|
1063
1844
|
signal.throwIfAborted();
|
|
1064
1845
|
let source, borrowed = 0, acquiredInput;
|
|
1065
1846
|
if (file === "-") source = context.stdin;
|
|
1066
1847
|
else {
|
|
1067
|
-
const path =
|
|
1068
|
-
|
|
1848
|
+
const path = resolvePath(context.cwd, file);
|
|
1849
|
+
const capabilities = await context.fs.capabilitiesFor?.(path, { signal }) ?? context.fs.capabilities;
|
|
1850
|
+
if (capabilities?.retainedRead && context.fs.openReadFile) {
|
|
1851
|
+
const reader2 = new ReadBudget({ ...context, signal }, {});
|
|
1852
|
+
const stat = await inspect(reader2, path, "follow");
|
|
1853
|
+
if (stat?.type === "file") {
|
|
1854
|
+
if (stat.size > limits.inputBytes - inputBytes) throw new Diff3Error("LIMIT", "Input byte limit exceeded");
|
|
1855
|
+
context.inputBudget?.check(inputBytes + stat.size);
|
|
1856
|
+
source = reader2.diffSource(path);
|
|
1857
|
+
} else if (context.fs.readStream) source = context.fs.readStream(path, { signal });
|
|
1858
|
+
else throw new FsError(stat ? "EISDIR" : "ENOENT", { path });
|
|
1859
|
+
} else if (context.fs.readStream) source = context.fs.readStream(path, { signal });
|
|
1069
1860
|
else {
|
|
1070
1861
|
const maxBytes = Math.min(limits.inputBytes - inputBytes, limits.retainedBytes - retained);
|
|
1071
1862
|
const resource = await stdout.acquire(async (readSignal) => ({ bytes: await context.fs.readFile(path, { signal: readSignal, ...Number.isFinite(maxBytes) ? { maxBytes } : {} }) }), (resource2) => {
|
|
@@ -1095,44 +1886,29 @@ async function executeDiff3(context, configuration, invocation) {
|
|
|
1095
1886
|
return: closeInput
|
|
1096
1887
|
};
|
|
1097
1888
|
} }, signal)[Symbol.asyncIterator]();
|
|
1098
|
-
|
|
1099
|
-
chunks.push(parts);
|
|
1100
|
-
let size = 0, complete = false;
|
|
1889
|
+
let complete = false;
|
|
1101
1890
|
let readFailure;
|
|
1102
1891
|
try {
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1892
|
+
inputs.push(await stored.load({ async *[Symbol.asyncIterator]() {
|
|
1893
|
+
for (; ; ) {
|
|
1894
|
+
charge(1);
|
|
1895
|
+
const next = await reader.next();
|
|
1896
|
+
signal.throwIfAborted();
|
|
1897
|
+
if (next.done) {
|
|
1898
|
+
complete = true;
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
const bytes = next.value;
|
|
1902
|
+
if (bytes.length === 0) continue;
|
|
1903
|
+
if (bytes.length > limits.inputBytes - inputBytes) throw new Diff3Error("LIMIT", "Input byte limit exceeded");
|
|
1904
|
+
context.inputBudget?.check(inputBytes + bytes.length);
|
|
1905
|
+
inputBytes += bytes.length;
|
|
1906
|
+
charge(bytes.length);
|
|
1907
|
+
stored.reserve();
|
|
1908
|
+
for (let offset2 = 0; offset2 < bytes.length; offset2 += 16384) yield new Uint8Array(bytes.subarray(offset2, offset2 + 16384));
|
|
1110
1909
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
if (bytes2.length > limits.inputBytes - inputBytes) throw new Diff3Error("LIMIT", "Input byte limit exceeded");
|
|
1114
|
-
context.inputBudget?.check(inputBytes + bytes2.length);
|
|
1115
|
-
inputBytes += bytes2.length;
|
|
1116
|
-
charge(bytes2.length);
|
|
1117
|
-
hold(bytes2.length + 8);
|
|
1118
|
-
const cells = parts.length + inputs.length + chunks.length + 1;
|
|
1119
|
-
if (cells > limits.graphCells) throw new Diff3Error("LIMIT", "Spool fragment limit exceeded");
|
|
1120
|
-
peakGraphCells = Math.max(peakGraphCells, cells);
|
|
1121
|
-
parts.push(new Uint8Array(bytes2));
|
|
1122
|
-
size += bytes2.length;
|
|
1123
|
-
}
|
|
1124
|
-
hold(size);
|
|
1125
|
-
charge(size);
|
|
1126
|
-
const bytes = new Uint8Array(size);
|
|
1127
|
-
let index = 0;
|
|
1128
|
-
for (const part of parts) {
|
|
1129
|
-
charge(1);
|
|
1130
|
-
bytes.set(part, index);
|
|
1131
|
-
index += part.length;
|
|
1132
|
-
}
|
|
1133
|
-
retained -= size + parts.length * 8 + borrowed;
|
|
1134
|
-
parts.length = 0;
|
|
1135
|
-
inputs.push(bytes);
|
|
1910
|
+
} }));
|
|
1911
|
+
retained -= borrowed;
|
|
1136
1912
|
if (acquiredInput) acquiredInput.bytes = void 0;
|
|
1137
1913
|
} catch (error) {
|
|
1138
1914
|
readFailure = { error };
|
|
@@ -1148,24 +1924,22 @@ async function executeDiff3(context, configuration, invocation) {
|
|
|
1148
1924
|
if (readFailure) throw readFailure.error;
|
|
1149
1925
|
}
|
|
1150
1926
|
charge(0);
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
decodedBytes += rendered.accounting.decodedBytes;
|
|
1155
|
-
peakGraphCells = Math.max(peakGraphCells, spoolCells + rendered.accounting.peakGraphCells);
|
|
1156
|
-
peakRetained = Math.max(peakRetained, retained + rendered.accounting.peakRetainedBytes);
|
|
1157
|
-
hold(rendered.stdout.length + rendered.stderr.length);
|
|
1158
|
-
outputBytes = rendered.stdout.length + rendered.stderr.length;
|
|
1927
|
+
const rendered = await compareStoredDiff3(inputs, options, stored);
|
|
1928
|
+
peakGraphCells = Math.max(peakGraphCells, stored.peakGraphCells);
|
|
1929
|
+
outputBytes = rendered.outputBytes;
|
|
1159
1930
|
publishing = true;
|
|
1160
|
-
|
|
1161
|
-
|
|
1931
|
+
for await (const bytes of rendered.stderr.bytes()) await writeBytes(stderr.output, bytes, signal);
|
|
1932
|
+
for await (const bytes of rendered.stdout.bytes()) await writeBytes(stdout.output, bytes, signal);
|
|
1162
1933
|
return result(rendered.exitCode);
|
|
1163
|
-
} catch (
|
|
1934
|
+
} catch (caught) {
|
|
1935
|
+
const error = caught instanceof ToolError ? new Diff3Error("STATE", "VFS input validation failed") : caught;
|
|
1164
1936
|
signal.throwIfAborted();
|
|
1165
1937
|
if (publishing) throw error;
|
|
1166
1938
|
if (!(error instanceof Diff3Error) && !(error instanceof FsError)) throw error;
|
|
1167
1939
|
await stdout.close();
|
|
1168
|
-
|
|
1940
|
+
peakGraphCells = Math.max(peakGraphCells, stored?.peakGraphCells ?? 0);
|
|
1941
|
+
await stored?.close();
|
|
1942
|
+
inputs.length = 0;
|
|
1169
1943
|
retained = metadataRetained;
|
|
1170
1944
|
const code = Object.getOwnPropertyDescriptor(error, "code")?.value;
|
|
1171
1945
|
const message = Object.getOwnPropertyDescriptor(error, "message")?.value;
|
|
@@ -1189,7 +1963,7 @@ async function executeDiff3(context, configuration, invocation) {
|
|
|
1189
1963
|
else {
|
|
1190
1964
|
bytes[index++] = 92;
|
|
1191
1965
|
bytes[index++] = 117;
|
|
1192
|
-
for (const
|
|
1966
|
+
for (const shift3 of [12, 8, 4, 0]) bytes[index++] = hex.charCodeAt(char >>> shift3 & 15);
|
|
1193
1967
|
}
|
|
1194
1968
|
}
|
|
1195
1969
|
bytes[index] = 10;
|