forge-terminal 0.5.1 → 0.5.2
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 +7 -6
- package/dist/chunks/{about-credits-FZ35HUFP.js → about-credits-VZQJAWG3.js} +1 -1
- package/dist/chunks/args-FZXEZBPA.js +3 -0
- package/dist/chunks/{boot-PCZBPNFR.js → boot-NYKO3NLR.js} +1 -1
- package/dist/chunks/chunk-2AFHW44W.js +36 -0
- package/dist/chunks/{chunk-S2M4XESA.js → chunk-63ZZRDSV.js} +1 -1
- package/dist/chunks/{chunk-63ZK5SRQ.js → chunk-7I2OSTBX.js} +1 -1
- package/dist/chunks/chunk-7KYO62XK.js +3 -0
- package/dist/chunks/{chunk-DZOBIUV6.js → chunk-BIBDLXCG.js} +1 -1
- package/dist/chunks/{chunk-G46QQBT3.js → chunk-BROTSQXG.js} +1 -1
- package/dist/chunks/chunk-CVNYUROW.js +3 -0
- package/dist/chunks/chunk-CW2Y2KDQ.js +3 -0
- package/dist/chunks/chunk-DYIATUFE.js +3 -0
- package/dist/chunks/{chunk-SK2UZ25Y.js → chunk-EITGK5OI.js} +1 -1
- package/dist/chunks/chunk-GRWOJKQB.js +3 -0
- package/dist/chunks/{chunk-X26WUHWB.js → chunk-GT6U6HV3.js} +1 -1
- package/dist/chunks/{chunk-JMBEZPYC.js → chunk-HWCXNKIN.js} +1 -1
- package/dist/chunks/chunk-IED6VBE6.js +3 -0
- package/dist/chunks/{chunk-2CX33C6H.js → chunk-ITW5FG4K.js} +1 -1
- package/dist/chunks/{chunk-MTDCDKPU.js → chunk-IVBSXPNS.js} +2 -2
- package/dist/chunks/chunk-J2UQI544.js +4 -0
- package/dist/chunks/{chunk-THDAQBQ3.js → chunk-J6AZTW62.js} +1 -1
- package/dist/chunks/chunk-JGJU3AW5.js +3 -0
- package/dist/chunks/{chunk-XURW53YK.js → chunk-K6ERQTUQ.js} +1 -1
- package/dist/chunks/chunk-KMLT45OJ.js +66 -0
- package/dist/chunks/{chunk-QXNB5DQ2.js → chunk-LA5JVBFP.js} +1 -1
- package/dist/chunks/chunk-M6LYLTFH.js +3 -0
- package/dist/chunks/chunk-O7DK3GJT.js +3 -0
- package/dist/chunks/chunk-Q7ERPAG3.js +7 -0
- package/dist/chunks/{chunk-HCLEHCAR.js → chunk-R24JCIZ5.js} +1 -1
- package/dist/chunks/{chunk-3KWAO2N2.js → chunk-RK3WGALB.js} +1 -1
- package/dist/chunks/chunk-RXI6QLNY.js +82 -0
- package/dist/chunks/chunk-SNFUGJ3M.js +3 -0
- package/dist/chunks/chunk-T37DEXUI.js +3 -0
- package/dist/chunks/chunk-TARDT6LZ.js +55 -0
- package/dist/chunks/{chunk-EKTUUKDP.js → chunk-TYWGB767.js} +1 -1
- package/dist/chunks/chunk-VLVNA4T3.js +3 -0
- package/dist/chunks/{chunk-YINYF6C7.js → chunk-VTA6Z45X.js} +1 -1
- package/dist/chunks/{chunk-JOIHR724.js → chunk-W2QJA73Q.js} +1 -1
- package/dist/chunks/{chunk-BD3OLIVT.js → chunk-XPATZLEH.js} +1 -1
- package/dist/chunks/chunk-XUKYIVJC.js +3 -0
- package/dist/chunks/{chunk-GLAD7GP2.js → chunk-YK26E3OX.js} +1 -1
- package/dist/chunks/{chunk-YNZIN42P.js → chunk-ZFLFBNIK.js} +1 -1
- package/dist/chunks/{chunk-655UG277.js → chunk-ZHNPBRCX.js} +1 -1
- package/dist/chunks/{chunk-C4UCCBCX.js → chunk-ZOQA3JAR.js} +1 -1
- package/dist/chunks/clip-command-SLSAWJF4.js +3 -0
- package/dist/chunks/clipboard-7KSZNWWT.js +3 -0
- package/dist/chunks/colour-LMZO2EE6.js +3 -0
- package/dist/chunks/command-DMGGGAPS.js +3 -0
- package/dist/chunks/config-command-6GXRV627.js +3 -0
- package/dist/chunks/continue-editing-4W3XWWCE.js +3 -0
- package/dist/chunks/decoded-SMEHAVCH.js +3 -0
- package/dist/chunks/{entry-2XJD7UCY.js → entry-TV4FJQDR.js} +2 -2
- package/dist/chunks/execute-NEDE4JM6.js +3 -0
- package/dist/chunks/extensions-4UJRQ32J.js +3 -0
- package/dist/chunks/{extensions-command-MGPRISPH.js → extensions-command-VROVGVD4.js} +1 -1
- package/dist/chunks/{ffmpeg-2UZXAB3C.js → ffmpeg-OIVMTPY7.js} +1 -1
- package/dist/chunks/image-J5WDYORX.js +3 -0
- package/dist/chunks/install-5XLVERRR.js +3 -0
- package/dist/chunks/install-C6XNONFF.js +3 -0
- package/dist/chunks/launch-5JMWS5CI.js +17 -0
- package/dist/chunks/lock-AFVXUDOM.js +3 -0
- package/dist/chunks/manager-T3WDLUKR.js +4 -0
- package/dist/chunks/{needed-YEXRZMZX.js → needed-YU5BPYD6.js} +1 -1
- package/dist/chunks/notify-LTV7F634.js +3 -0
- package/dist/chunks/{own-WOK6H277.js → own-OJAQ5FRQ.js} +1 -1
- package/dist/chunks/pdfium-7HNCQ3K3.js +3 -0
- package/dist/chunks/preset-command-VP5RAXBG.js +3 -0
- package/dist/chunks/registry-E5PNQWOZ.js +3 -0
- package/dist/chunks/run-WSETTQXP.js +3 -0
- package/dist/chunks/{server-QNWPC2CC.js → server-EFNTD7ZW.js} +3 -3
- package/dist/chunks/{theme-EHFY7DT6.js → theme-NF3LQHPV.js} +1 -1
- package/dist/chunks/transcribe-CQFHXBTV.js +3 -0
- package/dist/chunks/transcribe-command-ZXB3JJFZ.js +3 -0
- package/dist/chunks/update-command-DJLYU6AB.js +3 -0
- package/dist/chunks/{update-note-GYJWUDFS.js → update-note-CJ5XYKYH.js} +1 -1
- package/dist/chunks/watch-command-ZNMO4SF7.js +3 -0
- package/dist/index.js +13 -13
- package/package.json +9 -9
- package/dist/chunks/args-FSQFXDIX.js +0 -3
- package/dist/chunks/chunk-2J2PTA5O.js +0 -3
- package/dist/chunks/chunk-2MLASXG5.js +0 -3
- package/dist/chunks/chunk-5TEAR5XH.js +0 -3
- package/dist/chunks/chunk-63BBFKT2.js +0 -4
- package/dist/chunks/chunk-72TNSFL5.js +0 -36
- package/dist/chunks/chunk-AYB5AJ4E.js +0 -3
- package/dist/chunks/chunk-C32KGH4S.js +0 -3
- package/dist/chunks/chunk-LBDSFSYP.js +0 -3
- package/dist/chunks/chunk-OY4EGSPE.js +0 -3
- package/dist/chunks/chunk-UXRQ4UBQ.js +0 -66
- package/dist/chunks/chunk-WIPP5TWQ.js +0 -3
- package/dist/chunks/chunk-WZWK3PEZ.js +0 -3
- package/dist/chunks/chunk-ZRHYGR2L.js +0 -134
- package/dist/chunks/clip-command-NZNC46H2.js +0 -3
- package/dist/chunks/clipboard-GICOXMMN.js +0 -3
- package/dist/chunks/colour-GSDOHCFK.js +0 -3
- package/dist/chunks/command-GYCYLUHN.js +0 -3
- package/dist/chunks/config-command-6YUMMZF3.js +0 -3
- package/dist/chunks/continue-editing-QE5RRIMG.js +0 -3
- package/dist/chunks/decoded-NBZ335RZ.js +0 -3
- package/dist/chunks/execute-FYEXZ7EY.js +0 -3
- package/dist/chunks/extensions-V5O4NIHI.js +0 -3
- package/dist/chunks/image-3CMUB2P4.js +0 -3
- package/dist/chunks/install-IDUHZTTS.js +0 -3
- package/dist/chunks/install-L5C2UT6M.js +0 -3
- package/dist/chunks/launch-GUHDBMSJ.js +0 -17
- package/dist/chunks/lock-UQJ66TZ3.js +0 -3
- package/dist/chunks/manager-UKTMRXKE.js +0 -4
- package/dist/chunks/pdfium-LYHOU6WV.js +0 -3
- package/dist/chunks/preset-command-6A2C6VPQ.js +0 -3
- package/dist/chunks/registry-2YU7NW4P.js +0 -3
- package/dist/chunks/run-U2CU6VGE.js +0 -5
- package/dist/chunks/transcribe-SCL3LFZU.js +0 -3
- package/dist/chunks/transcribe-command-BX2VVUI3.js +0 -3
- package/dist/chunks/update-command-JCTCRPCS.js +0 -3
- package/dist/chunks/watch-command-ZLZAWTNJ.js +0 -3
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as l}from"./chunk-J7FLFHQJ.js";import{a as s}from"./chunk-H3DIRJFE.js";import{homedir as $}from"node:os";import{posix as f,win32 as m}from"node:path";var x=/[\u0000-\u001f\u007f-\u009f--]/g;function c(e){return e.replace(x,"?")}function g(e,t,n){let i=n.relative(t,e);if(i==="")return"";if(!(i===".."||i.startsWith(`..${n.sep}`)||n.isAbsolute(i)))return i}function I(e,t={}){return c(y(e,t))}function y(e,t){let n=(t.platform??process.platform)==="win32"?m:f;if(t.cwd!==void 0){let a=g(e,t.cwd,n);if(a!==void 0)return a===""?".":a}let i=g(e,t.home??$(),n);return i!==void 0?i===""?"~":`~${n.sep}${i}`:e}function r(e,t=process.platform){return c((t==="win32"?m:f).basename(e))}import{dirname as F}from"node:path";var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function E(e){return e instanceof o}function W(e){return new o({code:"file-not-found",title:"File not found",detail:`${r(e)} could not be found.`,short:`${r(e)} could not be found.`,hint:"Check the filename and try again."})}function D(e){return new o({code:"not-a-file",title:"Not a file",detail:`${r(e)} is not a file.`,short:`${r(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function J(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(e)} could not be read.`,short:`${r(e)} could not be read.`,hint:"Check the file permissions and try again."})}function M(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${r(e)} could not be found: part of its path is not a directory.`,short:`part of ${r(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function j(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${r(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${r(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function z(e){return new o({code:"path-too-long",title:"Path too long",detail:`${r(e)}'s path is too long for the filesystem to resolve.`,short:`${r(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function L(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${r(e)} could not be checked.`,short:`${r(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function q(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${r(e)} is ${t}, which Forge cannot read.`,short:`${r(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function Y(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${r(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function V(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function _(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e,t)} is a HEIC photo, which needs Forge's free HEIC extension on ${n}.`,short:"HEIC needs the heic extension.",hint:"Install it with: forge extensions add heic",shellHint:"Open /extensions to install it."})}return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function X(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which needs Forge's free RAW extension on ${n}.`,short:"RAW needs the raw extension.",hint:"Install it with: forge extensions add raw",shellHint:"Open /extensions to install it."})}return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which Forge reads with macOS's own RAW support.`,short:"RAW needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function B(e){return new o({code:"raw-decoder-unavailable",title:"Cannot read this RAW",detail:`${r(e)} is a camera RAW photo that this Mac cannot read.`,short:"macOS cannot read RAW photos from this camera.",hint:"A newer camera usually needs a newer macOS."})}function G(e,t){let n=r(e.path);if(t!==void 0&&t!==e.format){let i=s[t].label;return s[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${n} \u2192 ${i} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${i} is lossless \u2014 there is no quality to trade away, so ${n} cannot be made to fit as ${i}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let i=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:i>0?`${n}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${n} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${s[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${n} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${s[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function K(e){let t=r(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${s[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function Q(e,t,n){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:n??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:n??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function Z(e,t,n){let i=e.kind==="media"?`The smallest ${r(e.path)} can get is ${l(n)}, which is still over ${l(t)}.`:`${r(e.path)} is ${l(n)} even at the lowest quality, which is still over ${l(t)}.`;return new o({code:"target-unreachable",title:"Cannot get that small",detail:i,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function ee(e,t,n){return new o({code:"unsupported-target",title:`Can't convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is a ${s[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${n.join(", ")}`})}function te(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${r(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function oe(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${s[t].label}`,detail:`${r(e)} is a ${s[t].label} file, but its content could not be read.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:n})}function ne(e,t={}){let n=r(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${n} is password-protected.`,short:`${n} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${n} --to jpeg --password-stdin`})}var p=e=>e==="convert"||e==="boost"||e==="remove-background";function re(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:p(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function ie(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${r(e[0])} and ${r(e[1])} would both become ${r(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function ae(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${r(e)} would write ${r(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function se(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${r(e)} is both the input and the output.`,hint:p(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:p(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function v(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(F(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var k=new Set(["EACCES","EPERM","EROFS"]);function le(e,t){if(E(t))return t;let n=t?.code;return n!==void 0&&k.has(n)?v(e,t):t}function de(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function ue(e){return new o({code:"empty-directory",title:"No images found",detail:`${r(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function ce(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function pe(e,t,n){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${n} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function he(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function ge(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function fe(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function me(e,t,n,i){return new o({code:"extension-outdated",title:"Extension out of date",detail:`${e} ${n} cannot ${t}; that needs ${i} or later.`,hint:`Update it with: forge extensions add ${e}`,shellHint:"Open /extensions to update it."})}function we(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function be(e,t,n=process.platform){let i=n==="win32"?"PC":n==="darwin"?"Mac":"computer";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this ${i}: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function xe(e,t=process.platform){let n=t==="win32"?"Windows":t==="darwin"?"macOS":t==="linux"?"Linux":"this system";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} is not available on ${n}.`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function $e(e){return new o({code:"update-unavailable",title:"Cannot update this Forge",detail:`This copy of Forge was not installed with npm i -g, so ${e} cannot be installed over it.`,hint:"npm i -g forge-terminal"})}function ye(e,t=process.platform){return t==="win32"?new o({code:"update-denied",title:"Forge is in use",detail:`npm could not replace Forge's files to update it to ${e}. Windows keeps them locked while Forge runs: close every Forge window, then run the command below. If Node is installed for every user, run it in a terminal opened as administrator.`,short:"Windows locks Forge while it runs: close it, then run this",hint:`npm i -g forge-terminal@${e}`}):new o({code:"update-denied",title:"npm needs permission",detail:`npm needs permission to update Forge to ${e}.`,short:"npm needs permission to update Forge",hint:`sudo npm i -g forge-terminal@${e}`})}function Fe(e,t){return new o({code:"update-failed",title:"Update failed",detail:`npm could not install Forge ${e}: ${t}`,short:"npm could not install the update",hint:`npm i -g forge-terminal@${e}`})}function Ee(){return new o({code:"update-unreachable",title:"Could not check for updates",detail:"The npm registry could not be reached.",short:"could not reach npm",hint:"Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge update",shellHint:"Check your connection, then try again."})}function ve(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function ke(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function Ce(e,t,n){let i=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${i}.`,hint:n==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:n==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function Se(e){return new o({code:"no-subject",title:"No subject found",detail:`${r(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function Te(e,t,n){return n===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${r(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${r(e)} is too large to boost that far; ${t}x is the most it can take.`:`${r(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function Ne(e,t,n,i=process.platform){let a=n===1?"sharpen":"boost",d=i==="win32"?"PC":i==="darwin"?"Mac":"computer",u=Math.max(1,Math.round(t/60));return new o({code:"boost-too-slow",title:`Too slow to ${a}`,detail:`${r(e)} would take about ${u} ${u===1?"minute":"minutes"} to ${a} on this ${d}.`,hint:"Try a smaller photo."})}function Pe(e,t){return new o({code:"resize-too-large",title:"Too large to resize to",detail:`${r(e)} would be ${t.width} \xD7 ${t.height}.`,hint:"Resize works up to 16,384 px a side and 100 megapixels."})}var C={darwin:"\u2303\u21E7\u23184",win32:"Win+Shift+S"};function Ie(e,t=process.platform){let n=C[t];return new o({code:"no-clipboard-image",title:"No image",detail:e==="text"?"The clipboard holds text, not a picture.":"The clipboard is empty.",hint:n===void 0?"Copy a picture or a screenshot, then run forge clip again.":`Copy a picture, or take a screenshot with ${n}, then run forge clip again.`})}function He(e=process.platform){return new o({code:"clipboard-unavailable",title:"No clipboard",detail:e==="linux"?"Forge reads the clipboard of a Wayland or X11 desktop, and not over SSH.":"Forge reads the clipboard on macOS, Windows and Linux, and not over SSH."})}function Re(e){return new o({code:"clipboard-tool-missing",title:`Clipboard needs ${e}`,detail:`Forge reaches the clipboard through ${e}, and it is not on this computer.`,short:`${e} is not on this computer`,hint:`Install it with sudo apt install ${e} (or your distribution's package manager), then try again.`})}function Oe(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function Ae(e,t,n,i=!1){let a=r(e);if(i)return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${a} is no smaller even at the lowest quality, so nothing was written.`,short:"nothing written"});let d=n>t?`would grow from ${l(t)} to ${l(n)}`:`would stay at ${l(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${a} ${d}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function Ue(e,t,n){return new o({code:"cannot-compress-more",title:"Already small enough",detail:`${r(e)} is ${l(t)}, already under ${l(n)}, so nothing was written.`,short:"already under that size"})}function We(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function De(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function Je(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Me(e){return new o({code:"animated-crop",title:"Can't crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function je(e){return new o({code:"animated-rotate",title:"Can't rotate an animation",detail:`${r(e)} is animated; rotating works on still images.`})}function ze(e,t=process.platform,n=!1){let i=h(t),a=n?`forge extensions add video (or ${i})`:t==="linux"?`${i} (or your distribution's package manager)`:i;return new o({code:"ffmpeg-missing",title:"Video and audio need ffmpeg",detail:`${r(e)} is a video or audio file, and ffmpeg is not on this computer.`,short:"ffmpeg is not on this computer",hint:`Install it with ${a}, then run Forge again.`})}function Le(e,t,n=process.platform){let i=s[e].label,a=/^[AEFHILMNORSX]/.test(t.codec)?"an":"a",d=t.encoders,u=d.length>1?`${d.slice(0,-1).join(", ")} or ${d.at(-1)}`:d[0]??"",w=d.length>1?"any of them":"it",b=n==="linux"?"Install a full build of ffmpeg, then run Forge again. On Fedora, RPM Fusion's ffmpeg replaces ffmpeg-free.":n==="win32"?`Install a full build of ffmpeg, such as gyan.dev's (${h(n)}), then run Forge again.`:`Install a full build of ffmpeg (${h(n)}), then run Forge again.`;return new o({code:"encoder-missing",title:`Your ffmpeg can't write ${i}`,detail:`${i} needs ${a} ${t.codec} encoder${t.sound?" for its sound":""}: ${u}. Your ffmpeg was built without ${w}.`,short:`Your ffmpeg has no ${t.codec} encoder`,hint:b})}function h(e=process.platform){return e==="win32"?"winget install ffmpeg":e==="linux"?"sudo apt install ffmpeg":"brew install ffmpeg"}function qe(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${r(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}function Ye(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function Ve(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){return n==="whisper"?new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e,t)} cannot be read by whisper.`,hint:"Video and sound files can be transcribed."}):new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e)} cannot be read by Apple's speech recogniser.`,hint:"MP4, MOV, M4A, MP3, WAV and AIFF can be transcribed; with ffmpeg (brew install ffmpeg), any video or sound file."})}function _e(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){let i=n==="apple"?"Apple's speech recogniser":"The whisper extension";return new o({code:"language-unsupported",title:"Language not supported",detail:`${i} does not support ${e}.`,hint:"Pass another with --language, for example --language en-US."})}function Xe(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function Be(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function Ge(e=!1){return e?new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs Forge's free read-text extension.",short:"Needs the read-text extension.",hint:"Install it with: forge extensions add read-text",shellHint:"Open /extensions to install it."}):new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs macOS 26 or later.",short:"Reading text needs macOS 26 or later."})}function Ke(e){let t=r(e);return new o({code:"no-text",title:"No text found",detail:`No text found in ${t}`,short:`No text found in ${t}`})}function Qe(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function Ze(e,t={}){let n=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&n.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&n.push("",` ${e.cause.stack??e.cause.message}`),n}export{c as a,I as b,r as c,E as d,W as e,D as f,J as g,M as h,j as i,z as j,L as k,q as l,Y as m,V as n,_ as o,X as p,B as q,G as r,K as s,Q as t,Z as u,ee as v,te as w,oe as x,ne as y,re as z,ie as A,ae as B,se as C,v as D,le as E,de as F,ue as G,ce as H,pe as I,he as J,ge as K,fe as L,me as M,we as N,be as O,xe as P,$e as Q,ye as R,Fe as S,Ee as T,ve as U,ke as V,Ce as W,Se as X,Te as Y,Ne as Z,Pe as _,Ie as $,He as aa,Re as ba,Oe as ca,Ae as da,Ue as ea,We as fa,De as ga,Je as ha,Me as ia,je as ja,ze as ka,Le as la,h as ma,qe as na,Ye as oa,Ve as pa,_e as qa,Xe as ra,Be as sa,Ge as ta,Ke as ua,Qe as va,Ze as wa};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as te,g as st,h as it}from"./chunk-EEQSUBBL.js";import{c as ue,d as at,f as me,g as ct,k as ft}from"./chunk-QXNB5DQ2.js";import{b as nt,c as rt}from"./chunk-XURW53YK.js";import{b as Ce,c as Ue,e as ze,h as je,i as et,j as tt,o as ot}from"./chunk-2J2PTA5O.js";import{n as qe,o as Ve,q as Ge,r as R}from"./chunk-DZOBIUV6.js";import{H as Te,I as V,J as de,L as Ne,P as Be,Y as Le,c as A,d as T,da as j,ka as Je,la as We,na as J,u as Ae,w as Z,y as X}from"./chunk-WIPP5TWQ.js";import{a as De}from"./chunk-J7FLFHQJ.js";import{a as S}from"./chunk-H3DIRJFE.js";import{a as He,b as ee,c as M,e as Ke,f as Ye,g as Qe,h as Ze,i as Xe}from"./chunk-KXKQDFHX.js";import{mkdtemp as Tt,rm as Nt}from"node:fs/promises";import{tmpdir as Bt}from"node:os";import{join as oe}from"node:path";var dt=(e,t,o)=>ze(e,t,o)===void 0;function pt(e,t,o=Number.POSITIVE_INFINITY,n=[2,4]){return[...n].reverse().find(s=>s<o&&dt(e,t,s))??0}async function Lt(e,t,o){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=e.op,{assetFor:i,catalogEntry:a,offeredHere:f}=await import("./catalog-FMHWWMUX.js");if(!f(r,process.platform,process.arch))throw Be(a(r)?.title??r);let{installed:p,extensionsRoot:d}=await import("./paths-6OENILJ4.js"),w=await p(r);if(!w)throw Ne(r);let l=Ce(w.version);if(e.op==="boost"){let b=a(r),y=Ue(e.scale,w.version,b&&i(b)?.version);if(y)throw y}if(e.op==="boost"&&!dt(n.width,n.height,e.scale))throw Le(n.path,pt(n.width,n.height,Number.POSITIVE_INFINITY,l),e.scale);let{runExtension:h}=await import("./run-U2CU6VGE.js"),g=[];n.frames>1&&g.push({code:"animation-flattened",message:`${A(n.path)} has ${n.frames} frames. Only the first frame was used.`});let I=await Tt(oe(Bt(),"forge-ext-"));try{t({phase:"decoding"});let b=oe(I,"in.png"),y=oe(I,"out.png");await tt(n,b);let $=e.op==="boost"?["--in",b,"--out",y,"--scale",String(e.scale),"--cache",oe(d(),"boost","cache")]:[b,y];await h(w,$,{subject:n.path,what:`${Jt(e)} is running on ${A(n.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),onProgress:(v,O)=>t({phase:"tiles",done:v,total:O}),...e.op==="boost"?{maxScale:pt(n.width,n.height,e.scale,l)}:{},...o===void 0?{}:{signal:o}});let x=(await ee())(y);S[e.target].hasAlpha||(x=x.flatten({background:e.options.background}));let P=await je(x,e.target,e.options.quality).toBuffer();t({phase:"writing"});let E=await et(P,s);return{job:e,outputBytes:E,warnings:g}}catch(b){throw T(b)?b:J(n.path,b)}finally{await Nt(I,{recursive:!0,force:!0}).catch(()=>{})}}function Jt(e){return e.op!=="boost"?"Remove background":e.scale===1?"Sharpen":`Boost resolution ${e.scale}\xD7`}var ut={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Lt};import{randomBytes as ao}from"node:crypto";import{open as co,rm as fo,stat as ne}from"node:fs/promises";import{dirname as po,join as uo}from"node:path";var le="%NOISE_FLOOR%",Wt=["highpass=f=80",`afftdn=nr=12:nf=${le}`],Ct="highpass=f=80,astats=measure_perchannel=none:measure_overall=RMS_trough";function wt(e){let t=/RMS trough dB:\s*(-?[\d.]+|-?inf)/i.exec(e)?.[1],o=t===void 0?Number.NaN:Number(t);return Number.isFinite(o)?Math.min(-30,Math.max(-70,Math.round(o+8))):-50}var ge="%LOUDNORM_MEASURED%",Ut={mp4:"mp4",hevc:"mp4",mov:"mov",webm:"webm",mkv:"matroska",avi:"avi",gif:"gif",mp3:"mp3",m4a:"ipod",opus:"opus",flac:"flac",wav:"wav",aiff:"aiff",ogg:"ogg"},zt={mp4:["h264","hevc","mpeg4","av1"],mov:["h264","hevc","mpeg4","prores","av1"],mkv:["h264","hevc","mpeg4","vp8","vp9","av1"],hevc:["hevc"],webm:["vp8","vp9","av1"],avi:["mpeg4","h264","mjpeg","msmpeg4v3"]},qt={mp4:["aac","alac","mp3"],hevc:["aac","alac","mp3"],mov:["aac","alac","mp3","pcm_s16le","pcm_s16be","pcm_s24le"],m4a:["aac","alac"],mkv:["aac","mp3","opus","vorbis","flac","ac3","eac3"],webm:["opus","vorbis"],opus:["opus"],mp3:["mp3"],flac:["flac"],wav:["pcm_s16le"],aiff:["pcm_s16be"],ogg:["vorbis","opus","flac"],avi:["mp3","ac3","aac","pcm_s16le"]},mt=[48e3,24e3,16e3,12e3,8e3];function Vt(e,t,o){let n={encoder:"opus",kbps:96,args:["-strict","-2"],rates:[48e3]};switch(e){case"webm":return o("libopus")?{encoder:"libopus",kbps:96,rates:mt}:o("libvorbis")?{encoder:"libvorbis",kbps:128}:o("opus")?n:{codec:"Opus or Vorbis",encoders:["libopus","libvorbis","opus"],sound:!0};case"opus":return o("libopus")?{encoder:"libopus",kbps:96,rates:mt}:o("opus")?n:{codec:"Opus",encoders:["libopus","opus"]};case"mp3":return o("libmp3lame")?{encoder:"libmp3lame",kbps:128}:{codec:"MP3",encoders:["libmp3lame"]};case"flac":return{encoder:"flac"};case"wav":return{encoder:"pcm_s16le"};case"aiff":return{encoder:"pcm_s16be"};case"ogg":return o("libvorbis")?{encoder:"libvorbis",kbps:128}:{encoder:"vorbis",kbps:128,args:["-strict","-2","-ac","2"]};default:return{encoder:t==="darwin"&&o("aac_at")?"aac_at":"aac",kbps:128}}}var G=e=>Math.max(2,Math.floor(e/2)*2),Gt=e=>String(Math.round(e*1e3)/1e3),Ht=e=>String(Math.ceil(e*1e3)/1e3),Kt=e=>Math.round(38-(e-1)*20/99),Yt=e=>Math.round(50-(e-1)*30/99),Qt=e=>Math.round(40-(e-1)*18/99),lt=e=>Math.round(20+e*60/100),Zt=e=>Math.round(31-(e-1)*29/99);function Xt(e,t){let o=.15*2**((18-e)/6);return Math.max(64,Math.round(t*o/1e3))}function jt(e,t,o,n,s){let r=e.width,i=e.height;if(o)r=o.width,i=o.height;else{t.crop?.box&&(r=t.crop.box.width,i=t.crop.box.height);let a=t.resize;if(a&&"width"in a){let f=Math.min(a.width,r)/r;r*=f,i*=f}else if(a&&"height"in a){let f=Math.min(a.height,i)/i;r*=f,i*=f}else a&&(r*=a.percent/100,i*=a.percent/100)}return r*i*(n??e.fps*s)}var eo="zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";function gt(e){let t=[],o=e;for(;o>2;)t.push("atempo=2"),o/=2;for(;o<.5;)t.push("atempo=0.5"),o/=.5;return t.push(`atempo=${Math.round(o*1e3)/1e3}`),t}var to=800,oo=15,ht=32;function he(e){let{facts:t,options:o,target:n,platform:s}=e,r=o.media??{},i=t.video,a=t.audio,f=S[n].media==="sound",p=n==="gif",d=o.compress!==void 0,w=s==="darwin",l=c=>e.has===void 0||e.has.has(c),h=c=>We(n,c,e.os??s),g=r.cut?.start??0,I=Math.min(r.cut?.end??t.duration,t.duration),b=Math.max(0,I-g),y=r.speed??1,$=b/y,u=i!==void 0&&!f,x=a!==void 0&&!r.mute&&!p,P,E,v,O;if(r.targetBytes!==void 0&&$>0){if(u&&i){let c=st({duration:$,width:i.width,height:i.height,fps:i.fps,hasAudio:x,targetBytes:r.targetBytes});"videoKbps"in c&&(P={width:c.width,height:c.height,fps:c.fps},v=c.videoKbps,E=c.audioKbps)}else if(x){let c=Math.floor(r.targetBytes*8/$/1e3*.98);O=Math.max(ht,Math.min(320,c))}}let F=[];if(u&&i){if(i.hdr&&n!=="hevc"&&l("zscale")&&F.push(eo),o.crop?.box){let c=o.crop.box;F.push(`crop=${G(c.width)}:${G(c.height)}:${c.left}:${c.top}`)}if(P)F.push(`scale=${P.width}:${P.height}`);else if(o.resize){let c=o.resize;"width"in c?F.push(`scale=trunc(min(${G(c.width)}\\,iw)/2)*2:-2`):"height"in c?F.push(`scale=-2:trunc(min(${G(c.height)}\\,ih)/2)*2`):F.push(`scale=trunc(iw*${c.percent/100}/2)*2:-2`)}if(o.rotate&&F.push(o.rotate===90?"transpose=1":o.rotate===270?"transpose=2":"hflip,vflip"),y!==1&&F.push(`setpts=PTS/${y}`),p){let c=Math.min(to,G(i.width));F.push(`fps=${Math.min(oo,i.fps)},scale=${c}:-2:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=4`)}}let Y=P?.fps??r.fps,Ie=u&&i!==void 0&&F.length===0&&Y===void 0&&!d&&r.targetBytes===void 0&&(zt[n]??[]).includes(i.codec),m=[],ae=!1;if(!u)m.push("-vn");else if(Ie)m.push("-c:v","copy");else{if(F.length&&m.push("-vf",F.join(",")),p)m.push("-c:v","gif","-loop","0");else if(n==="webm"){if(!l("libvpx-vp9"))throw h({codec:"VP9",encoders:["libvpx-vp9"]});if(ae=v!==void 0,m.push("-c:v","libvpx-vp9","-row-mt","1","-deadline","good","-cpu-used","4"),i?.codec==="gif"&&m.push("-pix_fmt","yuva420p"),v!==void 0)m.push("-b:v",`${v}k`);else{let c=d?Yt(o.quality??60):33;m.push("-crf",String(c),"-b:v","0")}}else if(n==="hevc"){let c=l("libx265"),k=w&&l("hevc_videotoolbox");if(!c&&!k)throw h({codec:"HEVC",encoders:["libx265",...w?["hevc_videotoolbox"]:[]]});if(v!==void 0)c?m.push("-c:v","libx265","-preset","fast","-b:v",`${v}k`):m.push("-c:v","hevc_videotoolbox","-b:v",`${v}k`);else if(k&&(!d||!c)){let D=d?lt(o.quality??60):60;m.push("-c:v","hevc_videotoolbox","-q:v",String(D))}else{let D=d?Qt(o.quality??60):26;m.push("-c:v","libx265","-crf",String(D),"-preset","fast")}m.push("-tag:v","hvc1","-pix_fmt",i?.hdr?"p010le":"yuv420p")}else{let c=d?Kt(o.quality??60):21,k=()=>`${v??Xt(c,i?jt(i,o,P,Y,y):0)}k`;if(v===void 0&&!d&&w&&l("h264_videotoolbox"))m.push("-c:v","h264_videotoolbox","-q:v","65");else if(l("libx264"))ae=v!==void 0,v!==void 0?m.push("-c:v","libx264","-preset","medium","-b:v",`${v}k`):d?m.push("-c:v","libx264","-preset","medium","-crf",String(c)):m.push("-c:v","libx264","-preset","veryfast","-crf","21");else if(w&&l("h264_videotoolbox"))v!==void 0?m.push("-c:v","h264_videotoolbox","-b:v",k()):m.push("-c:v","h264_videotoolbox","-q:v",String(lt(o.quality??60)));else if(l("libopenh264"))m.push("-c:v","libopenh264","-b:v",k());else if(s==="win32"&&l("h264_mf"))m.push("-c:v","h264_mf","-b:v",k());else if(n==="avi")if(v!==void 0)m.push("-c:v","mpeg4","-b:v",`${v}k`);else{let D=d?Zt(o.quality??60):3;m.push("-c:v","mpeg4","-q:v",String(D))}else throw h({codec:"H.264",encoders:["libx264",...w?["h264_videotoolbox"]:[],"libopenh264",...s==="win32"?["h264_mf"]:[]]});m.push("-pix_fmt","yuv420p")}Y!==void 0?m.push("-r",String(Y)):n==="avi"?m.push("-fps_mode","cfr"):p||m.push("-fps_mode","passthrough")}let Re=r.cleanup?[...Wt]:[],Q=[...Re,...y!==1?gt(y):[]],B=r.loudness;B!==void 0&&Q.push(`loudnorm=I=${B}:TP=-1.5:LRA=11:${ge}:linear=true`);let $e=r.bitrate??E??O,_e=x&&a!==void 0&&Q.length===0&&$e===void 0&&!(d&&f)&&(qt[n]??[]).includes(a.codec),_=[];if(!x)_.push("-an");else if(_e)_.push("-c:a","copy");else{Q.length&&_.push("-af",Q.join(","));let c=Vt(n,s,l);if("codec"in c)throw h(c);_.push("-c:a",c.encoder);let k=$e??c.kbps;if(k!==void 0&&c.kbps!==void 0&&_.push("-b:a",`${k}k`),c.args&&_.push(...c.args),!c.args?.includes("-ac")&&E!==void 0&&E<=ht&&_.push("-ac","1"),B!==void 0&&a){let D=!c.rates||c.rates.includes(a.sampleRate);_.push("-ar",String(D?a.sampleRate:c.rates?.[0]))}}let ce=[];g>0&&ce.push("-ss",Ht(g)),r.cut&&ce.push("-t",Gt(b));let z=[...ce,"-i",e.input],q=[],fe=[...u?["-map","0:v:0"]:[],...x?["-map","0:a:0"]:[]],ke=o.keepMetadata?[]:["-map_metadata","-1"],At=Ut[n]??n,Me=["mp4","hevc","mov","m4a"].includes(n)?["-movflags","+faststart"]:[],Oe=["-f",At,"-y",e.output],pe=s==="win32"?"NUL":"/dev/null",L=[];return r.cleanup&&L.push({args:[...z,...q,"-vn","-af",Ct,"-f","null",pe],measures:"noise"}),B!==void 0&&L.push({args:[...z,...q,"-vn","-af",`${[...Re,...y!==1?gt(y):[]].map(c=>`${c},`).join("")}loudnorm=I=${B}:TP=-1.5:LRA=11:print_format=json`,"-f","null",pe],measures:"loudness",pass:{at:1,of:2}}),ae?(L.push({args:[...z,...q,...fe.slice(0,2),...m,"-pass","1","-passlogfile",e.passlog,"-an","-f","null",pe],pass:{at:1,of:2}}),L.push({args:[...z,...q,...fe,...m,"-pass","2","-passlogfile",e.passlog,..._,...ke,...Me,...Oe],pass:{at:2,of:2}})):L.push({args:[...z,...q,...fe,...m,..._,...ke,...Me,...Oe],...B!==void 0?{pass:{at:2,of:2}}:{}}),{steps:L,duration:$,copies:{video:Ie,audio:_e},...P?{fitted:P}:{}}}var W=(e,t,o)=>e.subarray(t,t+o).toString("latin1"),no=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1","avif","avis","crx "]),ro=new Set(["M4A ","M4B ","M4P ","F4A ","F4B "]);function so(e){let t=W(e,8,4);if(!no.has(t))return t==="qt "?"mov":ro.has(t)?"m4a":"mp4"}function vt(e){if(e.length<4)return;if(W(e,4,4)==="ftyp")return so(e);if(e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163)return e.includes("webm",0,"latin1")?"webm":"mkv";let t=W(e,0,4);if(t==="RIFF"){let o=W(e,8,4);return o==="WAVE"?"wav":o==="AVI "?"avi":void 0}if(t==="FORM"){let o=W(e,8,4);return o==="AIFF"||o==="AIFC"?"aiff":void 0}if(t==="fLaC")return"flac";if(t==="OggS")return e.includes("OpusHead",0,"latin1")?"opus":"ogg";if(W(e,0,3)==="ID3"||e[0]===255&&((e[1]??0)&224)===224&&((e[1]??0)&6)===2)return"mp3"}var mo=["mp4","mov","webm","mkv","avi","gif"],yt=["mp4","mov","hevc","webm","mkv","avi","gif","mp3","m4a","wav"],lo=["mp3","m4a","wav","aiff","flac","opus","ogg"],go=["mp3","m4a","opus","flac","aiff","wav"];async function ho(e){let t=await co(e,"r");try{let o=Buffer.alloc(64),{bytesRead:n}=await t.read(o,0,o.length,0);return o.subarray(0,n)}finally{await t.close()}}function wo(e,t){return t&&!t.video&&(e==="mp4"||e==="mov")?"m4a":e}async function xt(e,t){let o=vt(await ho(e));if(!o)throw new Error("not video or sound");if(o!=="mp4"&&o!=="mov"&&S[o].media!==t)throw new Error(`not ${t}`);let n=(await ne(e)).size,s=await ue(),r;if(s){try{r=await me(e,s)}catch(a){throw Z(e,a)}if(r.duration<=0||!r.video&&!r.audio)throw Z(e,r)}let i=wo(o,r);if(S[i].media!==t)throw new Error(`not ${t}`);return{kind:"media",path:e,format:i,bytes:n,...r?{facts:r}:{}}}async function vo(){let{assetFor:e,catalogEntry:t}=await import("./catalog-FMHWWMUX.js"),o=t("video");return o!==void 0&&e(o)!==void 0}async function bo(e,t){if(e.kind==="media"&&e.facts)return e.facts;try{return await me(e.path,t)}catch(o){throw Z(e.path,o)}}function yo(e,t){let o=e.options.media??{},n=o.cut?.start??0,s=Math.min(o.cut?.end??t,t);return Math.max(0,s-n)/(o.speed??1)}function Pt(e,t){if(e.op!=="convert")return;let o=e.sources[0],n=o.kind==="media"?o.facts:void 0;if(!n)return;let s=e.options.media??{},r=it({...n,duration:yo(e,n.duration)},{soundOnly:S[e.target].media==="sound",mute:s.mute===!0||e.target==="gif"});return t<r?{floor:r}:void 0}function xo(e){let t=e.slice(e.lastIndexOf("{"),e.lastIndexOf("}")+1),o=JSON.parse(t);return[`measured_I=${o.input_i}`,`measured_TP=${o.input_tp}`,`measured_LRA=${o.input_lra}`,`measured_thresh=${o.input_thresh}`,`offset=${o.target_offset}`].join(":")}async function bt(e){await Promise.all(e.map(t=>fo(t,{force:!0}).catch(()=>{})))}async function Ft(e,t,o){if(e.op!=="convert")throw new Error(`media engines only convert, not ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=await ue();if(!r)throw Je(n.path,process.platform,await vo());let i=await bo(n,r),a=ao(6).toString("hex"),f=qe(s,a),p=uo(po(s),`.forge-pass-${a}`),d=[f,`${p}-0.log`,`${p}-0.log.temp`,`${p}-0.log.mbtree`,`${p}-0.log.mbtree.temp`],w=[],l=(u,x=e.options)=>he({input:n.path,output:f,target:e.target,facts:i,options:x,platform:u,os:process.platform,passlog:p,...r.has?{has:r.has}:{}}),h=e.options,g=l(process.platform);if(g.duration<=0)throw Te(`The cut keeps nothing of ${A(n.path)}: it starts at or after its end.`,`It is ${te(i.duration)} long.`);await Ve(s);let I=process.platform,b=h.media?.cut;if(g.copies.video&&b&&b.start>0){let u=await ct(n.path,b.start,r);u!==void 0&&b.start-u>.05&&(h={...h,media:{...h.media,cut:{...b,start:u}}},g=l(process.platform,h),w.push({code:"media-cut-keyframe",message:`It starts at ${te(u)}, the keyframe just before ${te(b.start)}.`}))}let y=async u=>{let x="",P="";for(let E of u.steps){let v=E.args.map(F=>F.replace(ge,x).replace(le,P)),O=await ft(v,{tools:r,signal:o,report:E.measures!==void 0,onTime:F=>t({phase:"time",done:Math.min(F,u.duration),total:u.duration,...E.pass?{pass:E.pass}:{}})});E.measures==="loudness"&&(x=xo(O)),E.measures==="noise"&&(P=String(wt(O)))}};try{try{await y(g)}catch(P){if(o?.aborted||!g.steps.some(E=>E.args.some(v=>v.endsWith("_videotoolbox"))))throw P;I="linux",g=l(I,h),await y(g)}let u=h.media?.targetBytes;for(let P of[.95,.9]){if(u===void 0||(await ne(f)).size<=u)break;h={...h,media:{...h.media,targetBytes:Math.floor(u*P)}},g=l(I,h),await y(g)}let x=(await ne(f)).size;if(u!==void 0&&x>u)throw Ae(n,e.options.media?.targetBytes??u,x);if(e.options.compress!==void 0&&x>=n.bytes)throw j(n.path,n.bytes,x);await Ge(f,s)}catch(u){throw await bt(d),o?.aborted||T(u)?u:J(n.path,u)}await bt(d.slice(1));let $=i.video;if(g.fitted&&$&&(g.fitted.width<$.width-2||g.fitted.fps<$.fps)){let u=De(e.options.media?.targetBytes??0);w.push({code:"media-fitted",message:`To fit ${u} it is now ${g.fitted.width}\xD7${g.fitted.height} at ${g.fitted.fps} fps.`})}return{job:e,outputBytes:(await ne(s)).size,warnings:w}}function Wn(e,t){if(e.kind!=="media"||!e.facts)return;let o=at()?.has;if(o)try{he({input:e.path,output:e.path,target:t,facts:e.facts,options:{background:"#ffffff",keepMetadata:!1},platform:process.platform,passlog:"",has:o});return}catch(n){return T(n)&&n.code==="encoder-missing"?n:void 0}}var H=e=>new Set(e);function Po(e){let t=e.kind==="media"?e.facts:void 0,o=e.kind==="image"||t!==void 0&&t.audio===void 0;return H(yt.filter(n=>!(o&&S[n].media==="sound"||n==="hevc"&&t?.video?.codec==="hevc")))}var Et={id:"video",reads:H(mo),writes:H(yt),ops:new Set(["convert"]),probe:e=>xt(e,"video"),run:Ft,sizeTo:Pt,writesFor:Po},St={id:"sound",reads:H(lo),writes:H(go),ops:new Set(["convert"]),probe:e=>xt(e,"sound"),run:Ft,sizeTo:Pt};import{readFile as re,rm as $t,stat as Fo}from"node:fs/promises";function zn(e,t){let o=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(o.length===0)throw V(e,"That selects no pages.",t);let n=new Set,s=(r,i)=>{if(!Number.isInteger(r)||r<1||r>t)throw V(i,`"${i}" is outside 1 and ${t}.`,t);return r};for(let r of o){let i=r.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let a=s(Number(i[1]),r),f=i[2]===""?t:s(Number(i[2]),r);if(f<a)throw V(r,`"${r}" ends before it starts.`,t);for(let p=a;p<=f;p++)n.add(p-1);continue}if(!/^\d+$/.test(r))throw V(r,`"${r}" is not a page number.`,t);n.add(s(Number(r),r)-1)}return[...n].sort((r,i)=>r-i)}function It(e){return[...new Set(e)].sort((t,o)=>t-o)}function qn(e){if(e.length===0)return"";let t=[...new Set(e)].sort((r,i)=>r-i),o=[],n=t[0],s=n;for(let r of t.slice(1)){if(r===s+1){s=r;continue}o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),n=r,s=r}return o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),o.join(", ")}function Rt(e,t){let o=[...new Set(e)].sort((r,i)=>r-i).filter(r=>r>=0&&r<t-1),n=[],s=0;for(let r of o)n.push({from:s,to:r}),s=r+1;return n.push({from:s,to:t-1}),n}var ve=He(()=>import("./pdf-compress-U2E3CNXG.js")),Eo=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),So=new Set(["pdf"]);async function C(e){return(await M()).PDFDocument.load(await re(e),{ignoreEncryption:!0})}async function Io(e){let{surveyDocument:t}=await ve(),o=await C(e),{size:n}=await Fo(e);return{kind:"document",path:e,format:"pdf",bytes:n,pages:o.getPageCount(),encrypted:o.isEncrypted,images:t(o)}}function U(e){for(let t of e)if(t.encrypted)throw X(t.path)}async function Ro(e,t,o){let n=await ee(),s=t.format==="jpeg"||t.format==="png",r=s?(await n(o).metadata()).orientation:void 0;if(s&&(r===void 0||r===1))return t.format==="jpeg"?e.embedJpg(o):e.embedPng(o);if(t.format==="jpeg"){let i=await n(o).rotate().jpeg({quality:S.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await n(o).rotate().png().toBuffer())}async function $o(e,t){let o=e.sources[0];if(o.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let n=[];o.frames>1&&n.push({code:"animation-flattened",message:`${A(o.path)} has ${o.frames} frames, and ${S.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let s=await re(o.path);t({phase:"encoding"});let i=await(await M()).PDFDocument.create(),a=await Ro(i,o,s);i.addPage([a.width,a.height]).drawImage(a,{x:0,y:0,width:a.width,height:a.height}),t({phase:"writing"});let p=await R(e.outputs[0],await i.save());return{job:e,outputBytes:p,warnings:n}}async function _o(e,t){U(e.sources.filter(i=>i.kind==="document"));let n=await(await M()).PDFDocument.create();for(let i of e.sources){t({phase:"reading"});let a=await C(i.path),f=await n.copyPages(a,a.getPageIndices());for(let p of f)n.addPage(p)}t({phase:"writing"});let s=await n.save(),r=await R(e.outputs[0],s);return{job:e,outputBytes:r,warnings:[]}}async function ko(e,t){let o=e.sources[0];U([o]);let n=await M();t({phase:"reading"});let s=await C(o.path),r=Rt(e.cuts,s.getPageCount()),i=[],a=0;try{for(let[f,p]of r.entries()){let d=await n.PDFDocument.create(),w=Array.from({length:p.to-p.from+1},(g,I)=>p.from+I),l=await d.copyPages(s,w);for(let g of l)d.addPage(g);let h=e.outputs[f];if(h===void 0)throw new Error(`split produced ${r.length} parts but was given ${e.outputs.length} outputs`);a+=await R(h,await d.save()),i.push(h),t({phase:"page",done:f+1,total:r.length})}}catch(f){throw await Promise.all(i.map(p=>$t(p,{force:!0}))),f}return{job:e,outputBytes:a,warnings:[]}}async function we(e,t){let n=await(await M()).PDFDocument.create(),s=await n.copyPages(e,t);for(let r of s)n.addPage(r);return n.save()}async function Mo(e,t){let o=e.sources[0];if(U([o]),e.pages.length===0)throw de("That extract selects no pages.");t({phase:"reading"});let n=await C(o.path),s=It(e.pages),r=[],i=0;try{if(e.separate)for(let[a,f]of s.entries()){let p=e.outputs[a];i+=await R(p,await we(n,[f])),r.push(p),t({phase:"page",done:a+1,total:s.length})}else{t({phase:"writing"});let a=e.outputs[0];i=await R(a,await we(n,s)),r.push(a)}}catch(a){throw await Promise.all(r.map(f=>$t(f,{force:!0}))),a}return{job:e,outputBytes:i,warnings:[]}}async function Oo(e,t){let o=e.sources[0];U([o]),t({phase:"reading"});let n=await C(o.path),s=new Set(e.pages),r=n.getPageIndices().filter(a=>!s.has(a));if(r.length===0)throw de("That would delete every page.");t({phase:"writing"});let i=await R(e.outputs[0],await we(n,r));return{job:e,outputBytes:i,warnings:[]}}async function Do(e,t){let o=e.sources[0];U([o]);let n=await M();t({phase:"reading"});let s=await C(o.path);for(let i of s.getPages()){let f=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(n.degrees(f))}t({phase:"writing"});let r=await R(e.outputs[0],await s.save());return{job:e,outputBytes:r,warnings:[]}}async function Ao(e,t){let o=e.sources[0];U([o]);let{compressPdf:n}=await ve();t({phase:"reading"});let s=await re(o.path);t({phase:"encoding"});let{bytes:r,recompressed:i,skipped:a,fromDpi:f,toDpi:p}=await n(s,{quality:e.options.quality??60,dpi:e.options.dpi??150});if(e.options.compress&&r.length>=o.bytes)throw j(o.path,o.bytes,r.length);t({phase:"writing"});let d=await R(e.outputs[0],r),w=h=>h===1?"":"s",l=[];return i===0&&a===0?l.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?l.push({code:"pdf-no-images",message:`None of its ${a} image${w(a)} could be re-encoded \u2014 they are not JPEG data.`}):a>0&&l.push({code:"pdf-images-skipped",message:`${i} image${w(i)} recompressed, ${a} skipped (not JPEG).`}),f!==void 0&&p!==void 0&&l.push({code:"pdf-downsampled",message:`Images reduced from ${f} to ${p} dpi. Pass --dpi ${f} to keep them.`}),{job:e,outputBytes:d,warnings:l}}async function To(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:o}=await ve(),n=await re(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(s=>({dpi:s})),measure:async s=>(await o(n,{quality:s.quality??60,...s.dpi===void 0?{}:{dpi:s.dpi}})).bytes.byteLength}}var _t={id:"pdf",measurer:To,reads:Eo,writes:So,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:Io,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Ao(e,t):$o(e,t);case"merge":return _o(e,t);case"split":return ko(e,t);case"extract":return Mo(e,t);case"delete":return Oo(e,t);case"rotate":return Do(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as No}from"node:child_process";import{mkdtemp as Bo,readFile as Ee,rm as Lo}from"node:fs/promises";import{tmpdir as Jo}from"node:os";import{basename as Wo,extname as Co,join as kt,win32 as Pe}from"node:path";import{pathToFileURL as Uo}from"node:url";import{promisify as zo}from"node:util";var Fe=zo(No),be=Buffer.from([208,207,17,224,161,177,26,225]);async function qo(e){if(e.length<be.length||!e.subarray(0,be.length).equals(be))return!1;let t=await Ze();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function Vo(e){let t=await Qe();try{let o=new t(e);if(!o.getEntry("word/document.xml"))return;let n=0,s=o.getEntry("docProps/app.xml");if(s){let r=/<Pages>(\d+)<\/Pages>/.exec(o.readAsText(s));r?.[1]&&(n=Number(r[1]))}return{pages:n}}catch{return}}async function Go(e){let t=await Ee(e),o=await Vo(t);if(o)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:o.pages,encrypted:!1};if(await qo(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}function Ho(e,t){return e==="win32"?[Pe.join(t.ProgramFiles??"C:\\Program Files","LibreOffice","program","soffice.exe"),Pe.join(t["ProgramFiles(x86)"]??"C:\\Program Files (x86)","LibreOffice","program","soffice.exe")]:["/Applications/LibreOffice.app/Contents/MacOS/soffice"]}var Ko=0;async function Yo(){Ko++;try{return await Fe("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}for(let e of Ho(process.platform,process.env))try{return await Fe(e,["--version"],{timeout:5e3}),e}catch{}}var Mt,Qo=!1,Zo;async function Xo(){return Qo?Zo:(Mt??=Yo(),Mt)}var Se="\f";function se(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function jo(e){if(e.format==="docx"){let o=await Ke(),{value:n}=await o.extractRawText({path:e.path});return se(n)}if(e.format==="doc"){let o=await Ye(),s=await new o().extract(e.path);return se(s.getBody())}return(await nt(await Ee(e.path))).flatMap((o,n)=>n===0?se(o):[Se,...se(o)])}var ye=612,ie=792,N=54,xe=11,Ot=14;async function en(e){let{PDFDocument:t,StandardFonts:o}=await M(),n=await t.create(),s=await n.embedFont(o.Helvetica),r=ye-N*2,i=n.addPage([ye,ie]),a=ie-N,f=()=>{i=n.addPage([ye,ie]),a=ie-N};for(let p of e){if(p===Se){f();continue}let d="";for(let w of p.split(/\s+/).filter(Boolean)){let l=d?`${d} ${w}`:w;d&&s.widthOfTextAtSize(l,xe)>r?(a<N&&f(),i.drawText(d,{x:N,y:a,size:xe,font:s}),a-=Ot,d=w):d=l}d&&(a<N&&f(),i.drawText(d,{x:N,y:a,size:xe,font:s}),a-=Ot)}return n.save()}async function tn(e){let{Document:t,Packer:o,PageBreak:n,Paragraph:s}=await Xe(),r=e.map(a=>a===Se?new s({children:[new n]}):new s(a)),i=new t({sections:[{children:r}]});return o.toBuffer(i)}var on=new Set(["docx","doc","pdf"]),nn=new Set(["docx","pdf"]),rn=new Set(["convert"]),sn={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};function an(e=process.platform){return e==="linux"?{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: sudo apt install libreoffice"}:e!=="win32"?sn:{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice from libreoffice.org for full-fidelity conversion."}}function cn(e,t,o,n=process.platform){return[`-env:UserInstallation=${n==="win32"?Uo(Pe.join(e,"profile"),{windows:!0}).href:`file://${e}/profile`}`,"--headless","--convert-to",o,"--outdir",e,t]}async function fn(e,t,o){let n=await Bo(kt(Jo(),"forge-word-"));try{await Fe(e,cn(n,t,o),{timeout:12e4});let s=Wo(t,Co(t));return await Ee(kt(n,`${s}.${o}`))}finally{await Lo(n,{recursive:!0,force:!0})}}async function pn(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the word engine can only convert a document source");if(o.encrypted)throw X(o.path);t({phase:"reading"});let n=await Xo();t({phase:"encoding"});let s=[],r;try{if(n!==void 0)r=await fn(n,o.path,e.target);else{let a=await jo(o);r=e.target==="pdf"?await en(a):await tn(a),s.push(an())}}catch(a){throw J(o.path,a)}t({phase:"writing"});let i=await R(e.outputs[0],r);return{job:e,outputBytes:i,warnings:s}}var Dt={id:"word",reads:on,writes:nn,ops:rn,probe:Go,run:pn};var K=[ot,Et,St,_t,Dt,ut,rt];function vr(e){return K.find(t=>t.reads.has(e))}function br(e){return K.find(t=>t.writes.has(e))}function yr(e){if(e.op==="convert"){let t=e.sources[0].format;return K.find(o=>o.reads.has(t)&&o.writes.has(e.target))}return K.find(t=>t.ops.has(e.op))}async function xr(e){let t;for(let o of K)try{return await o.probe(e)}catch(n){T(t)||(t=n)}throw t}export{zn as a,It as b,qn as c,Rt as d,Wn as e,K as f,vr as g,br as h,yr as i,xr as j};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{r as F}from"./chunk-DZOBIUV6.js";import{execFile as vn}from"node:child_process";import{chmodSync as le,existsSync as Ke,mkdirSync as pe,readdirSync as Ge,readFileSync as H,rmdirSync as Mn,rmSync as $,writeFileSync as In}from"node:fs";import{dirname as U,join as u}from"node:path";var tn={convert:"#55c7d9",compress:"#79c98b",edit:"#b39ae8",pdf:"#ff6b4a"},rn="#55c7d9",on="#a68ce0",sn=4/5,an=(e,n,t,r)=>`<path fill="${r}" d="M${e} ${n}h${4*t}v${t}h${-3*t}v${t}h${2*t}v${t}h${-2*t}v${2*t}h${-t}z"/>`;function cn(e,n){let t=n<=20,r=t?3:4,i=t?6:4.6,o=t?51:51.5,c=Array.from({length:r},(g,w)=>o-(r-1-w)*i).map(g=>`<line x1="${g}" y1="66" x2="${g+66*sn}" y2="0"/>`).join(""),f=e==="forge"?"url(#w)":tn[e];return`<svg width="${n}" height="${n}" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="w" gradientUnits="userSpaceOnUse" x1="34" y1="0" x2="62" y2="0"><stop offset="0" stop-color="${rn}"/><stop offset="1" stop-color="${on}"/></linearGradient><clipPath id="c"><rect width="64" height="64" rx="14"/></clipPath><clipPath id="i"><rect x="1.5" y="1.5" width="61" height="61" rx="12.5"/></clipPath></defs><g clip-path="url(#c)"><rect width="64" height="64" fill="#1e1e1e"/><g clip-path="url(#i)" stroke="${f}" stroke-width="${t?3.6:2.4}">${c}</g>${an(16,12,8,"#e7e7e7")}</g><rect x=".75" y=".75" width="62.5" height="62.5" rx="13.5" fill="none" stroke="#3a3a3a" stroke-width="1.5"/></svg>`}async function S(e,n){let{default:t}=await import("sharp");return t(Buffer.from(cn(e,n))).png().toBuffer()}function he(e){let n=Buffer.alloc(6);n.writeUInt16LE(0,0),n.writeUInt16LE(1,2),n.writeUInt16LE(e.length,4);let t=6+16*e.length,r=e.map(({size:i,png:o})=>{let s=Buffer.alloc(16);return s[0]=i>=256?0:i,s[1]=i>=256?0:i,s.writeUInt16LE(1,4),s.writeUInt16LE(32,6),s.writeUInt32LE(o.length,8),s.writeUInt32LE(t,12),t+=o.length,s});return Buffer.concat([n,...r,...e.map(i=>i.png)])}function y(e){let n=[{action:"open",label:"Open Forge",kinds:["image","folder"],window:!0,paint:"forge"},{action:"convert",label:"Convert in Forge",kinds:["image","folder"],window:!0,paint:"convert"},{action:"compress",label:"Compress in Forge",kinds:["image","folder"],window:!0,paint:"compress"},{action:"sharpen",label:"Sharpen in Forge",kinds:["image"],window:!1,paint:"edit"},{action:"open-pdf",label:"Open in Forge",kinds:["pdf"],window:!0,paint:"pdf"}],t=(e.presets??[]).map(r=>({action:"preset",preset:r,label:`${r} in Forge`,kinds:["image"],window:!1,paint:"forge"}));return[...e.sharpen?n:n.filter(r=>r.action!=="sharpen"),...t]}var $e=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function B(e,n){if(typeof e=="string")return`${n}<string>${$e(e)}</string>`;if(typeof e=="number")return`${n}<integer>${e}</integer>`;if(typeof e=="boolean")return`${n}<${e}/>`;if(Array.isArray(e))return`${n}<array>
|
|
4
|
-
${e.map(r=>B(r,`${n} `)).join(`
|
|
5
|
-
`)}
|
|
6
|
-
${n}</array>`;let t=Object.entries(e).map(([r,i])=>`${n} <key>${$e(r)}</key>
|
|
7
|
-
${B(i,`${n} `)}`);return t.length===0?`${n}<dict/>`:`${n}<dict>
|
|
8
|
-
${t.join(`
|
|
9
|
-
`)}
|
|
10
|
-
${n}</dict>`}var ye=e=>`<?xml version="1.0" encoding="UTF-8"?>
|
|
11
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
12
|
-
<plist version="1.0">
|
|
13
|
-
${B(e,"")}
|
|
14
|
-
</plist>
|
|
15
|
-
`,un={image:"public.image",folder:"public.folder",pdf:"com.adobe.pdf"};function fn(e){return e.length===1&&e[0]==="image"?"com.apple.Automator.fileSystemObject.image":e.length===1&&e[0]==="pdf"?"com.apple.Automator.fileSystemObject.PDF":e.length===1&&e[0]==="folder"?"com.apple.Automator.fileSystemObject.folder":"com.apple.Automator.fileSystemObject"}var a=e=>`'${e.replace(/'/g,"'\\''")}'`,j="forge",xe=e=>e.preset===void 0?`com.forge-terminal.menu.${e.action}`:`com.forge-terminal.menu.preset.${e.preset}`,we="com.forge-terminal.menu.",Se="runWorkflowAsService",E=e=>`${xe(e)} - ${e.label} - ${Se}`,ln=`ObjC.import('Foundation')
|
|
16
|
-
function run(argv) {
|
|
17
|
-
const domain = argv[0]
|
|
18
|
-
const defaults = $.NSUserDefaults.standardUserDefaults
|
|
19
|
-
const or = (v) => (v.isNil() ? $.NSDictionary.dictionary : v)
|
|
20
|
-
const all = $.NSMutableDictionary.dictionaryWithDictionary(or(defaults.persistentDomainForName(domain)))
|
|
21
|
-
const status = $.NSMutableDictionary.dictionaryWithDictionary(or(all.objectForKey('NSServicesStatus')))
|
|
22
|
-
const on = { presentation_modes: { ContextMenu: true, FinderPreview: true, ServicesMenu: true, TouchBar: true } }
|
|
23
|
-
for (const arg of argv.slice(1)) {
|
|
24
|
-
const key = arg.slice(1)
|
|
25
|
-
if (arg[0] === '+') status.setObjectForKey($(on), key)
|
|
26
|
-
else status.removeObjectForKey(key)
|
|
27
|
-
}
|
|
28
|
-
all.setObjectForKey(status, 'NSServicesStatus')
|
|
29
|
-
defaults.setPersistentDomainForName(all, domain)
|
|
30
|
-
}`;function D(e){return[e.osascript??"/usr/bin/osascript",["-l","JavaScript","-e",ln,e.domain??"pbs",...e.on.map(n=>`+${n}`),...e.off.map(n=>`-${n}`)]]}function _(e,n){let t=ye({CFBundleDevelopmentRegion:"English",CFBundleIdentifier:xe(e),CFBundleInfoDictionaryVersion:"6.0",CFBundleName:e.label,CFBundlePackageType:"BNDL",CFBundleShortVersionString:"1.0",CFBundleVersion:"1",NSServices:[{NSIconName:j,NSMenuItem:{default:e.label},NSMessage:Se,NSRequiredContext:{NSApplicationIdentifier:"com.apple.finder"},NSSendFileTypes:e.kinds.map(s=>un[s])}]}),r=e.preset===void 0?"":` ${a(e.preset)}`,i=`${a(n)} ${e.action}${r} "$@"`,o=ye({AMApplicationBuild:"521",AMApplicationVersion:"2.10",AMDocumentVersion:"2",actions:[{action:{AMAccepts:{Container:"List",Optional:!0,Types:["com.apple.cocoa.path"]},AMActionVersion:"2.0.3",AMApplication:["Automator"],AMParameterProperties:{COMMAND_STRING:{},CheckedForUserDefaultShell:{},inputMethod:{},shell:{},source:{}},AMProvides:{Container:"List",Types:["com.apple.cocoa.string"]},ActionBundlePath:"/System/Library/Automator/Run Shell Script.action",ActionName:"Run Shell Script",ActionParameters:{COMMAND_STRING:i,CheckedForUserDefaultShell:!0,inputMethod:1,shell:"/bin/zsh",source:""},BundleIdentifier:"com.apple.RunShellScript",CFBundleVersion:"2.0.3",CanShowSelectedItemsWhenRun:!1,CanShowWhenRun:!0,Category:["AMCategoryUtilities"],"Class Name":"RunShellScriptAction",InputUUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A01",OutputUUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A02",UUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A03",UnlocalizedApplications:["Automator"]},isViewVisible:!0}],connectors:{},workflowMetaData:{serviceApplicationBundleID:"com.apple.finder",serviceApplicationPath:"/System/Library/CoreServices/Finder.app",serviceInputTypeIdentifier:fn(e.kinds),serviceOutputTypeIdentifier:"com.apple.Automator.nothing",serviceProcessesInput:!1,workflowTypeIdentifier:"com.apple.Automator.servicesMenu"}});return{name:`${e.label}.workflow`,files:{"Contents/Info.plist":t,"Contents/document.wflow":o,"Contents/Resources/document.wflow":o}}}import{execFile as xn}from"node:child_process";import{accessSync as pn,constants as mn}from"node:fs";import{isAbsolute as De,join as p}from"node:path";var d="forge-terminal-menu";function ve(e){let n=r=>r&&De(r)?r:void 0,t=(e.xdgConfigDirs??"").split(":").filter(r=>De(r));return{dataHome:n(e.xdgDataHome)??p(e.home,".local","share"),configHome:n(e.xdgConfigHome)??p(e.home,".config"),configDirs:t.length>0?t:["/etc/xdg"]}}function K(e,n=process.env.PATH){for(let t of(n??"").split(":"))if(t!=="")try{return pn(p(t,e),mn.X_OK),!0}catch{}return!1}var Me={image:"image/*",folder:"inode/directory",pdf:"application/pdf"},gn=e=>e.map(n=>`${Me[n]};`).join(""),P=e=>`${e.paint}.png`,h=e=>p(e.dataHome,"nautilus","scripts","Forge"),b=e=>e.preset===void 0?e.action:`preset-${e.preset}`,k=e=>e.preset===void 0?e.action:`preset ${e.preset}`,G=e=>e.label;function Ie(e,n){return`#!/bin/sh
|
|
31
|
-
# ${d}: Forge's right-click menu, written by Forge. \`forge menu remove\` takes it out.
|
|
32
|
-
if [ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
|
|
33
|
-
IFS='
|
|
34
|
-
'
|
|
35
|
-
set -f
|
|
36
|
-
set -- $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
|
|
37
|
-
fi
|
|
38
|
-
exec ${a(n)} ${k(e)} "$@"
|
|
39
|
-
`}var I=e=>p(e.dataHome,"nemo","actions"),W=(e,n)=>`forge-${e.preset===void 0?n.indexOf(e.action)+1:n.length+1}-${b(e)}.nemo_action`,M=e=>e.replace(/%/g,"%%");function Ne(e,n){return`[Nemo Action]
|
|
40
|
-
# ${d}: Forge's right-click menu, written by Forge. \`forge menu remove\` takes it out.
|
|
41
|
-
Name=${M(e.label)}
|
|
42
|
-
Comment=${M(e.label)}
|
|
43
|
-
Exec=${M(a(n))} ${k(e)} %F
|
|
44
|
-
Selection=notnone
|
|
45
|
-
Mimetypes=${gn(e.kinds)}
|
|
46
|
-
`}var A=e=>p(e.dataHome,"kio","servicemenus"),V=e=>`forge-${e}.desktop`,X=["image","folder","pdf"],dn=e=>M(`"${e.replace(/[\\"`$]/g,"\\$&")}"`).replace(/\\/g,"\\\\");function Fe(e,n,t){let r=n.filter(c=>c.kinds.includes(e));if(r.length===0)return;let i=r.length>1,o=["[Desktop Entry]",`# ${d}: Forge's right-click menu, written by Forge. \`forge menu remove\` takes it out.`,"Type=Service","ServiceTypes=KonqPopupMenu/Plugin","X-KDE-ServiceTypes=KonqPopupMenu/Plugin",`MimeType=${Me[e]};`,`Actions=${r.map(c=>`${b(c)};`).join("")}`,"X-KDE-Priority=TopLevel",...i?["X-KDE-Submenu=Forge",`Icon=${p(t.menuDir,"forge.png")}`]:[]],s=r.map(c=>["",`[Desktop Action ${b(c)}]`,`Name=${c.label}`,`Icon=${p(t.menuDir,P(c))}`,`Exec=${dn(t.launcher)} ${k(c)} %F`].join(`
|
|
47
|
-
`));return`${[...o,...s].join(`
|
|
48
|
-
`)}
|
|
49
|
-
`}var C=e=>p(e.configHome,"Thunar","uca.xml"),Ee=e=>e.configDirs.map(n=>p(n,"Thunar","uca.xml")),be=`<?xml version="1.0" encoding="UTF-8"?>
|
|
50
|
-
<actions>
|
|
51
|
-
</actions>
|
|
52
|
-
`,hn=e=>`${d}-${b(e)}`,v=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),$n={image:{patterns:["*"],type:"image-files"},folder:{patterns:["*"],type:"directories"},pdf:{patterns:["*.pdf","*.PDF"],type:"other-files"}};function Pe(e,n){return e.map(t=>{let r=t.kinds.map(s=>$n[s]),i=[...new Set(r.flatMap(s=>s.patterns))],o=i.includes("*")?["*"]:i;return["<action>",` <icon>${v(p(n.menuDir,P(t)))}</icon>`,` <name>${v(t.label)}</name>`,` <submenu>${t.kinds.includes("pdf")?"":"Forge"}</submenu>`,` <unique-id>${hn(t)}</unique-id>`,` <command>${v(M(a(n.launcher)))} ${k(t)} %F</command>`,` <description>${v(t.label)}</description>`," <range></range>",` <patterns>${v(o.join(";"))}</patterns>`,...r.map(s=>` <${s.type}/>`),"</action>"].join(`
|
|
53
|
-
`)}).map(t=>`${t}
|
|
54
|
-
`).join("")}var yn=/[ \t]*<action>[\s\S]*?<\/action>[ \t]*\r?\n?/g;function J(e){return e.replace(yn,n=>n.includes(`<unique-id>${d}-`)?"":n)}function q(e,n){let t=J(e),r=t.lastIndexOf("</actions>");if(r===-1||!/<actions>/.test(t))return;let i=t.lastIndexOf(`
|
|
55
|
-
`,r)+1;return/^[ \t]*$/.test(t.slice(i,r))&&(r=i),`${t.slice(0,r)}${n}${t.slice(r)}`}var ke=(e,n,t)=>K("thunar",n)||t(p(e.configHome,"Thunar"));var Y="ForgeTerminal.Forge",Ae=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),Q=e=>e.replace(/['‘’‚‛]/g,"$&$&"),Ce=Q;function Z(e,n){return["[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null","$x = New-Object Windows.Data.Xml.Dom.XmlDocument",`$x.LoadXml('<toast><visual><binding template="ToastText02"><text id="1">${Ce(Ae(e))}</text><text id="2">${Ce(Ae(n))}</text></binding></visual></toast>')`,`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${Y}').Show([Windows.UI.Notifications.ToastNotification]::new($x))`].join("; ")}function wn(e,n,t=process.platform){return t==="win32"?["powershell.exe",["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",Z(e,n)]]:["/usr/bin/osascript",["-e","on run argv","-e","display notification (item 2 of argv) with title (item 1 of argv)","-e","end run",e,n]]}var T=e=>`"${e.replace(/[\\"]/g,"\\$&").replace(/\n/g,"\\n")}"`;function Sn(e,n,t={}){let r=t.has??(i=>K(i));if(r("notify-send"))return["notify-send",["--app-name=Forge",...t.icon?[`--icon=${t.icon}`]:[],"--",e,n]];if(r("gdbus"))return["gdbus",["call","--session","--dest","org.freedesktop.Notifications","--object-path","/org/freedesktop/Notifications","--method","org.freedesktop.Notifications.Notify",T("Forge"),"0",T(t.icon??""),T(e),T(n),"[]","{}","-1"]]}function _n(e,n,t=process.platform,r={}){let i=t==="linux"?Sn(e,n,r):wn(e,n,t);return new Promise(o=>{if(i===void 0)return o();try{xn(i[0],i[1],{timeout:1e4,windowsHide:!0},()=>o())}catch{o()}})}var z="Forge was uninstalled",ee="Its menu items are removed.",Te="Forge could not start",Oe="Run forge in a terminal once to set its menu up again.";function Le(e){let{osascript:n,pbs:t}=e.tools??{osascript:"/usr/bin/osascript",pbs:"/System/Library/CoreServices/pbs"},r=[e.node,...e.execArgv,e.forge].map(a).join(" "),[i,o]=D({on:[],off:e.services,osascript:n}),s=[i,...o].map(a).join(" "),c=(f,g)=>`${a(n)} -e 'display notification "${g}" with title "${f}"'`;return`#!/bin/sh
|
|
56
|
-
# Forge's right-click menu. Rewritten by Forge whenever it sets the menu up.
|
|
57
|
-
if [ ! -f ${a(e.forge)} ]; then
|
|
58
|
-
# Forge is gone: take its menu with it, and say so once.
|
|
59
|
-
${e.bundles.map(f=>` rm -rf ${a(f)}`).join(`
|
|
60
|
-
`)}
|
|
61
|
-
rm -rf ${a(e.menuDir)}
|
|
62
|
-
${s}
|
|
63
|
-
${a(t)} -update
|
|
64
|
-
${c(z,ee)}
|
|
65
|
-
exit 0
|
|
66
|
-
fi
|
|
67
|
-
if [ ! -x ${a(e.node)} ]; then
|
|
68
|
-
${c(Te,Oe)}
|
|
69
|
-
exit 1
|
|
70
|
-
fi
|
|
71
|
-
${e.xdgConfigHome===void 0?"":`export XDG_CONFIG_HOME=${a(e.xdgConfigHome)}
|
|
72
|
-
`}exec ${r} menu run "$@"
|
|
73
|
-
`}function Ue(e){let n=e.xdgConfigHome===void 0?{}:{XDG_CONFIG_HOME:e.xdgConfigHome};return`// Forge's right-click menu. Rewritten by Forge whenever it sets the menu up.
|
|
74
|
-
import { execFileSync, spawn } from 'node:child_process'
|
|
75
|
-
import { existsSync, rmSync } from 'node:fs'
|
|
76
|
-
|
|
77
|
-
const FORGE = ${JSON.stringify(e.forge)}
|
|
78
|
-
const ARGS = ${JSON.stringify(e.execArgv)}
|
|
79
|
-
const MENU = ${JSON.stringify(e.menuDir)}
|
|
80
|
-
const KEYS = ${JSON.stringify(e.keys)}
|
|
81
|
-
const ENV = ${JSON.stringify(n)}
|
|
82
|
-
|
|
83
|
-
if (existsSync(FORGE)) {
|
|
84
|
-
const child = spawn(process.execPath, [...ARGS, FORGE, 'menu', 'run', ...process.argv.slice(2)], {
|
|
85
|
-
stdio: 'inherit',
|
|
86
|
-
windowsHide: true,
|
|
87
|
-
env: { ...process.env, ...ENV },
|
|
88
|
-
})
|
|
89
|
-
child.on('exit', (code) => process.exit(code ?? 0))
|
|
90
|
-
} else {
|
|
91
|
-
// Forge is gone: say so while its app ID still exists, then take the menu with it.
|
|
92
|
-
try {
|
|
93
|
-
execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', ${JSON.stringify(Z(z,ee))}], { windowsHide: true })
|
|
94
|
-
} catch {}
|
|
95
|
-
for (const key of KEYS) {
|
|
96
|
-
try {
|
|
97
|
-
execFileSync('reg.exe', ['delete', key, '/f'], { windowsHide: true, stdio: 'ignore' })
|
|
98
|
-
} catch {}
|
|
99
|
-
}
|
|
100
|
-
rmSync(MENU, { recursive: true, force: true })
|
|
101
|
-
}
|
|
102
|
-
`}function Dn(){return`say() {
|
|
103
|
-
if command -v notify-send >/dev/null 2>&1; then
|
|
104
|
-
notify-send --app-name=Forge -- "$1" "$2" >/dev/null 2>&1
|
|
105
|
-
elif command -v gdbus >/dev/null 2>&1; then
|
|
106
|
-
${["gdbus call --session --dest org.freedesktop.Notifications","--object-path /org/freedesktop/Notifications","--method org.freedesktop.Notifications.Notify",`Forge 0 "''" "\\"$1\\"" "\\"$2\\"" '[]' '{}' -1`].join(" ")} >/dev/null 2>&1
|
|
107
|
-
fi
|
|
108
|
-
}`}function He(e){let n=[e.node,...e.execArgv,e.forge].map(a).join(" "),t=e.files.map(a).join(` \\
|
|
109
|
-
`),r="";if(e.thunar!==void 0){let i=a(e.thunar.file),o=a(`${e.thunar.file}.forge-tmp`),s=a(e.thunar.seed),c=['/<action>/ { held = ""; holding = 1 }',`holding { held = held $0 "\\n"; if (/<\\/action>/) { holding = 0; if (held !~ /<unique-id>${e.marker}-/) printf "%s", held }; next }`,"{ print }"].join(`
|
|
110
|
-
`);r=` if [ -f ${i} ] && grep -qF '<unique-id>${e.marker}-' ${i}; then
|
|
111
|
-
awk ${a(c)} ${i} > ${o} && mv -f ${o} ${i}
|
|
112
|
-
if [ -f ${s} ] && cmp -s ${s} ${i}; then rm -f ${i}; fi
|
|
113
|
-
fi
|
|
114
|
-
`}return`#!/bin/sh
|
|
115
|
-
# Forge's right-click menu. Rewritten by Forge whenever it sets the menu up.
|
|
116
|
-
${Dn()}
|
|
117
|
-
if [ ! -f ${a(e.forge)} ]; then
|
|
118
|
-
# Forge is gone: take its menu with it, and say so once.
|
|
119
|
-
for f in ${t}; do
|
|
120
|
-
if [ -f "$f" ] && grep -qF ${a(e.marker)} "$f"; then rm -f "$f"; fi
|
|
121
|
-
done
|
|
122
|
-
${r}${e.folders.map(i=>` rmdir ${a(i)} 2>/dev/null
|
|
123
|
-
`).join("")} rm -rf ${a(e.menuDir)}
|
|
124
|
-
say ${a(z)} ${a(ee)}
|
|
125
|
-
exit 0
|
|
126
|
-
fi
|
|
127
|
-
if [ ! -x ${a(e.node)} ]; then
|
|
128
|
-
say ${a(Te)} ${a(Oe)}
|
|
129
|
-
exit 1
|
|
130
|
-
fi
|
|
131
|
-
${e.xdgConfigHome===void 0?"":`export XDG_CONFIG_HOME=${a(e.xdgConfigHome)}
|
|
132
|
-
`}exec ${n} menu run "$@"
|
|
133
|
-
`}var O="HKCU\\Software\\Classes",Re=`${O}\\SystemFileAssociations\\image\\shell\\Forge`,Be=`${O}\\Directory\\shell\\Forge`,te=`${O}\\SystemFileAssociations\\.pdf\\shell\\ForgeOpen`,je=`${O}\\AppUserModelId\\${Y}`,ie=()=>[Re,Be,te,je],oe=e=>`${e.paint}.ico`;function _e(e){let n=o=>`conhost.exe --headless "${e.node}" "${e.menuDir}\\run.mjs" ${o.action}${o.preset===void 0?"":` ${o.preset}`} "%1"`,t=o=>`${e.menuDir}\\${oe(o)}`,r=(o,s)=>{let c=e.items.filter(f=>f.kinds.includes(s));return c.length===0?[]:[{key:o,values:{MUIVerb:"Forge",Icon:t({paint:"forge"}),SubCommands:""}},...c.flatMap((f,g)=>{let w=f.preset===void 0?f.action:`preset-${f.preset}`,l=`${o}\\shell\\${g+1}${w}`;return[{key:l,values:{MUIVerb:f.label,Icon:t(f)}},{key:`${l}\\command`,values:{"":n(f)}}]})]},i=e.items.find(o=>o.kinds.includes("pdf"));return[...r(Re,"image"),...r(Be,"folder"),...i?[{key:te,values:{MUIVerb:i.label,Icon:t(i)}},{key:`${te}\\command`,values:{"":n(i)}}]:[],{key:je,values:{DisplayName:"Forge",IconUri:`${e.menuDir}\\forge.png`}}]}var re=e=>`'${Q(e)}'`,ne=e=>re(`Registry::${e.replace(/^HKCU\\/,"HKEY_CURRENT_USER\\")}`);function se(e){return["$ErrorActionPreference = 'Stop'",...ie().map(t=>`Remove-Item -Path ${ne(t)} -Recurse -Force -ErrorAction SilentlyContinue`),...e.flatMap(({key:t,values:r})=>[`New-Item -Path ${ne(t)} -Force | Out-Null`,...Object.entries(r).map(([i,o])=>`Set-ItemProperty -LiteralPath ${ne(t)} -Name ${re(i===""?"(default)":i)} -Value ${re(o)}`)])].join(`
|
|
134
|
-
`)}var ot=(e,n)=>e.version===n.version&&e.forge===n.forge&&e.node===n.node&&e.execArgv.join("\0")===n.execArgv.join("\0")&&e.xdgConfigHome===n.xdgConfigHome&&(e.presets??[]).join("\0")===(n.presets??[]).join("\0"),We="/System/Library/CoreServices/pbs",Ve=e=>u(e.menuDir,"state.json"),N=e=>u(e.home,"Library","Services"),ce=e=>y({sharpen:!0}).map(n=>u(N(e),`${n.label}.workflow`)),ue=()=>y({sharpen:!0}).map(E);function Xe(e){let n;try{n=Ge(N(e)).filter(t=>t.endsWith(".workflow"))}catch{return[]}return n.flatMap(t=>{let r=u(N(e),t);try{let i=H(u(r,"Contents","Info.plist"),"utf8"),o=/<key>CFBundleIdentifier<\/key>\s*<string>([^<]*)<\/string>/.exec(i)?.[1],s=/<key>CFBundleName<\/key>\s*<string>([^<]*)<\/string>/.exec(i)?.[1];return!o?.startsWith(we)||s===void 0?[]:[{path:r,key:`${o} - ${(f=>f.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"))(s)} - runWorkflowAsService`}]}catch{return[]}})}function Nn(e){try{return JSON.parse(H(Ve(e),"utf8"))}catch{return}}var st=e=>Nn(e)!==void 0,m=(e,n)=>{pe(U(e),{recursive:!0}),In(e,n)};async function at(e){if(!Fn(e.platform))return;let n=y({sharpen:e.sharpen,presets:e.presets??[]});if(pe(e.menuDir,{recursive:!0}),e.platform==="linux")await kn(e,n);else if(e.platform==="darwin"){let r=u(e.menuDir,"run"),i=n.filter(l=>l.preset!==void 0),o=i.map(l=>u(N(e),_(l,r).name));m(r,Le({...e,bundles:[...ce(e),...o],services:[...ue(),...i.map(E)]})),le(r,493);let s=Xe(e);for(let l of[...ce(e),...s.map(R=>R.path)])$(l,{recursive:!0,force:!0});let c=new Map,{default:f}=await import("sharp");for(let l of n){c.has(l.paint)||c.set(l.paint,await f(await S(l.paint,64)).tiff().toBuffer());let{name:R,files:ze}=_(l,r),de=u(N(e),R);for(let[en,nn]of Object.entries(ze))m(u(de,en),nn);m(u(de,"Contents","Resources",`${j}.tiff`),c.get(l.paint))}let g=n.map(E),w=new Set([...ue(),...s.map(l=>l.key)]);await e.run(...D({on:g,off:[...w].filter(l=>!g.includes(l))})),await e.run(We,["-update"])}else{m(u(e.menuDir,"run.mjs"),Ue({...e,keys:ie()}));for(let r of Je){let i=await Promise.all([16,24,32,48,256].map(async o=>({size:o,png:await S(r,o)})));m(u(e.menuDir,oe({paint:r})),he(i))}m(u(e.menuDir,"forge.png"),await S("forge",256)),await e.run("powershell.exe",Ze(se(_e({...e,items:n}))))}let t={version:e.version,forge:e.forge,node:e.node,execArgv:e.execArgv,...e.xdgConfigHome===void 0?{}:{xdgConfigHome:e.xdgConfigHome},...e.presets&&e.presets.length>0?{presets:[...e.presets]}:{}};m(Ve(e),JSON.stringify(t))}var Fn=e=>e==="darwin"||e==="win32"||e==="linux",Je=["forge","convert","compress","edit","pdf"],qe=e=>ve({home:e.home,...e.xdgDataHome===void 0?{}:{xdgDataHome:e.xdgDataHome},...e.xdgConfigHome===void 0?{}:{xdgConfigHome:e.xdgConfigHome},...e.xdgConfigDirs===void 0?{}:{xdgConfigDirs:e.xdgConfigDirs}});function fe(e){let n=y({sharpen:!0}),t=n.map(i=>i.action),r=(i,o)=>{try{return Ge(i).filter(o).map(s=>u(i,s))}catch{return[]}};return[...new Set([...n.map(i=>u(h(e),G(i))),...r(h(e),()=>!0),...n.map(i=>u(I(e),W(i,t))),...r(I(e),i=>i.startsWith("forge-")&&i.endsWith(".nemo_action")),...X.map(i=>u(A(e),V(i)))])]}var x=e=>{try{return H(e,"utf8")}catch{return}};function Ye(e){for(let n of e)x(n)?.includes(d)&&$(n,{force:!0})}var Qe=e=>u(e.menuDir,"made.json"),me=e=>{try{return JSON.parse(H(Qe(e),"utf8"))}catch{return[]}};function L(e,n){let t=[];for(let r=n;!Ke(r)&&U(r)!==r;r=U(r))t.push(r);t.length!==0&&(pe(n,{recursive:!0}),m(Qe(e),JSON.stringify([...new Set([...me(e),...t])])))}function En(e){for(let n of[...e].sort((t,r)=>r.length-t.length))try{Mn(n)}catch{}}var ge=e=>u(e.menuDir,"thunar-seed.xml");async function bn(e,n,t,r){let i=C(n),o=x(i);if(o===void 0){if(!ke(n,e.path,Ke))return;o=Ee(n).map(x).find(c=>c!==void 0&&q(c,"")!==void 0)??be,m(ge(e),o),L(e,U(i))}let s=q(o,Pe(t,{launcher:r,menuDir:e.menuDir}));s!==void 0&&s!==x(i)&&await F(i,Buffer.from(s))}async function Pn(e,n){let t=C(n),r=x(t);if(r===void 0||!r.includes(`<unique-id>${d}-`))return;let i=J(r);i===x(ge(e))?$(t,{force:!0}):await F(t,Buffer.from(i))}async function ae(e,n,t=!1){await F(e,Buffer.from(n)),t&&le(e,493)}async function kn(e,n){let t=qe(e),r=u(e.menuDir,"run");for(let o of Je)m(u(e.menuDir,P({paint:o})),await S(o,128));Ye(fe(t));let i=y({sharpen:!0}).map(o=>o.action);L(e,h(t));for(let o of n)await ae(u(h(t),G(o)),Ie(o,r),!0);L(e,I(t));for(let o of n)await ae(u(I(t),W(o,i)),Ne(o,r));L(e,A(t));for(let o of X){let s=Fe(o,n,{launcher:r,menuDir:e.menuDir});s!==void 0&&await ae(u(A(t),V(o)),s,!0)}await bn(e,t,n,r),m(r,He({...e,files:fe(t),folders:[...new Set([h(t),...me(e)])].sort((o,s)=>s.length-o.length),marker:d,thunar:{file:C(t),seed:ge(e)}})),le(r,493)}async function An(e){let n=qe(e);Ye(fe(n)),await Pn(e,n),En([h(n),...me(e)]),$(e.menuDir,{recursive:!0,force:!0})}async function ct(e){if(e.platform==="linux")await An(e);else if(e.platform==="darwin"){let n=Xe(e);for(let r of[...ce(e),...n.map(i=>i.path)])$(r,{recursive:!0,force:!0});$(e.menuDir,{recursive:!0,force:!0});let t=new Set([...ue(),...n.map(r=>r.key)]);await e.run(...D({on:[],off:[...t]})),await e.run(We,["-update"])}else e.platform==="win32"&&($(e.menuDir,{recursive:!0,force:!0}),await e.run("powershell.exe",Ze(se([]))))}var Ze=e=>["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",e],ut=(e,n)=>new Promise((t,r)=>{vn(e,n,{timeout:6e4,windowsHide:!0},i=>i?r(i):t())});export{a,K as b,P as c,_n as d,ot as e,Nn as f,st as g,at as h,Fn as i,ct as j,ut as k};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d}from"./chunk-LBDSFSYP.js";import"./chunk-C4UCCBCX.js";import"./chunk-EKTUUKDP.js";import"./chunk-63BBFKT2.js";import"./chunk-JOIHR724.js";import"./chunk-655UG277.js";import"./chunk-Q6KQWJ4J.js";import"./chunk-OY4EGSPE.js";import"./chunk-C32KGH4S.js";import"./chunk-HCLEHCAR.js";import"./chunk-57M4J2BR.js";import"./chunk-63XCSYHM.js";import"./chunk-BD3OLIVT.js";import"./chunk-3KWAO2N2.js";import"./chunk-WZWK3PEZ.js";import"./chunk-EEQSUBBL.js";import"./chunk-QXNB5DQ2.js";import"./chunk-XURW53YK.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-2J2PTA5O.js";import"./chunk-THDAQBQ3.js";import"./chunk-DZOBIUV6.js";import"./chunk-5TEAR5XH.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{b as clipLines,a as runClip,d as runClipCommand,c as runUndo};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c}from"./chunk-SK2UZ25Y.js";import"./chunk-EKTUUKDP.js";import"./chunk-DZOBIUV6.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{a as copy,c as linuxText,b as paste};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{h as S,i as k,m as C}from"./chunk-MTDCDKPU.js";import{i as $,k as u,l as w}from"./chunk-YINYF6C7.js";import{c as I,d as y,f as O}from"./chunk-PBIS2ONZ.js";import{b as m,c as d,h as f,i as p}from"./chunk-QVACE4IE.js";import{a as h,b as g}from"./chunk-57M4J2BR.js";import"./chunk-63XCSYHM.js";import{a as l}from"./chunk-3KWAO2N2.js";import"./chunk-WZWK3PEZ.js";import"./chunk-EEQSUBBL.js";import"./chunk-QXNB5DQ2.js";import"./chunk-XURW53YK.js";import"./chunk-2J2PTA5O.js";import"./chunk-THDAQBQ3.js";import"./chunk-DZOBIUV6.js";import"./chunk-5TEAR5XH.js";import{c as b,n as x}from"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";import{resolve as R}from"node:path";var P=({r:t,g:n,b:o},s)=>s?`\x1B[38;2;${t};${n};${o}m\u2588\u2588\x1B[39m `:"";function N(t,n){let o=d(n),s,e=Number.POSITIVE_INFINITY;for(let r of t){let a=(r.centre.L-o.L)**2+(r.centre.a-o.a)**2+(r.centre.b-o.b)**2;a<e&&(e=a,s=r)}return s}async function D(t,n){let{pixels:o}=await C(t.input),s=I(o);if(s.length===0)throw x(t.input);let e=t.inside?N(s,t.inside):void 0,r=e?y(o,e):s;if(t.svg)return{exitCode:0,stdout:[S(b(t.input),r,"light",e?.hex)],stderr:[]};if(n.json){let i=h(l,{source:R(t.input),...e?{inside:e.hex}:{},colours:r.map(c=>({hex:c.hex,rgb:f(c.rgb),oklch:p(c.rgb),share:c.share}))});return{exitCode:0,stdout:[JSON.stringify(i)],stderr:[]}}let a=O(r.map(i=>i.share));return{exitCode:0,stdout:r.map((i,c)=>`${P(i.rgb,n.colour)}${i.hex} ${String(a[c]).padStart(3)}%`),stderr:[]}}async function H(t,n){let o=$(t.colour);if(t.svg)return{exitCode:0,stdout:[k(t.colour,o)],stderr:[]};let s=o.map(e=>({...e,...w(e.rgb)}));if(n.json){let e=g(l,{reference:m(t.colour),steps:s.map(r=>({step:r.step,hex:r.hex,oklch:p(r.rgb),white:r.white,black:r.black}))});return{exitCode:0,stdout:[JSON.stringify(e)],stderr:[]}}return{exitCode:0,stdout:s.map(e=>`${String(e.step).padStart(4)} ${P(e.rgb,n.colour)}${e.hex} white ${e.white.toFixed(1)} ${u(e.white)} \xB7 black ${e.black.toFixed(1)} ${u(e.black)}`),stderr:[]}}export{D as runPalette,H as runScale};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as s}from"./chunk-WE6KP4FR.js";import{H as o}from"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";var c=["open","convert","compress","sharpen","open-pdf","preset"];function u(r){let[e,n,...i]=r;if(e==="install"||e==="remove")return{kind:e};if(e==="run"||e==="open"){if(!c.includes(n))throw o(`No menu action called "${n??""}".`);if(n==="preset"){let[t,...a]=i;if(e!=="run"||t===void 0||!s(t))throw o(`No preset called "${t??""}".`);return{kind:"run",action:n,preset:t,paths:a}}return{kind:e,action:n,paths:i}}throw o(`No menu command called "${e??""}".`)}function m(r,e){switch(r){case"convert":return{paths:e,mode:"convert",advance:!0};case"compress":return{paths:e,mode:"compress",advance:!0};case"open-pdf":return{paths:e,mode:"pdf",advance:!1};default:return{paths:[],mode:"convert",advance:!1}}}export{m as openedFor,u as parseMenuArgs};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b}from"./chunk-JMBEZPYC.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{a as CONFIG_KEYS,b as runConfig};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e}from"./chunk-G46QQBT3.js";import"./chunk-THDAQBQ3.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{a as OPS,d as chainLabels,e as reasonsFor,c as stepLabel,b as withStep};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{g as a}from"./chunk-5TEAR5XH.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{a as openable};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as a,d as b,e as c,f as d}from"./chunk-63BBFKT2.js";import"./chunk-JOIHR724.js";import"./chunk-655UG277.js";import"./chunk-Q6KQWJ4J.js";import"./chunk-OY4EGSPE.js";import"./chunk-C32KGH4S.js";import"./chunk-HCLEHCAR.js";import"./chunk-57M4J2BR.js";import"./chunk-63XCSYHM.js";import"./chunk-BD3OLIVT.js";import"./chunk-3KWAO2N2.js";import"./chunk-WZWK3PEZ.js";import"./chunk-EEQSUBBL.js";import"./chunk-QXNB5DQ2.js";import"./chunk-XURW53YK.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-2J2PTA5O.js";import"./chunk-THDAQBQ3.js";import"./chunk-DZOBIUV6.js";import"./chunk-5TEAR5XH.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{d as execute,a as exitCodeFor,c as renderRun,b as runIntent};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{Ib as a,Jb as b,Kb as c,Lb as d,Mb as e}from"./chunk-UXRQ4UBQ.js";import"./chunk-YINYF6C7.js";import"./chunk-PBIS2ONZ.js";import"./chunk-Q6KQWJ4J.js";import"./chunk-I25E2XDH.js";import"./chunk-IBPGC4N2.js";import"./chunk-U5TEGDGH.js";import"./chunk-QVACE4IE.js";import"./chunk-3KWAO2N2.js";import"./chunk-EEQSUBBL.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{e as ExtensionsFlow,c as byteCount,b as extensionCredits,d as extensionsChip,a as realManager};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{h as a,i as b,j as c,k as d,l as e,m as f,n as g,o as h}from"./chunk-2J2PTA5O.js";import"./chunk-THDAQBQ3.js";import"./chunk-DZOBIUV6.js";import"./chunk-5TEAR5XH.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{c as decodeToPng,a as encode,d as encodeToBuffer,g as guessCrop,h as imageEngine,f as loadCropView,e as measureImage,b as writeAtomic};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{e as a,f as b,g as c,h as d,i as e,j as f,k as g}from"./chunk-ZRHYGR2L.js";import"./chunk-DZOBIUV6.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{e as hasMenu,d as installMenu,c as isInstalled,b as readState,f as removeMenu,g as runProgram,a as stateMatches};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e,f}from"./chunk-63ZK5SRQ.js";import"./chunk-WIPP5TWQ.js";import"./chunk-J7FLFHQJ.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{f as installUpdate,a as installedGlobally,e as lastWords,c as npmBeside,d as npmCliBeside,b as runningScript};
|