forge-terminal 0.5.8 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -12
- package/dist/chunks/{about-credits-PQSIWSE2.js → about-credits-XL2AIGQ7.js} +1 -1
- package/dist/chunks/args-PS5SVBZY.js +3 -0
- package/dist/chunks/boot-QRKC4QBA.js +3 -0
- package/dist/chunks/check-HOITNMJX.js +3 -0
- package/dist/chunks/{chunk-6RCS3KBP.js → chunk-2JU3YZQU.js} +1 -1
- package/dist/chunks/{chunk-Q6KQWJ4J.js → chunk-2L66A2X6.js} +1 -1
- package/dist/chunks/chunk-2OSM4W4D.js +3 -0
- package/dist/chunks/{chunk-XGG3NYQN.js → chunk-3HG7RXC2.js} +1 -1
- package/dist/chunks/chunk-3IX3QA76.js +3 -0
- package/dist/chunks/chunk-3SVHRKQH.js +6 -0
- package/dist/chunks/chunk-4MZV4SRU.js +4 -0
- package/dist/chunks/chunk-4NDZTK22.js +3 -0
- package/dist/chunks/{chunk-7XFLG32B.js → chunk-5FJT4BNY.js} +1 -1
- package/dist/chunks/chunk-5XJCMMCM.js +3 -0
- package/dist/chunks/chunk-65Y7YCZZ.js +3 -0
- package/dist/chunks/{chunk-WBW6G4N6.js → chunk-6HUYBVQA.js} +1 -1
- package/dist/chunks/chunk-BSFBZBAI.js +16 -0
- package/dist/chunks/chunk-BWJNZT75.js +6 -0
- package/dist/chunks/{chunk-WE6KP4FR.js → chunk-BYUOU2Q2.js} +1 -1
- package/dist/chunks/chunk-CCNRNCRU.js +3 -0
- package/dist/chunks/chunk-ECA4PW5T.js +3 -0
- package/dist/chunks/chunk-EIPMQFIF.js +3 -0
- package/dist/chunks/chunk-EJWTYDBJ.js +3 -0
- package/dist/chunks/chunk-EYOO35US.js +3 -0
- package/dist/chunks/chunk-FGR6QCG5.js +3 -0
- package/dist/chunks/chunk-FWVE3GNA.js +3 -0
- package/dist/chunks/{chunk-ILQDMVJR.js → chunk-FXA45V4B.js} +1 -1
- package/dist/chunks/chunk-G6L5NIJ5.js +19 -0
- package/dist/chunks/chunk-GIG4I2IC.js +23 -0
- package/dist/chunks/chunk-HXKLYK3M.js +7 -0
- package/dist/chunks/chunk-I2LPGKUU.js +3 -0
- package/dist/chunks/chunk-JD3RB6IV.js +66 -0
- package/dist/chunks/{chunk-W53XNVNH.js → chunk-JUA63KQK.js} +1 -1
- package/dist/chunks/{chunk-4KGC5ZBZ.js → chunk-NLM2SP3F.js} +1 -1
- package/dist/chunks/chunk-NMGQGYVM.js +3 -0
- package/dist/chunks/chunk-NUCGWLOY.js +8 -0
- package/dist/chunks/{chunk-SM735FG7.js → chunk-NUTTDNTG.js} +1 -1
- package/dist/chunks/chunk-PA7AG2NK.js +55 -0
- package/dist/chunks/{chunk-KTCHWHQB.js → chunk-PISCJKIG.js} +1 -1
- package/dist/chunks/chunk-PON65UTS.js +3 -0
- package/dist/chunks/chunk-QIMSNTKL.js +3 -0
- package/dist/chunks/{chunk-4MJEEEFA.js → chunk-QO4JUY6B.js} +1 -1
- package/dist/chunks/chunk-QPUKPSPZ.js +3 -0
- package/dist/chunks/{chunk-JI7YY44M.js → chunk-S7BZPV5T.js} +1 -1
- package/dist/chunks/chunk-SFN3LBB6.js +3 -0
- package/dist/chunks/{chunk-OXDRJO4V.js → chunk-TNIPRV6K.js} +1 -1
- package/dist/chunks/{chunk-SZRSAL64.js → chunk-UEAZTRTL.js} +1 -1
- package/dist/chunks/chunk-UI4EUC3S.js +3 -0
- package/dist/chunks/chunk-UN5DSJE2.js +3 -0
- package/dist/chunks/chunk-UUTBDIFR.js +3 -0
- package/dist/chunks/chunk-WID72ZII.js +4 -0
- package/dist/chunks/chunk-X2YUHPOU.js +4 -0
- package/dist/chunks/chunk-X4QI2EYV.js +3 -0
- package/dist/chunks/chunk-YBA6DJQ4.js +3 -0
- package/dist/chunks/chunk-YJZEHJ6U.js +3 -0
- package/dist/chunks/chunk-YYZYZWF5.js +80 -0
- package/dist/chunks/clip-command-4ON3Q57W.js +3 -0
- package/dist/chunks/clipboard-W67Q22JG.js +3 -0
- package/dist/chunks/colour-2BGK2BFR.js +3 -0
- package/dist/chunks/command-ZX3L5VFO.js +3 -0
- package/dist/chunks/config-command-VEGQPXVB.js +3 -0
- package/dist/chunks/continue-editing-LTMIEFRD.js +3 -0
- package/dist/chunks/decoded-SK6W44WW.js +3 -0
- package/dist/chunks/{entry-HGEJC7CZ.js → entry-3R2GK3IW.js} +2 -2
- package/dist/chunks/execute-TC3QZ6GL.js +3 -0
- package/dist/chunks/extensions-3SG2LW7R.js +3 -0
- package/dist/chunks/{extensions-command-65QEMN2L.js → extensions-command-RNAPQYWV.js} +1 -1
- package/dist/chunks/ffmpeg-G4TRWUTV.js +3 -0
- package/dist/chunks/image-67XO45NW.js +3 -0
- package/dist/chunks/install-UN3YGSJW.js +3 -0
- package/dist/chunks/{install-KGFOAQCU.js → install-X7EEH5CQ.js} +1 -1
- package/dist/chunks/launch-EGFNGHLN.js +18 -0
- package/dist/chunks/lock-5ZO5PCZP.js +3 -0
- package/dist/chunks/manager-272REVNF.js +4 -0
- package/dist/chunks/{needed-6GCBKP3S.js → needed-7IUPDEJB.js} +1 -1
- package/dist/chunks/notify-UD7FQAWX.js +3 -0
- package/dist/chunks/{own-KMIT2CXF.js → own-5BD5BVE7.js} +1 -1
- package/dist/chunks/pdfium-MHPBLZY5.js +3 -0
- package/dist/chunks/preferences-E2CH2YSG.js +3 -0
- package/dist/chunks/preset-command-5I3NZ2OP.js +3 -0
- package/dist/chunks/registry-DWFV4GBG.js +3 -0
- package/dist/chunks/{run-GUFPETHF.js → run-3DX3SROY.js} +1 -1
- package/dist/chunks/server-TF32DQEO.js +81 -0
- package/dist/chunks/signals-QSXY3F2A.js +3 -0
- package/dist/chunks/text-layer-PFIDCTEL.js +5 -0
- package/dist/chunks/theme-4Y66DDAO.js +3 -0
- package/dist/chunks/transcribe-HH5P3PV4.js +3 -0
- package/dist/chunks/transcribe-command-VY5HYNXV.js +3 -0
- package/dist/chunks/update-command-6VVDG75Y.js +3 -0
- package/dist/chunks/update-note-XV2T2NNG.js +3 -0
- package/dist/chunks/watch-command-BMSMGIHK.js +3 -0
- package/dist/helpers/forge-transcribe +0 -0
- package/dist/index.js +16 -15
- package/package.json +17 -5
- package/dist/chunks/args-J5JEHQLE.js +0 -3
- package/dist/chunks/boot-ETZUHG3U.js +0 -3
- package/dist/chunks/check-B6NP7BEM.js +0 -3
- package/dist/chunks/chunk-2M5PPZIS.js +0 -36
- package/dist/chunks/chunk-4OSMYHKQ.js +0 -4
- package/dist/chunks/chunk-4RNVZQRC.js +0 -3
- package/dist/chunks/chunk-6TTONCYR.js +0 -6
- package/dist/chunks/chunk-BP6CVOQR.js +0 -66
- package/dist/chunks/chunk-DD5Z6NSH.js +0 -3
- package/dist/chunks/chunk-DHW72U6X.js +0 -3
- package/dist/chunks/chunk-FAUL5L2W.js +0 -3
- package/dist/chunks/chunk-FEFNS6YZ.js +0 -3
- package/dist/chunks/chunk-H3DIRJFE.js +0 -3
- package/dist/chunks/chunk-H3KW7HTC.js +0 -3
- package/dist/chunks/chunk-HTA25PO2.js +0 -3
- package/dist/chunks/chunk-J7FLFHQJ.js +0 -3
- package/dist/chunks/chunk-J7Z7ULLN.js +0 -3
- package/dist/chunks/chunk-KH5DHZ2U.js +0 -8
- package/dist/chunks/chunk-N32JL4UI.js +0 -3
- package/dist/chunks/chunk-N6RCLJE6.js +0 -4
- package/dist/chunks/chunk-NAE3AJ3M.js +0 -3
- package/dist/chunks/chunk-NMECUMJD.js +0 -7
- package/dist/chunks/chunk-NUW4YOJ6.js +0 -3
- package/dist/chunks/chunk-RQWWUCGQ.js +0 -3
- package/dist/chunks/chunk-RT6EXB2P.js +0 -3
- package/dist/chunks/chunk-T4CLHCLJ.js +0 -4
- package/dist/chunks/chunk-TFGK7IRZ.js +0 -19
- package/dist/chunks/chunk-TJ5YBJEO.js +0 -3
- package/dist/chunks/chunk-TLHUFIXD.js +0 -3
- package/dist/chunks/chunk-V6GWPR2A.js +0 -3
- package/dist/chunks/chunk-VBDRWNEG.js +0 -3
- package/dist/chunks/chunk-YISJTRB6.js +0 -72
- package/dist/chunks/chunk-YPAFAG4W.js +0 -6
- package/dist/chunks/chunk-Z6IQV737.js +0 -3
- package/dist/chunks/chunk-ZBMJTIYR.js +0 -3
- package/dist/chunks/chunk-ZX5FDZZW.js +0 -55
- package/dist/chunks/clip-command-QIMH2U7N.js +0 -3
- package/dist/chunks/clipboard-IZJTBTSW.js +0 -3
- package/dist/chunks/colour-3MFAFJNN.js +0 -3
- package/dist/chunks/command-GAGAD65W.js +0 -3
- package/dist/chunks/config-command-CKPJXJEE.js +0 -3
- package/dist/chunks/continue-editing-M6WESEVB.js +0 -3
- package/dist/chunks/decoded-XWKU23RG.js +0 -3
- package/dist/chunks/execute-MRVDAKZO.js +0 -3
- package/dist/chunks/extensions-ONARRS5Q.js +0 -3
- package/dist/chunks/ffmpeg-RTFJS67A.js +0 -3
- package/dist/chunks/image-R5C3AWHT.js +0 -3
- package/dist/chunks/install-MFYGS5TG.js +0 -3
- package/dist/chunks/launch-T7YOO7BQ.js +0 -17
- package/dist/chunks/lock-BG3CLOHA.js +0 -3
- package/dist/chunks/manager-5EJGANFW.js +0 -4
- package/dist/chunks/notify-NQNNOBFC.js +0 -3
- package/dist/chunks/pdfium-77L526HZ.js +0 -3
- package/dist/chunks/preferences-3P4V2EDX.js +0 -3
- package/dist/chunks/preset-command-3ILRQZSJ.js +0 -3
- package/dist/chunks/registry-K245FDI2.js +0 -3
- package/dist/chunks/server-M5YGJHOL.js +0 -77
- package/dist/chunks/text-layer-LHZNDMPZ.js +0 -3
- package/dist/chunks/theme-XKWZV7OX.js +0 -3
- package/dist/chunks/transcribe-SQC6QTV5.js +0 -3
- package/dist/chunks/transcribe-command-PAHSXMWG.js +0 -3
- package/dist/chunks/update-command-DWEBUFT5.js +0 -3
- package/dist/chunks/update-note-NRPILOCL.js +0 -3
- package/dist/chunks/watch-command-QOMMDISG.js +0 -3
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as ie,d as ue,e as pe,g as ce,h as de}from"./chunk-TJ5YBJEO.js";import{a as te,b as oe,c as se,k as ne,m as M,n as O,s as ae}from"./chunk-FEFNS6YZ.js";import{b as X,c as T}from"./chunk-6RMRWBMB.js";import{a as y}from"./chunk-H3KW7HTC.js";import{b as I}from"./chunk-NUW4YOJ6.js";import{e as be}from"./chunk-DHW72U6X.js";import{a as C,c as _,d as ee,e as F,f as re}from"./chunk-KTCHWHQB.js";import{f as fe,g as le,h as me,i as ge,j as he,k as ye}from"./chunk-YJ6XLDRA.js";import{a as g}from"./chunk-4OSMYHKQ.js";import{d as $}from"./chunk-EEQSUBBL.js";import{a as Z}from"./chunk-FAUL5L2W.js";import{a as L,d as U}from"./chunk-TLHUFIXD.js";import{a as Y,c as K,d as E,e as Q}from"./chunk-V6GWPR2A.js";import{G as N,H as V,K as G,a as P,q as z,s as k,u as q,va as H,x as J}from"./chunk-ZBMJTIYR.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{b as x,c as w}from"./chunk-VLVNA4T3.js";import{a as R}from"./chunk-H3DIRJFE.js";import{readFile as Te}from"node:fs/promises";import{dirname as Oe,resolve as Me}from"node:path";async function we(e){let t=[],r=[...e.resolved.failures];for(let o of e.resolved.sources){let s=C(o);if(!s.includes(e.target)){r.push({path:o.path,error:q(o,e.target,s)});continue}let a={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},n=E(a);K(n,o.path)&&e.target!==o.format&&(n=Q({...a,suffix:e.target})),t.push({op:"convert",sources:[o],outputs:[n],target:e.target,options:e.options})}return{jobs:t,failures:r}}import{resolve as je}from"node:path";function Be(e,t=new Set){let r={path:je(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:C(e).filter(a=>!o||F(a)),actions:ce([e],t).filter(a=>!o||a.id===O.id).map(a=>a.id)};if(e.kind==="image")return{...r,width:e.width,height:e.height,...s};if(e.kind==="media"){let a=e.facts;return{...r,...a?{duration:a.duration}:{},...a?.video?{width:a.video.width,height:a.video.height,fps:a.video.fps}:{},...s}}return{...r,pages:e.pages,encrypted:e.encrypted,...s}}async function Ie(e){let t=await y(e,{recursive:!1}),{installedExtensionIds:r}=await import("./available-TNMISSBA.js"),o=await r();return{probes:t.sources.map(s=>Be(s,o)),failures:t.failures}}import{dirname as Se}from"node:path";var j=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function ve(e,t){let r=x(Se(e),j(t));return r==="."?"":` in ${r.endsWith("/")?r:`${r}/`}`}function xe(e,t){let{pct:r,direction:o}=W(e,t);return o==="same"?"same size":`${r}% ${o}`}function Pe(e,t={}){let r=e.results[0];if(!r)return[];let o=r.job.sources[0],s=r.job.outputs;if(s.length>1){let n=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${ve(s[0],t)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(r.outputBytes)} total`];for(let i of r.warnings)n.push("",`\u26A0 ${i.message}`);return n}let a=[`\u2713 ${w(o.path)} \u2192 ${x(s[0],j(t))}`,` ${h(o.bytes)} \u2192 ${h(r.outputBytes)} \xB7 ${xe(o.bytes,r.outputBytes)}`];for(let n of r.warnings)a.push("",`\u26A0 ${n.message}`);return a}function ke(e,t={}){let r=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${xe(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let a of s.job.outputs)r.push(` ${x(a,j(t))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){r.push("");for(let s of o)r.push(`\u26A0 ${s.message}`)}return r}function $e(e,t={}){let r=e.results.flatMap(u=>u.job.outputs),o=r.map(u=>w(u)).join(", "),s=r.length===1?"file":"files",a=r[0]===void 0?"":ve(r[0],t),n=[`\u2713 ${r.length} ${s} \xB7 ${o}${a}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)n.push("",`\u26A0 ${u.message}`);return n}function B(e,t){if(e.length===0)return[];let r=[];for(let o of e)r.push(...H(o.error,{debug:t.debug}),"");return r}function Re(){let e=new Set(_()),t=new Set(ee()),r=["Formats",""];for(let s of e){let a=R[s],n=t.has(s)?"read and write":"read only";r.push(` ${a.label.padEnd(6)} ${a.extensions.join(" ").padEnd(12)} ${n}`)}let o=[...e].filter(s=>!t.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[a,n]=o.length===1?["is","it"]:["are","them"];r.push("",`${s} ${a} read only because Forge cannot yet write ${n}.`)}return r}function Ee(e,t={}){let r=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&r.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&r.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&r.push(`${e.fps} fps`),e.pages!==void 0&&r.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&r.push("password-protected"),[`${x(e.path,j(t))} \xB7 ${r.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Ce}from"node:readline";import{PassThrough as Je}from"node:stream";function Ne(e){return new Promise(t=>{let r=Ce({input:e,terminal:!1}),o=!1,s=a=>{if(o)return;o=!0,r.close(),e.pause(),e.unref?.(),t(a.replace(/\r$/,""))};r.once("line",s),r.once("close",()=>s(""))})}async function Fe(e){if(e.stdin)return Ne(process.stdin);if(!process.stdin.isTTY)return;let t=new Je,r=Ce({input:process.stdin,output:t,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>r.question("",o))}finally{process.stderr.write(`
|
|
4
|
-
`),r.close()}}function Ae(e){return e.kind==="preset"?e.name:e.kind==="pageop"?"PDF":e.kind==="compress"?"Compress":e.kind==="convert"?"Convert":"Edit"}function A(e){return e.length===0?0:e.some(t=>t.error.code==="invalid-arguments")?2:1}function De(e,t){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let r=t.find(n=>n.kind==="document"),o=r?.pages??0,s=e.split;if(!s)throw N("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:ie(o)};if(s.mode==="every-n")return{cuts:ue(o,s.n)};let a=Math.max(o-1,0);for(let n of s.after)if(!Number.isInteger(n)||n<1||n>a)throw V(String(n),`"${n}" is outside 1 and ${a} \u2014 ${r?w(r.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(n=>n-1)}}function We(e,t){let r;return()=>t?(r??=Fe({stdin:e}).then(o=>e&&o===""?void 0:o),r):Promise.resolve(void 0)}async function ze(e,t,r,o){let s;if(e.encrypted){if(s=t.password??await r(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Z(await Te(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let a;try{a=O.plan([e],{target:t.target,background:t.options.background,keepMetadata:t.options.keepMetadata,dpi:String(t.dpi??150),...t.options.quality===void 0?{}:{quality:t.options.quality},...t.pages===void 0?{}:{pages:t.pages},...t.output===void 0?{}:{destination:t.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!P(i))throw i;return{failure:{path:e.path,error:i}}}let n=a[0];if(n?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(n.options.password=s),{job:n}}function S(e,t){return r=>{if(r.type==="search:attempt"){t||e.onSearch?.(r.rung.dpi===void 0?`attempt ${r.attempt} of ${r.of}`:`${r.rung.dpi} dpi \xB7 attempt ${r.attempt} of ${r.of}`);return}if(r.type==="search:settled"){t&&e.onSearch?.(`${r.completed} of ${r.total} searched`);return}if(!t&&r.type==="job:phase"&&r.progress.phase==="time"){let o=r.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of ${o.pass.of} \xB7 ${s}`:s);return}t&&(r.type==="job:done"||r.type==="job:error")&&e.onProgress?.({completed:r.completed,total:r.total})}}var b=(e,t)=>({kind:e,results:[],failures:t,inputBytes:0,outputBytes:0});async function qe(e){let t=await y(e.inputs,{recursive:!1});if(t.sources.length===0)return b("pageop",t.failures);let r=pe.find(n=>n.id===e.action);if(!r)throw new Error(`no action registered for "${e.action}"`);let o=t.sources[0]?.path??"";if(!r.appliesTo(t.sources)){let n=de(r,t.sources)??"not available for these files";return b("pageop",[...t.failures,{path:o,error:k(e.action,n)}])}let s;try{s=r.plan(t.sources,De(e,t.sources))}catch(n){if(!P(n))throw n;return b("pageop",[...t.failures,{path:o,error:n}])}let a=await I(s,{force:e.force});return{kind:"pageop",results:a.results,failures:[...t.failures,...a.refusals,...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function Ve(e,t){let r=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of r.sources){if(!M.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!Y(e.output)?Me(e.output):void 0,p=e.output===void 0||u!==void 0?Oe(i.path):Oe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:r.roots.get(i.path)})),[f]=M.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:p});f?.op==="convert"&&(u!==void 0&&(f.outputs=[u]),e.dpi!==void 0&&(f.options.dpi=e.dpi),o.push(f))}let a=o.length>1;a&&t.onProgress?.({completed:0,total:o.length});let n=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(t,a)});return{kind:"compress",results:n.results,failures:[...r.failures,...s,...n.refusals,...n.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function Ge(e,t){let r=e.kind,o=e.op==="remove-background"?L(e.target):void 0;if(o)return b(r,[{path:"",error:o}]);let{installed:s}=await import("./paths-6OENILJ4.js"),a=await s(e.op);if(!a)return b(r,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:l,catalogEntry:c}=await import("./catalog-FMHWWMUX.js"),m=c("boost"),v=m&&l(m)?.version,D=U(e.scale,a.version,v);if(D)return b(r,[{path:"",error:D}])}let n=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?oe:se,u=[],p=[];for(let l of n.sources){if(!i.appliesTo([l])){p.push({path:l.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let c=te(l,e.target);if(c){p.push({path:l.path,error:c});continue}u.push(...i.plan([l],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:n.roots}))}let f=u.length>1;f&&t.onProgress?.({completed:0,total:u.length});let d=await I(u,{force:e.force,concurrency:1,...t.signal===void 0?{}:{signal:t.signal},onEvent:S(t,f)});return{kind:r,results:d.results,failures:[...n.failures,...p,...d.refusals,...d.failures],inputBytes:d.inputBytes,outputBytes:d.outputBytes}}async function He(e,t){let r=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:be(e.target,r);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),a=[],n=[],i=[];for(let c of s.sources)c.kind==="image"&&e.media===void 0?a.push(c):c.kind==="media"&&!e.trim?n.push(c):c.kind==="image"?i.push({path:c.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:c.path,error:k(r,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ne(n,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),f=[...ae(a,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],d=f.length>1;d&&t.onProgress?.({completed:0,total:f.length});let l=await I(f,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(t,d)});return{kind:e.kind,results:l.results,failures:[...s.failures,...i,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function Le(e,t){let r=await y(e.inputs,{recursive:e.recursive}),o=m=>m.kind==="document"&&m.format==="pdf",s=F(e.target),a=s?r.sources.filter(o):[],n=s?r.sources.filter(m=>!o(m)):r.sources,i=[],u=[],p=We(e.passwordStdin??!1,t.interactive??!0);for(let m of a){let v=await ze(m,e,p,r.roots.get(m.path));"failure"in v?u.push(v.failure):i.push(v.job)}let f=await we({resolved:{sources:n,failures:[],roots:r.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),d=[...f.jobs,...i],l=d.length>1;l&&t.onProgress?.({completed:0,total:d.length});let c=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(t,l)});return{kind:"convert",results:c.results,failures:[...r.failures,...u,...f.failures,...c.refusals,...c.unreachable.map(m=>({path:m.job.sources[0].path,error:m.error})),...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function Ue(e,t={}){try{if(e.kind==="pageop")return await qe(e);if(e.kind==="extension-op")return await Ge(e,t);if(e.kind==="edit")return await He(e,t);if(e.kind==="preset"){let{runPresetCommand:r}=await import("./preset-command-3ILRQZSJ.js");return await r(e)}return e.kind==="compress"?await Ve(e,t):await Le(e,t)}catch(r){if(!P(r))throw r;return b(e.kind,[{path:"",error:r}])}}function Ye(e,t){let r=A(e.failures);if(t.json)return{exitCode:r,stdout:[JSON.stringify(fe(g,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?$e(e):e.results.length===1?Pe(e):ke(e);return{exitCode:r,stdout:o,stderr:B(e.failures,{debug:t.debug})}}function Ke(e,t){let r=[{path:"",error:e}],o=A(r);return t.json?{exitCode:o,stdout:[JSON.stringify(le(g,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:B(r,{debug:t.debug})}}async function Qe(e,t){let{runConfig:r}=await import("./config-command-CKPJXJEE.js"),o=await r(e);return t?{exitCode:0,stdout:[JSON.stringify(he(g,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function zr(e,t={}){let r=t.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Qe(e,r);if(e.kind==="clip"){let{runClipCommand:n}=await import("./clip-command-QIMH2U7N.js");return await n(e,{...t,json:r,debug:o})}if(e.kind==="update"){let{runUpdate:n}=await import("./update-command-DWEBUFT5.js"),i=await n(g,{...t.onInstalling?{onInstalling:t.onInstalling}:{}});return{exitCode:0,stdout:r?[JSON.stringify({forge:g,ok:!0,...i.data})]:i.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:n}=await import("./entry-HGEJC7CZ.js"),i=[];return{exitCode:await n(g,p=>i.push(p)),stdout:i,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:n}=await import("./extensions-command-65QEMN2L.js"),i=await n(e,{onDownload:t.onDownload});return{exitCode:0,stdout:r?[JSON.stringify(ye(g,i.data))]:i.stdout,stderr:[]}}if(e.kind==="formats")return r?{exitCode:0,stdout:[JSON.stringify(me(g,re()))],stderr:[]}:{exitCode:0,stdout:Re(),stderr:[]};if(e.kind==="probe"){let{probes:n,failures:i}=await Ie(e.inputs),u=A(i);return r?{exitCode:u,stdout:[JSON.stringify(ge(g,{probes:n,failures:i}))],stderr:[]}:{exitCode:u,stdout:n.flatMap((p,f)=>[...f>0?[""]:[],...Ee(p)]),stderr:B(i,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"||e.kind==="card"){let{runCard:n,runPalette:i,runScale:u}=await import("./colour-3MFAFJNN.js"),p={json:r,colour:t.colour??!1};return e.kind==="card"?await n(e,p):e.kind==="palette"?await i(e,p):await u(e,p)}if(e.kind==="transcribe"){let{runTranscribeCommand:n}=await import("./transcribe-command-PAHSXMWG.js"),i=[],u=[],p;return{exitCode:await n(e,{out:d=>i.push(d),err:d=>u.push(d),finished:d=>{p=T("Transcribe",d)}}),stdout:i,stderr:u,...p?{notice:p}:{}}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw N("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");let s=await Ue(e,t),a=T(Ae(e),X(s.results,s.failures));return{...Ye(s,{json:r,debug:o}),...a?{notice:a}:{}}}catch(s){if(!P(s))throw s;return Ke(s,{json:r,debug:o})}}export{Ie as a,xe as b,A as c,Ue as d,Ye as e,zr as f};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as w,h as et,i as P}from"./chunk-7XFLG32B.js";import{b as y,c as F,d as D,f as O,g as K,h as tt}from"./chunk-N32JL4UI.js";var ht=[[15,"rose"],[45,"red"],[70,"orange"],[95,"amber"],[120,"yellow"],[140,"lime"],[165,"green"],[185,"teal"],[215,"cyan"],[250,"sky"],[280,"blue"],[295,"indigo"],[315,"violet"],[340,"purple"],[355,"pink"],[360,"rose"]];function S(t){let{C:e,h:n}=O(F(t));return e<.03?"grey":B(n)}function B(t){let e=(t%360+360)%360;return(ht.find(([n])=>e<n)??[360,"rose"])[1]}var wt=["full","mono","analogous","opposite","split","triad","pastel"],nt={full:"Full set",mono:"Monochromatic",analogous:"Analogous",opposite:"Complementary",split:"Split complementary",triad:"Triadic",pastel:"Pastel"},W={brightness:0,saturation:0,hue:0,contrast:0},St=t=>!!(t.brightness||t.saturation||t.hue||t.contrast),Y=[{name:"red",hex:{r:251,g:44,b:54},role:"danger"},{name:"orange",hex:{r:255,g:105,b:0}},{name:"yellow",hex:{r:239,g:177,b:0},role:"warning"},{name:"green",hex:{r:0,g:201,b:80},role:"success"},{name:"teal",hex:{r:0,g:187,b:167}},{name:"blue",hex:{r:43,g:127,b:255},role:"info"},{name:"purple",hex:{r:173,g:70,b:255}},{name:"pink",hex:{r:246,g:51,b:154}}],ct={analogous:[-30,0,30],opposite:[0,180],split:[0,150,210],triad:[0,120,240]},ut=.553,gt=.024,d=t=>O(F(t)),T=(t,e,n)=>D(K({L:t,C:Math.max(0,e),h:(n+360)%360})),G=(t,e)=>(t-e+540)%360-180;function rt(t,e,n){let r=K({L:t,C:e,h:n}),a=F(D(r));return Math.hypot(a.L-r.L,a.a-r.a,a.b-r.b)<.003}function L(t,e){let n=0,r=.4;for(let a=0;a<30;a++){let o=(n+r)/2;rt(t,o,e)?n=o:r=o}return n}function q({L:t,C:e,h:n}){let r=L(t,n);return r>0?Math.min(1,e/r):0}var z=(t,e)=>e>=0?t+(.98-t)*(e/100):t+(t-.05)*(e/100),Q=(t,e,n)=>n>=0?t+(Math.max(t,e)-t)*(n/100):t*(1+n/100);function N(t,e){if(!(e.brightness||e.saturation||e.hue))return t;let{L:n,C:r,h:a}=d(t),o=z(n,e.brightness),s=(a+e.hue+360)%360,l=Q(r,L(o,s),e.saturation);for(let i=0;i<40&&l>0&&!rt(o,l,s);i++)l-=.005;return T(o,l,s)}function v(t,e,n,r){let a=z(t,r.brightness),o=(n+r.hue+360)%360,s=L(a,o);return T(a,Math.min(s,Q(e,s,r.saturation)),o)}function J(t,e,n){if(!e)return t;let r=d(t[n].rgb).L;return t.map((a,o)=>{if(o===n)return a;let s=d(a.rgb),l=Math.max(.02,Math.min(.995,r+(s.L-r)*(1+e/100))),i=T(l,Math.min(s.C,L(l,s.h)),s.h);return{...a,rgb:i,hex:y(i)}})}function Mt(t,e,n,r){return J(t(N(e,n)),n.contrast,r)}function ot(t,e){let n=d(t),r=Y.map(i=>d(i.hex)),a=0;r.forEach((i,h)=>{Math.abs(G(n.h,i.h))<Math.abs(G(n.h,r[a].h))&&(a=h)});let o=r[a],s=Math.max(-10,Math.min(10,G(n.h,o.h)/2)),l=q(n);return Y.map((i,h)=>{if(h===a)return{name:i.name,role:i.role,rgb:N(t,e),yours:!0};let u=r[h],c=n.L>=o.L?u.L+(n.L-o.L)*(1-u.L)/(1-o.L):u.L*n.L/o.L,x=z(c,e.brightness),m=(u.h+s+e.hue+360)%360,f=L(x,m),$=Math.min(1,q(u)),b=Math.min(f,Q(l*$*f,f,e.saturation));return{name:i.name,role:i.role,rgb:T(x,b,m),yours:!1}})}function mt(t,e,n){let r=d(t),a=S(t);if(e==="mono")return[{name:a,rgb:N(t,n),yours:!0},{name:`${a} soft`,rgb:v(r.L,r.C*.5,r.h,n),yours:!1},{name:`${a} dusty`,rgb:v(r.L,r.C*.22,r.h,n),yours:!1}];if(e==="pastel")return ot(t,W).map((l,i)=>{let h=d(l.rgb),u=h.C<.01?d(Y[i].hex).h:h.h;return{...l,rgb:v(.86,Math.min(.1,L(.86,u))*.85,u,n)}});let o=q(r);return(ct[e]??[0]).map(l=>{if(l===0)return{name:a,rgb:N(t,n),yours:!0};let i=(r.h+l+360)%360,h=o*L(r.L,i);return{name:o>0?B(i):S(v(r.L,h,i,W)),rgb:v(r.L,h,i,n),yours:!1}}).sort((l,i)=>Number(i.yours)-Number(l.yours))}function pt(t,e,n){let r=d(t).h+e.hue,a=Math.max(0,gt*(1+e.saturation/100));return P(T(z(ut,e.brightness),a,r),n)}function Lt(t,e,n=W,r=w){let a=et(r);return{rows:(e==="full"?ot(t,n):mt(t,e,n)).map(({name:l,role:i,rgb:h,yours:u})=>({name:l,...i?{role:i}:{},steps:J(P(h,r),n.contrast,a),yours:u})),neutral:J(pt(t,n,r),n.contrast,a)}}var R=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),I=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"colour",M='font-family="Inter"',U=t=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`;function at(t){let e=t==="dark";return{ink:e?"#FAFAFA":"#111111",grey:e?"#A1A1AA":"#71717A",edge:e?"#FFFFFF":"#000000",paper:e?"#18181B":"#FFFFFF"}}var ft=`<defs><pattern id="checker" width="16" height="16" patternUnits="userSpaceOnUse"><rect width="16" height="16" fill="#FFFFFF"/><rect width="8" height="8" fill="#E5E5E5"/><rect x="8" y="8" width="8" height="8" fill="#E5E5E5"/></pattern></defs>
|
|
4
|
-
`;function H(t,e,n,r="light",a={}){let{ink:o,grey:s,edge:l,paper:i}=at(r),h=Math.min(n.length,a.perRow??n.length),u=Math.ceil(n.length/Math.max(1,h)),c=h>8?64:104,x=10,m=Math.max(c,...n.map(g=>Math.max(g.name.length*8,Math.ceil(g.value.length*6.5)))),f=c+56,$=48+h*m+Math.max(0,h-1)*x,b=84+u*f,k=c>80?12:10,j=`<text id="title" x="24" y="38" ${M} font-size="15" font-weight="600" fill="${o}">${R(t)}</text><text id="subtitle" x="24" y="58" ${M} font-size="12" fill="${s}">${R(e)}</text>`,C=n.map((g,E)=>`<g id="${I(g.id)}" transform="translate(${24+E%h*(m+x)} ${80+Math.floor(E/h)*f})">`+(g.alpha===void 0?"":`<rect id="checker" width="${c}" height="${c}" rx="${k}" fill="url(#checker)"/>`)+`<rect id="swatch" width="${c}" height="${c}" rx="${k}" fill="${g.hex}"`+(g.alpha===void 0?"":` fill-opacity="${g.alpha.toFixed(3)}"`)+` stroke="${l}" stroke-opacity="0.08"/><text id="name" x="1" y="${c+22}" ${M} font-size="13" font-weight="600" fill="${o}">${R(g.name)}</text><text id="value" x="1" y="${c+40}" ${M} font-size="11" fill="${s}">${R(g.value)}</text></g>`).join(`
|
|
5
|
-
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${b}" viewBox="0 0 ${$} ${b}">
|
|
6
|
-
`+(n.some(g=>g.alpha!==void 0)?ft:"")+`<g id="${I(t)}">
|
|
7
|
-
<rect id="card" width="${$}" height="${b}" rx="0" fill="${i}"/>
|
|
8
|
-
${j}
|
|
9
|
-
${C}
|
|
10
|
-
</g>
|
|
11
|
-
</svg>`}function Tt(t,e,n="light",r){let a=t.replace(/\.[^.]+$/,""),o=e.length;return H(t,r?`${o} shade${o===1?"":"s"} of ${r}`:`${o} colour${o===1?"":"s"}, most of the image first`,e.map((s,l)=>({id:`${a}-${l+1}`,name:s.hex,value:tt(s.rgb),hex:s.hex})),n)}function _(t){if(t.set==="radix")return"Radix 1\u201312";if(t.set==="even")return`${t.start}\u2013${t.end}, ${t.count} even steps`;let e=w;return t.start===e.start&&t.end===e.end?"50\u2013950":`Tailwind ${t.start}\u2013${t.end}`}function Et(t,e,n="light",r=w){let a=S(t);return H(U(a),`from ${y(t)} \xB7 ${_(r)} in OKLCH`,e.map(o=>({id:`${a}-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),n)}function At(t,e,n,r=w,a="light"){let{ink:o,grey:s,edge:l,paper:i}=at(a),h=`${U(S(t))} palette`,u=`from ${y(t)} \xB7 ${nt[n]} \xB7 ${_(r)} in OKLCH`,c=[...e.rows.map(p=>({name:p.name,steps:p.steps})),{name:"neutral",steps:e.neutral}],x=c[0]?.steps.map(p=>p.step)??[],m=44,f=6,$=m+10,b=92,k=24+Math.max(92,...c.map(p=>p.name.length*8+12)),j=k+x.length*m+Math.max(0,x.length-1)*f+24,C=Math.max(j,48+Math.ceil(u.length*6.5)),g=b+c.length*$+24+10,E=`<text id="title" x="24" y="38" ${M} font-size="15" font-weight="600" fill="${o}">${R(h)}</text><text id="subtitle" x="24" y="58" ${M} font-size="12" fill="${s}">${R(u)}</text>`,st=x.map((p,A)=>`<text id="step-${p}" x="${k+A*(m+f)+1}" y="${b-10}" ${M} font-size="11" font-weight="600" fill="${s}">${p}</text>`).join(""),it=c.map((p,A)=>{let V=b+A*$+(A===c.length-1?10:0),X=I(p.name);return`<g id="${X}"><text id="name" x="24" y="${V+m/2+4}" ${M} font-size="13" font-weight="600" fill="${o}">${R(p.name)}</text>`+p.steps.map((Z,lt)=>`<g id="${X}-${Z.step}"><rect id="swatch" x="${k+lt*(m+f)}" y="${V}" width="${m}" height="${m}" rx="8" fill="${Z.hex}" stroke="${l}" stroke-opacity="0.08"/></g>`).join("")+"</g>"}).join(`
|
|
12
|
-
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${C}" height="${g}" viewBox="0 0 ${C} ${g}">
|
|
13
|
-
<g id="${I(h)}">
|
|
14
|
-
<rect id="card" width="${C}" height="${g}" rx="0" fill="${i}"/>
|
|
15
|
-
${E}
|
|
16
|
-
<g id="steps">${st}</g>
|
|
17
|
-
${it}
|
|
18
|
-
</g>
|
|
19
|
-
</svg>`}function Ot(t,e,n,r="light",a=w){return H(`${U(S(t))} neutral`,`from ${y(t)} \xB7 ${n} tint \xB7 ${_(a)} in OKLCH`,e.map(o=>({id:`neutral-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),r)}function Nt(t,e,n,r="light",a=w){let o=S(t);return H(`${U(o)} alpha`,`from ${y(t)} \xB7 over ${n} \xB7 ${_(a)}`,e.map(s=>({id:`${o}-alpha-${s.step}`,name:String(s.step),value:s.hex8,hex:y(s.rgb),alpha:s.a})),r)}export{wt as a,nt as b,W as c,St as d,Mt as e,Lt as f,H as g,Tt as h,Et as i,At as j,Ot as k,Nt as l};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as h,c as A,g as o,m as y,n as I,t as v,u as O,v as P}from"./chunk-FEFNS6YZ.js";import{a as x,b as u,d as S}from"./chunk-RQWWUCGQ.js";import{g as s,h as f,j as g,k as b,l as c,m as a}from"./chunk-V6GWPR2A.js";import{G as d}from"./chunk-ZBMJTIYR.js";var l=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0,k={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:e=>(l(e)?.pages??0)>1,unavailable:e=>l(e)===void 0?"one PDF at a time":"only one page",options(e){let t=l(e);return t?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${t.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(e,t){let n=l(e);if(!n)return[];let r=Array.isArray(t.cuts)?t.cuts:[],i=S(r,n.pages).length,C=c(f(n.path,i),o(t.destination),o(t.name));return[{op:"split",sources:[n],outputs:C,cuts:r}]}};function $(e){return Array.from({length:Math.max(0,e-1)},(t,n)=>n)}function B(e,t){if(!Number.isInteger(t)||t<1)throw d("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let r=t;r<e;r+=t)n.push(r-1);return n}var p=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0;function D(e,t){return Array.isArray(t.pages)?u(t.pages):typeof t.pages=="string"?u(x(t.pages,e.pages)):[]}var w=e=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${e.pages}`}),T={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:e=>p(e)!==void 0,unavailable:()=>"one PDF at a time",options:e=>{let t=p(e);return t?[w(t),{kind:"select",id:"separate",label:"Output",default:"one",choices:[{value:"one",label:"One file",hint:"all selected pages together"},{value:"many",label:"Separate files",hint:"one per page"}]}]:[]},plan(e,t){let n=p(e);if(!n)return[];let r=D(n,t),i=t.separate==="many";return[{op:"extract",sources:[n],outputs:c(g(n.path,r,i),o(t.destination),o(t.name)),pages:r,separate:i}]}},j={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:e=>p(e)!==void 0,unavailable:()=>"one PDF at a time",options:e=>{let t=p(e);return t?[w(t)]:[]},plan(e,t){let n=p(e);return n?[{op:"delete",sources:[n],outputs:[a(s(n.path,"trimmed"),o(t.destination),o(t.name))],pages:D(n,t)}]:[]}};var m=e=>e.filter(t=>t.kind==="document"&&t.format==="pdf"),J={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:e=>m(e).length>=2&&m(e).length===e.length,unavailable:e=>m(e).length!==e.length?"PDFs only":"needs 2+ files",options:()=>[],plan(e,t){let n=a(b(e.map(r=>r.path)),o(t.destination),o(t.name));return[{op:"merge",sources:e,outputs:[n]}]}};var N=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0,E={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:e=>N(e)!==void 0,unavailable:()=>"one PDF at a time",options:()=>[{kind:"select",id:"degrees",label:"Turn",default:"90",choices:[{value:"90",label:"90\xB0 right",hint:"a quarter turn"},{value:"180",label:"180\xB0",hint:"upside down"},{value:"270",label:"90\xB0 left",hint:"a quarter turn back"}]}],plan(e,t){let n=N(e);if(!n)return[];let i=Number(t.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[a(s(n.path,"rotated"),o(t.destination),o(t.name))],turns:i}]}};var R=[I,y,J,k,T,j,E,v,O,P],se=R.filter(e=>!["convert","compress","trim","resize","crop"].includes(e.id)),F=[h,A];function ce(e,t=new Set){return[...R,...F.filter(n=>n.requires&&t.has(n.requires))].filter(n=>n.appliesTo(e))}function le(e,t){return e.appliesTo(t)?void 0:e.unavailable?.(t)}export{E as a,k as b,$ as c,B as d,R as e,se as f,ce as g,le as h};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{d as q,k as V}from"./chunk-4MJEEEFA.js";import{n as ye,o as j,q as ve}from"./chunk-V6GWPR2A.js";import{a as Se,b as Ie,c as xe,d as Ee,e as Me,f as Oe,g as $}from"./chunk-WBW6G4N6.js";import{D as fe,G as W,L as de,Z as ue,a as C,b as Z,c as ee,ca as me,d as U,e as te,ea as pe,f as re,fa as le,g as ne,ga as ge,h as oe,ha as we,i as ae,ia as be,ma as _,n as ie,o as se,p as ce,v as he,w as N}from"./chunk-ZBMJTIYR.js";import{c as P}from"./chunk-VLVNA4T3.js";import{a as g}from"./chunk-H3DIRJFE.js";import{b as M}from"./chunk-KXKQDFHX.js";import{constants as We}from"node:fs";import{access as Ve,readFile as je,rm as Je,stat as Xe,writeFile as Ge}from"node:fs/promises";import{dirname as He}from"node:path";var ze=[{id:"light",label:"Light",passes:[{threshold:12,range:24}]},{id:"medium",label:"Medium",passes:[{threshold:20,range:48},{threshold:20,range:24}]},{id:"strong",label:"Strong",passes:[{threshold:31,range:64},{threshold:31,range:32}]}],dt=1,ut=e=>ze.some(r=>r.id===e),Ae=e=>ze.find(r=>r.id===e),mt=e=>`debanded-${e}`;function wt(e){if(g[e].hasAlpha)return;let r=Object.keys(g).filter(t=>g[t].hasAlpha&&t!=="heic").join(", ");return W(`${g[e].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${r}.`)}var Be="1.1.0";function Fe(e,r){let t=e.split(".").map(o=>Number.parseInt(o,10)||0),n=r.split(".").map(o=>Number.parseInt(o,10)||0);for(let o=0;o<Math.max(t.length,n.length);o++){let i=(t[o]??0)-(n[o]??0);if(i!==0)return i>0}return!0}var _e="1.4.0";function bt(e){return e!==void 0&&Fe(e,_e)}function J(e){return e!==void 0&&Fe(e,Be)?[2,3,4]:[2,4]}function yt(e,r,t){if(e===1||J(r).some(o=>o===e))return;if(t!==void 0&&J(t).some(o=>o===e))return de("boost",`boost ${e}\xD7`,r,Be);let n=J(r).map(o=>`--boost ${o}`);return W(`No released boost makes ${e}\xD7 yet.`,`Try ${n.slice(0,-1).join(", ")} or ${n.at(-1)}.`)}var qe=16384,$e=1e8;function Te(e,r,t){let n=Math.max(e,r)*t;if(n>qe)return{side:n};let o=e*t*r*t;if(o>$e)return{megapixels:Math.round(o/1e6)}}var B=e=>Math.max(1,Math.round(e));function X(e,r){return"percent"in r?{width:B(e.width*r.percent/100),height:B(e.height*r.percent/100)}:"width"in r?{width:B(r.width),height:B(e.height*r.width/e.width)}:{width:B(e.width*r.height/e.height),height:B(r.height)}}function Le(e){return Te(e.width,e.height,1)}function Ue(e){let r=e>>>0;return()=>{r=r+1831565813>>>0;let t=r;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function De(e,r,t,n,{threshold:o,range:i},c=1){let m=Buffer.from(e),a=Math.min(3,n),s=Ue(c),d=h=>h<0?0:h>=r?r-1:h,u=h=>h<0?0:h>=t?t-1:h;for(let h=0;h<t;h++)for(let p=0;p<r;p++){let b=s()*i,l=s()*2*Math.PI,f=Math.round(Math.cos(l)*b),y=Math.round(Math.sin(l)*b),v=(u(h+y)*r+d(p+f))*n,I=(u(h-y)*r+d(p-f))*n,x=(u(h+y)*r+d(p-f))*n,O=(u(h-y)*r+d(p+f))*n,E=(h*r+p)*n;for(let S=0;S<a;S++){let F=(e[v+S]+e[I+S]+e[x+S]+e[O+S])/4;Math.abs(e[E+S]-F)<o&&(m[E+S]=Math.round(F))}}return m}function Re(e,r){let t=new Map;for(let n=0;n<e.length;n+=3){let o=e[n],i=e[n+1],c=e[n+2],m=o<<16|i<<8|c;if(!t.has(m)){if(t.size>=r)return;t.set(m,[o,i,c])}}return[...t.values()]}function ke(e,r,t,n){let o=Buffer.alloc(e.length),i=Int16Array.from(n.flatMap(d=>[...d])),c=n.length,m=(r+2)*3,a=new Float32Array(m),s=new Float32Array(m);for(let d=0;d<t;d++){let u=d%2===0;for(let p=0;p<r;p++){let b=u?p:r-1-p,l=(d*r+b)*3,f=(b+1)*3,y=Math.min(255,Math.max(0,e[l]+a[f])),v=Math.min(255,Math.max(0,e[l+1]+a[f+1])),I=Math.min(255,Math.max(0,e[l+2]+a[f+2])),x=0,O=Number.POSITIVE_INFINITY;for(let A=0;A<c;A++){let H=y-i[A*3],Y=v-i[A*3+1],K=I-i[A*3+2],Q=H*H+Y*Y+K*K;Q<O&&(O=Q,x=A)}let E=i[x*3],S=i[x*3+1],F=i[x*3+2];o[l]=E,o[l+1]=S,o[l+2]=F;let D=y-E,R=v-S,k=I-F,w=u?f+3:f-3,z=u?f-3:f+3;a[w]=a[w]+D*7/16,a[w+1]=a[w+1]+R*7/16,a[w+2]=a[w+2]+k*7/16,s[z]=s[z]+D*3/16,s[z+1]=s[z+1]+R*3/16,s[z+2]=s[z+2]+k*3/16,s[f]=s[f]+D*5/16,s[f+1]=s[f+1]+R*5/16,s[f+2]=s[f+2]+k*5/16,s[w]=s[w]+D/16,s[w+1]=s[w+1]+R/16,s[w+2]=s[w+2]+k/16}let h=a;a=s,s=h,s.fill(0)}return o}var Ye=new Set(["jpeg","png","webp","avif","heic","raw","gif","tiff"]),Ke=new Set(["jpeg","png","webp","avif","gif","tiff"]),Qe={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function Ze(e,r){if(r.format==="heif")return r.compression==="av1"?"avif":"heic";let t=Qe[r.format??""];if(!t)throw ae(e,r.format??"an unknown format");return t}async function et(e){let r;try{r=await Xe(e)}catch(i){let c=i.code;throw c==="ENOENT"?Z(e):c==="EACCES"||c==="EPERM"?U(e):c==="ENOTDIR"?te(e):c==="ELOOP"?re(e):c==="ENAMETOOLONG"?ne(e):oe(e,i)}if(!r.isFile())throw ee(e);try{await Ve(e,We.R_OK)}catch{throw U(e)}if(await Ie(e)){if(!await Se())throw ie(e);let i;try{i=await xe(e)}catch(c){throw N(e,"heic",c)}if(i.width===0||i.height===0)throw N(e,"heic",void 0);return{kind:"image",path:e,format:"heic",width:i.width,height:i.height,bytes:r.size,hasAlpha:i.hasAlpha,frames:1}}let t=await Ee(e);if(t){if(!await Me())throw se(e);let i;try{i=await Oe(e,t)}catch(c){throw N(e,"raw",c)}if(!i)throw ce(e);return{kind:"image",path:e,format:"raw",width:i.width,height:i.height,bytes:r.size,hasAlpha:!1,frames:1}}let n=await M(),o;try{o=await n(e).metadata()}catch(i){throw he(e,i)}return{kind:"image",path:e,format:Ze(e,o),width:o.autoOrient?.width??o.width??0,height:o.autoOrient?.height??o.height??0,bytes:r.size,hasAlpha:o.hasAlpha??!1,frames:o.pages??1}}function Pe(e,r,t,n){let o=t??g[r].defaultQuality;if(n&&g[r].quantisable)return tt(e,r,t,n);switch(r){case"jpeg":return e.jpeg({quality:o,mozjpeg:!0});case"webp":return e.webp({quality:o});case"avif":return e.avif({quality:o});case"png":return e.png({compressionLevel:9});case"gif":return e.gif();case"tiff":return e.tiff({compression:"deflate"});case"heic":throw new Error("heic is not writable; the capability graph should have prevented this");case"raw":throw new Error("raw is not writable; the capability graph should have prevented this");case"pdf":throw new Error("pdf is not an image target; the capability graph should have prevented this");case"docx":throw new Error("docx is not an image target; the capability graph should have prevented this");case"doc":throw new Error("doc is not an image target; the capability graph should have prevented this");default:throw new Error(`${r} is not an image target; the capability graph should have prevented this`)}}function tt(e,r,t,{dither:n}){let o=t??100,i=n?1:0;return r==="gif"?e.gif({interFrameMaxError:Math.round(32*(100-o)/100),dither:i}):e.png({palette:!0,quality:o,dither:i,compressionLevel:9,effort:10})}async function G(e,r,t,n){if(t.deband){let f=await M(),{data:y,info:v}=await e.clone().withIccProfile("srgb").raw().toBuffer({resolveWithObject:!0}),I=y;Ae(t.deband).passes.forEach((O,E)=>{I=De(I,v.width,v.height,v.channels,O,E+1)});let x={width:v.width,height:v.height,channels:v.channels};return await Pe(f(I,{raw:x}).withIccProfile("srgb"),r,t.quality,t.compress).toBuffer()}let o=t.dither;if(o===void 0||!g[r].quantisable)return await Pe(e,r,t.quality,t.compress).toBuffer();let i=f=>r==="gif"?f.gif({colours:o,dither:0,effort:10}):f.png({palette:!0,colours:o,quality:100,dither:0,compressionLevel:9,effort:10}),c=()=>r==="gif"?e.gif({colours:o,dither:1,effort:10}):e.png({palette:!0,colours:o,quality:100,dither:1,compressionLevel:9,effort:10});if(n)return await c().toBuffer();let m=await M(),a=e.clone().withIccProfile("srgb"),{data:s,info:d}=await a.raw().toBuffer({resolveWithObject:!0});if(d.channels===4){for(let f=3;f<s.length;f+=4)if(s[f]!==255)return await c().toBuffer()}let u=d.channels===3?s:rt(s),h=await i(m(u,{raw:{width:d.width,height:d.height,channels:3}})).toBuffer(),p=await m(h).removeAlpha().raw().toBuffer(),b=Re(p,o);if(!b)return await c().toBuffer();let l=ke(u,d.width,d.height,b);return await i(m(l,{raw:{width:d.width,height:d.height,channels:3}}).withIccProfile("srgb")).toBuffer()}function rt(e){let r=Buffer.alloc(e.length/4*3);for(let t=0,n=0;t<e.length;t+=4,n+=3)r[n]=e[t],r[n+1]=e[t+1],r[n+2]=e[t+2];return r}var T=(e,r)=>e.kind==="image"&&e.frames>1&&g[r].animatable;async function nt(e,r){let t=He(r);await j(r);let n=ye(r);try{return await Ge(n,e),await ve(n,r),e.length}catch(o){throw await Je(n,{force:!0}).catch(()=>{}),fe(r,o)}}async function L(e,r,t,n,o,i){if(e.kind!=="image")throw new Error("pipelineFor received a non-image source");let c=o??await $(e.path,e.format),a=(await M())(c,n?{animated:!0}:{});if(a=a.rotate(),t.trim&&(a=a.trim()),t.crop){if(!t.crop.box)throw new Error("pipelineFor needs the crop placed (run does it)");a=a.extract(t.crop.box)}if(t.resize){if(!i&&(t.trim||t.crop))throw new Error("pipelineFor needs the resolved size to resize a cut image");let s=i??X(e,t.resize);a=a.resize(s.width,s.height,{fit:"fill"})}return t.rotate&&(a=a.rotate(t.rotate)),e.hasAlpha&&!g[r].hasAlpha&&(a=a.flatten({background:t.background})),a=t.keepMetadata?a.keepMetadata():a.keepIccProfile(),{pipeline:a}}async function $t(e,r){let t={background:"#ffffff",keepMetadata:!1},{pipeline:n}=await L(e,"png",t,!1);await n.png({compressionLevel:1}).toFile(r)}async function Ut(e,r,t){let{pipeline:n}=await L(e,r,t,T(e,r));return await G(n,r,t,T(e,r))}async function ot(e){let r={width:e.width,height:e.height};if(e.frames>1)return{upright:r,trimmed:"animated"};let t=await $(e.path,e.format);try{let n=await M(),{info:o}=await n(t).rotate().trim().jpeg({quality:1}).toBuffer({resolveWithObject:!0});return o.width===r.width&&o.height===r.height?{upright:r,trimmed:"nothing"}:{upright:r,trimmed:{width:o.width,height:o.height}}}catch(n){throw C(n)?n:_(e.path,n)}}var Ce=1024;async function at(e){let r={background:"#ffffff",keepMetadata:!1},{pipeline:t}=await L(e,"png",r,!1);try{let{data:n,info:o}=await t.resize(Ce,Ce,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0}),i=o.width*o.height,c=o.channels,m=new Uint8Array(i*3),a=new Uint8Array(i),s=!1;for(let d=0;d<i;d++){for(let u=0;u<3;u++)m[d*3+u]=n[d*c+(c>=4?u:0)]??0;a[d]=n[d*c+c-1]??255,a[d]!==255&&(s=!0)}return{size:{width:e.width,height:e.height},thumb:{width:o.width,height:o.height,rgb:m,...s?{alpha:a}:{}}}}catch(n){throw C(n)?n:_(e.path,n)}}var Ne=128;async function it(e,r){let{thumb:t,size:n}=e,o=q(t,r),i=await M(),{info:c}=await i(st(t),{raw:{width:t.width,height:t.height,channels:3}}).resize(o.width,o.height,{fit:"cover",position:i.strategy.attention}).raw().toBuffer({resolveWithObject:!0}),m=q(n,r),a=Math.round(-(c.cropOffsetLeft??0)*n.width/t.width),s=Math.round(-(c.cropOffsetTop??0)*n.height/t.height);return{...m,left:Math.min(Math.max(a,0),n.width-m.width),top:Math.min(Math.max(s,0),n.height-m.height)}}function st(e){let{alpha:r}=e;if(!r)return e.rgb;let t=new Uint8Array(e.rgb.length);for(let n=0;n<t.length;n++){let o=(r[Math.floor(n/3)]??255)/255;t[n]=Math.round(Ne+((e.rgb[n]??0)-Ne)*o)}return t}async function ct(e,r){if(e.op!=="convert")throw new Error(`image engine cannot ${e.op}`);let t=e.sources[0],n=e.outputs[0];if(t.kind!=="image")throw new Error("the image engine cannot convert a document source");let o=g[e.target],i=[];r({phase:"reading"});let c=t.frames>1,m=T(t,e.target);c&&!o.animatable&&i.push({code:"animation-flattened",message:`${P(t.path)} has ${t.frames} frames, and ${o.label} cannot animate. Only the first frame was converted.`});let a=e.options,s;if(a.rotate&&c)throw be(t.path);if(a.trim||a.crop||a.resize){let u={width:t.width,height:t.height};if(a.trim&&a.crop)throw new Error("a job cannot both trim and crop");if(a.crop){if(c)throw we(t.path);let{aspect:h}=a.crop,p=f=>f.width===t.width&&f.height===t.height,b=q(u,h),l=a.crop.box??(p(b)?b:await it(await at(t),h));if(p(l)){if(!a.resize)throw ge(t.path,V(h));i.push({code:"nothing-cropped",message:`${P(t.path)} is already ${V(h)}; resized only.`});let{crop:f,...y}=a;a=y}else a={...a,crop:{aspect:h,box:l}},u={width:l.width,height:l.height}}if(a.trim){if(c)throw le(t.path);let{trimmed:h}=await ot(t);if(h==="nothing"){if(!a.resize)throw pe(t.path);i.push({code:"nothing-trimmed",message:`${P(t.path)} has no empty edges; resized only.`})}else h!=="animated"&&(u=h)}if(a.resize&&(s=X(u,a.resize),Le(s)))throw ue(t.path,s)}r({phase:"decoding"});let{pipeline:d}=await L(t,e.target,a,m,void 0,s);try{await j(n),r({phase:"encoding"});let u=await G(d,e.target,a,m);if(a.compress&&u.length>=t.bytes)throw me(t.path,t.bytes,u.length);r({phase:"writing"});let h=await nt(u,n);return{job:e,outputBytes:h,warnings:i}}catch(u){throw C(u)?u:_(t.path,u)}}async function ht(e){let r=await $(e.path,e.format);return typeof r=="string"?await je(r):r}async function ft(e){if(e.op!=="convert")return;let r=g[e.target];if(!r.lossy&&!(r.quantisable&&e.options.compress))return;let t=e.sources[0];if(t.kind!=="image")return;let n=await ht(t);return{ladder:[{}],measure:async o=>{let{pipeline:i}=await L(t,e.target,o,T(t,e.target),n);return(await G(i,e.target,o,T(t,e.target))).length}}}var Wt={id:"image",reads:Ye,writes:Ke,ops:new Set(["convert"]),probe:et,run:ct,measurer:ft};export{wt as a,bt as b,J as c,yt as d,qe as e,Te as f,ze as g,dt as h,ut as i,mt as j,X as k,Le as l,Pe as m,nt as n,$t as o,Ut as p,ot as q,at as r,it as s,Wt as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{C as P,D as l,E as S}from"./chunk-ZBMJTIYR.js";import{c as x}from"./chunk-H3DIRJFE.js";import{existsSync as h,statSync as w}from"node:fs";import{basename as f,dirname as _,extname as g,isAbsolute as M,join as c,relative as D,resolve as i,sep as F}from"node:path";function $(t){return t.endsWith("/")||t.endsWith(F)||h(t)&&w(t).isDirectory()?!0:g(t)===""}var O=255;function b(t,r){return r==="darwin"||r==="win32"?t.length:Buffer.byteLength(t)}function a(t,r,n=process.platform){if(b(t+r,n)<=O)return t+r;let e="";for(let s of t){if(b(e+s+r,n)>O)break;e+=s}return e+r}function it(t,r){if(i(t)===i(r))return!0;try{let n=w(t),e=w(r);return n.dev===e.dev&&n.ino===e.ino}catch{return!1}}function L(t,r){let n=f(t),e=g(n),s=e?n.slice(0,-e.length):n;return a(s,x(r))}function v(t,r,n){if(!n)return t;let e=D(i(n),r);return!e||e.startsWith("..")?t:c(t,e)}function k(t){let r=i(t.sourcePath),n=L(r,t.target);if(!t.output)return c(i(r,".."),n);let e=M(t.output)?t.output:i(t.output);return $(t.output)?c(v(e,i(r,".."),t.sourceRoot),n):i(e)}function st(t){let r=k(t);if(t.output&&!$(t.output))return r;let n=g(r);return c(i(r,".."),a(f(r,n),`-${t.suffix}${n}`))}function ot(t){if(!h(t))return t;let r=i(t,".."),n=f(t),e=g(n),s=e?n.slice(0,-e.length):n;for(let o=1;o<1e4;o++){let u=c(r,a(s,` (${o})${e}`));if(!h(u))return u}throw new Error(`no free name beside ${n}`)}function p(t){let r=i(t,".."),n=f(t),e=g(n);return{dir:r,stem:e?n.slice(0,-e.length):n,ext:e||".pdf"}}function A(t,r){let{dir:n,stem:e,ext:s}=p(i(t));return c(n,a(e,`-${r}${s}`))}function ut(t,r){let{dir:n,stem:e,ext:s}=p(i(t)),o=String(r).length;return Array.from({length:r},(u,m)=>c(n,a(e,`-${String(m+1).padStart(o,"0")}${s}`)))}function ct(t,r,n,e,s){let{stem:o}=p(i(t)),u=e?v(i(e),i(t,".."),s):i(t,".."),m=x(n),I=String(Math.max(1,...r.map(d=>d+1))).length,R=r.map(d=>c(u,a(o,`-${String(d+1).padStart(I,"0")}${m}`))),[E,...T]=R;if(E===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[E,...T]}function at(t,r,n){if(!n)return[A(t,"extract")];let{dir:e,stem:s,ext:o}=p(i(t));return r.map(u=>c(e,a(s,`-p${u+1}${o}`)))}function mt(t){let r=i(t[0]??"merged.pdf");if(new Set(t.map(e=>i(e,".."))).size===1){let e=i(r,"..");return c(e,a(f(e),"-merged.pdf"))}return A(r,"merged")}function B(t,r,n){let e=r?t.map(o=>c(r,f(o))):t,[s]=e;return!n||e.length!==1||s===void 0?e:[c(_(s),`${n}${g(s)}`)]}function ft(t,r,n){return B([t],r,n)[0]??t}import{execFile as J}from"node:child_process";import{randomBytes as j}from"node:crypto";import{constants as C}from"node:fs";import{access as U,mkdir as Y,rename as N,rm as z,writeFile as G}from"node:fs/promises";import{basename as y,dirname as W,extname as K,join as H}from"node:path";function Q(t,r=j(6).toString("hex")){let n=K(t);return H(W(t),a(`.forge-${r}-${y(t,n)}`,n))}async function V(t){let r=W(t);try{await Y(r,{recursive:!0})}catch(n){let e=l(t,n);throw e===n?S(t,n):e}try{await U(r,C.W_OK)}catch(n){throw P(t,n)}}var X=new Set(["EPERM","EBUSY","EACCES"]),Z=5,Et=9;async function q(t,r,n=process.platform,e=o=>new Promise(u=>setTimeout(u,o)),s=Z){if(n!=="win32"){await N(t,r),n==="darwin"&&await tt(t,r);return}for(let o=1;;o++)try{await N(t,r);return}catch(u){let m=u.code;if(o>=s||!m||!X.has(m))throw u;await e(Math.min(50*2**(o-1),1e3))}}function tt(t,r){return!y(t).startsWith(".")||y(r).startsWith(".")?Promise.resolve():new Promise(n=>{J("/usr/bin/chflags",["nohidden",r],()=>n())})}async function Pt(t,r){await V(t);let n=Q(t);try{return await G(n,r),await q(n,t),r.byteLength}catch(e){throw await z(n,{force:!0}).catch(()=>{}),l(t,e)}}export{$ as a,a as b,it as c,k as d,st as e,ot as f,A as g,ut as h,ct as i,at as j,mt as k,B as l,ft as m,Q as n,V as o,Et as p,q,Pt as r};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as E}from"./chunk-O7DK3GJT.js";import{i as R}from"./chunk-RQWWUCGQ.js";import{a as F,ma as y}from"./chunk-ZBMJTIYR.js";function P(n=process.env){let r=Number(n.UV_THREADPOOL_SIZE),o=E();return Number.isInteger(r)&&r>0?Math.min(o,r):o}function w(n){let r=n!==void 0&&Number.isFinite(n)?n:void 0;return Math.max(1,r??P())}async function x(n,r,o,f){let b=[],l=[];for(let[i,u]of n.entries())(f?.(u)?l:b).push(i);let p=0,m=0,t,g=async()=>{for(;;){let i=b[p],u=t?void 0:l[m];if(i!==void 0&&(u===void 0||i<u))p++,await o(n[i],i);else if(u!==void 0)m++,t=o(n[u],u).finally(()=>{t=void 0}),await t;else if(t)await t;else return}},d=Math.min(w(r),n.length);await Promise.all(Array.from({length:d},g))}async function T(n,r){let o=r.onEvent??(()=>{}),f=r.engineFor??R,b=w(r.concurrency),l=n.length,p=[],m=[],t=0;await x(n,b,async(e,a)=>{if(r.signal?.aborted)return;o({type:"job:start",job:e,index:a,total:l});let h=f(e);if(!h){t++;let s=e.sources[0].path,c={path:s,error:y(s,new Error(`no engine runs ${e.op}`))};m[a]=c,o({type:"job:error",job:e,failure:c,completed:t,total:l});return}try{let s=await h.run(e,c=>o({type:"job:phase",job:e,progress:c}),r.signal);p[a]=s,t++,o({type:"job:done",job:e,result:s,completed:t,total:l})}catch(s){t++;let c=e.sources[0].path,J=F(s)?s:y(c,s),v={path:c,error:J};m[a]=v,o({type:"job:error",job:e,failure:v,completed:t,total:l})}},e=>f(e)?.alone===!0);let d=p.filter(e=>e!==void 0),i=m.filter(e=>e!==void 0),u={results:d,failures:i,inputBytes:d.reduce((e,a)=>e+a.job.sources[0].bytes,0),outputBytes:d.reduce((e,a)=>e+a.outputBytes,0)};return o({type:"batch:done",summary:u}),u}export{P as a,w as b,x as c,T as d};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as D}from"./chunk-DHW72U6X.js";import{a as X,b as Q}from"./chunk-HZDYZ5RD.js";import{j as M}from"./chunk-N32JL4UI.js";import{a as K}from"./chunk-4OSMYHKQ.js";import{b as J}from"./chunk-EEQSUBBL.js";import{a as W}from"./chunk-HTA25PO2.js";import{a as Y}from"./chunk-KH5DHZ2U.js";import{a as U}from"./chunk-TLHUFIXD.js";import{m as R}from"./chunk-4MJEEEFA.js";import{G as d,J as H}from"./chunk-ZBMJTIYR.js";import{d as L}from"./chunk-J7FLFHQJ.js";import{b as z}from"./chunk-H3DIRJFE.js";var O=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},k=class extends O{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var E=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new k(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function N(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as le}from"node:events";import G from"node:child_process";import C from"node:path";import F from"node:fs";import m from"node:process";import{stripVTControlCharacters as ce}from"node:util";import{stripVTControlCharacters as se}from"node:util";var T=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,r)=>i.name().localeCompare(r.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),r=n.long&&e._findOption(n.long);!i&&!r?t.push(n):n.long&&!r?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(r=>!r.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>N(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[])}),t.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[]),i.get(o).push(r)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function r(h,p){return t.formatItem(h,n,p,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(u),i),""]));let l=t.visibleArguments(e).map(h=>r(t.styleArgumentTerm(t.argumentTerm(h)),t.styleArgumentDescription(t.argumentDescription(h))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),h=>h.helpGroupHeading??"Options:").forEach((h,p)=>{let x=h.map(_=>r(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));o=o.concat(this.formatItemList(p,x,t))}),t.showGlobalOptions){let h=t.visibleGlobalOptions(e).map(p=>r(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",h,t))}return this.groupItems(e.commands,t.visibleCommands(e),h=>h.helpGroup()||"Commands:").forEach((h,p)=>{let x=h.map(_=>r(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,x,t))}),o.join(`
|
|
4
|
-
`)}displayWidth(e){return se(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let o=" ".repeat(2);if(!n)return o+e;let u=e.padEnd(t+e.length-i.displayWidth(e)),l=2,a=(this.helpWidth??80)-t-l-2,h;return a<this.minWidthToWrap||i.preformatted(n)?h=n:h=i.boxWrap(n,a).replace(/\n/g,`
|
|
5
|
-
`+" ".repeat(t+l)),o+u+" ".repeat(l)+h.replace(/\n/g,`
|
|
6
|
-
${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,r=[];return n.forEach(o=>{let u=o.match(i);if(u===null){r.push("");return}let l=[u.shift()],c=this.displayWidth(l[0]);u.forEach(a=>{let h=this.displayWidth(a);if(c+h<=t){l.push(a),c+=h;return}r.push(l.join(""));let p=a.trimStart();l=[p],c=this.displayWidth(p)}),r.push(l.join(""))}),r.join(`
|
|
7
|
-
`)}};var A=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=ae(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new k(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Z(this.name().replace(/^no-/,"")):Z(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},V=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,r=i!==void 0?i:!1;return t.negate===(r===e)}};function Z(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ae(s){let e,t,n=/^-[^-]$/,i=/^--[^-]/,r=s.split(/[ |,]+/).concat("guard");if(n.test(r[0])&&(e=r.shift()),i.test(r[0])&&(t=r.shift()),!e&&n.test(r[0])&&(e=r.shift()),!e&&i.test(r[0])&&(e=t,t=r.shift()),r[0].startsWith("-")){let o=r[0],u=`option creation failed due to '${o}' in option flags '${s}'`;throw/^-[^-][^-]/.test(o)?new Error(`${u}
|
|
8
|
-
- a short flag is a single dash and a single character
|
|
9
|
-
- either use a single dash and a single character (for a short flag)
|
|
10
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(o)?new Error(`${u}
|
|
11
|
-
- too many short flags`):i.test(o)?new Error(`${u}
|
|
12
|
-
- too many long flags`):new Error(`${u}
|
|
13
|
-
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${s}'.`);return{shortFlag:e,longFlag:t}}function ue(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let n=0;n<=s.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=s.length;i++){let r;s[i-1]===e[n-1]?r=0:r=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+r),i>1&&n>1&&s[i-1]===e[n-2]&&s[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[s.length][e.length]}function q(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(o=>o.slice(2)));let n=[],i=3,r=.4;return e.forEach(o=>{if(o.length<=1)return;let u=ue(s,o),l=Math.max(s.length,o.length);(l-u)/l>r&&(u<i?(i=u,n=[o]):u===i&&n.push(o))}),n.sort((o,u)=>o.localeCompare(u)),t&&(n=n.map(o=>`--${o}`)),n.length>1?`
|
|
14
|
-
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
15
|
-
(Did you mean ${n[0]}?)`:""}var $=class s extends le{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>m.stdout.write(t),writeErr:t=>m.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>te()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>te()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:t=>ce(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let i=t,r=n;typeof i=="object"&&i!==null&&(r=i,i=null),r=r||{};let[,o,u]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),r.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(r.noHelp||r.hidden),l._executableFile=r.executableFile||null,u&&l.arguments(u),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(e){return new s(e)}createHelp(){return Object.assign(new T,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
16
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new E(e,t)}argument(e,t,n,i){let r=this.createArgument(e,t);return typeof n=="function"?r.default(i).argParser(n):r.default(n),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,r]=n.match(/([^ ]+) *(.*)/),o=t??"display help for command",u=this.createCommand(i);return u.helpOption(!1),r&&u.arguments(r),o&&u.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=u,(e||t)&&this._initCommandGroup(u),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
17
|
-
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new O(e,t,n)),m.exit(e)}action(e){let t=n=>{let i=this.registeredArguments.length,r=n.slice(0,i);return this._storeOptionsAsProperties?r[i]=this:r[i]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new A(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${i} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
18
|
-
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(r,o,u)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let l=this.getOptionValue(n);r!==null&&e.parseArg?r=this._callParseArg(e,r,l,o):r!==null&&e.variadic&&(r=e._collectValue(r,l)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(n,r,u)};return this.on("option:"+t,r=>{let o=`error: option '${e.flags}' argument '${r}' is invalid.`;i(r,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let o=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;i(r,o,"env")}),this}_optionEx(e,t,n,i,r){if(typeof t=="object"&&t instanceof A)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,n);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(r).argParser(i);else if(i instanceof RegExp){let u=i;i=(l,c)=>{let a=u.exec(l);return a?a[0]:c},o.default(r).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){m.versions?.electron&&(t.from="electron");let i=m.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=m.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":m.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
19
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(F.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",r=`'${e}' does not exist
|
|
20
|
-
- if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
21
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
22
|
-
- ${i}`;throw new Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(a,h){let p=C.resolve(a,h);if(F.existsSync(p))return p;if(n.includes(C.extname(h)))return;let x=n.find(_=>F.existsSync(`${p}${_}`));if(x)return`${p}${x}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||"";if(this._scriptPath){let a;try{a=F.realpathSync(this._scriptPath)}catch{a=this._scriptPath}o=C.resolve(C.dirname(a),o)}if(o){let a=i(o,r);if(!a&&!e._executableFile&&this._scriptPath){let h=C.basename(this._scriptPath,C.extname(this._scriptPath));h!==this._name&&(a=i(o,`${h}-${e._name}`))}r=a||r}let u=n.includes(C.extname(r)),l;m.platform!=="win32"?u?(t.unshift(r),t=ee(m.execArgv).concat(t),l=G.spawn(m.argv[0],t,{stdio:"inherit"})):l=G.spawn(r,t,{stdio:"inherit"}):(this._checkForMissingExecutable(r,o,e._name),t.unshift(r),t=ee(m.execArgv).concat(t),l=G.spawn(m.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{m.on(h,()=>{l.killed===!1&&l.exitCode===null&&l.kill(h)})});let c=this._exitCallback;l.on("close",a=>{a=a??1,c?c(new O(a,"commander.executeSubCommandAsync","(close)")):m.exit(a)}),l.on("error",a=>{if(a.code==="ENOENT")this._checkForMissingExecutable(r,o,e._name);else if(a.code==="EACCES")throw new Error(`'${r}' not executable`);if(!c)m.exit(1);else{let h=new O(1,"commander.executeSubCommandAsync","(error)");h.nestedError=a,c(h)}}),this.runningCommand=l}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let r;return r=this._chainOrCallSubCommandHook(r,i,"preSubcommand"),r=this._chainOrCall(r,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),r}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,r)=>{let o=i;if(i!==null&&n.parseArg){let u=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;o=this._callParseArg(n,i,r,u)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let r=n.defaultValue;n.variadic?i<this.args.length?(r=this.args.slice(i),n.parseArg&&(r=r.reduce((o,u)=>e(n,u,o),n.defaultValue))):r===void 0&&(r=[]):i<this.args.length&&(r=this.args[i],n.parseArg&&(r=e(n,r,n.defaultValue))),t[i]=r}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(o=>{i.push({hookedCommand:r,callback:o})})}),t==="postAction"&&i.reverse(),i.forEach(r=>{n=this._chainOrCall(n,()=>r.callback(r.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(r=>{i=this._chainOrCall(i,()=>r(this,t))}),i}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(r))i(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(r=>n.conflictsWith.includes(r.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function r(a){return a.length>1&&a[0]==="-"}let o=a=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(a)?!this._getCommandAndAncestors().some(h=>h.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,u=null,l=null,c=0;for(;c<e.length||l;){let a=l??e[c++];if(l=null,a==="--"){i===n&&i.push(a),i.push(...e.slice(c));break}if(u&&(!r(a)||o(a))){this.emit(`option:${u.name()}`,a);continue}if(u=null,r(a)){let h=this._findOption(a);if(h){if(h.required){let p=e[c++];p===void 0&&this.optionMissingArgument(h),this.emit(`option:${h.name()}`,p)}else if(h.optional){let p=null;c<e.length&&(!r(e[c])||o(e[c]))&&(p=e[c++]),this.emit(`option:${h.name()}`,p)}else this.emit(`option:${h.name()}`);u=h.variadic?h:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let h=this._findOption(`-${a[1]}`);if(h){h.required||h.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${h.name()}`,a.slice(2)):(this.emit(`option:${h.name()}`),l=`-${a.slice(2)}`);continue}}if(/^--[^=]+=/.test(a)){let h=a.indexOf("="),p=this._findOption(a.slice(0,h));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,a.slice(h+1));continue}}if(i===t&&r(a)&&!(this.commands.length===0&&o(a))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(a)){t.push(a),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a,...e.slice(c));break}else if(this._defaultCommandName){n.push(a,...e.slice(c));break}}if(this._passThroughOptions){i.push(a,...e.slice(c));break}i.push(a)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
23
|
-
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
24
|
-
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
25
|
-
`),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,r=n.code||"commander.error";this._exit(i,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in m.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,m.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new V(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=o=>{let u=o.attributeName(),l=this.getOptionValue(u),c=this.options.find(h=>h.negate&&u===h.attributeName()),a=this.options.find(h=>!h.negate&&u===h.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:a||o},i=o=>{let u=n(o),l=u.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},r=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(u=>u.long).map(u=>u.long);i=i.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);t=q(e,i)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",i=e.length,r=this.parent?` for '${this.name()}'`:"",o=e.join(", "),u=`error: too many arguments${r}. Expected ${t} argument${n} but got ${i}: ${o}.`;this.error(u,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(r=>{i.push(r.name()),r.alias()&&i.push(r.alias())}),t=q(e,i)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
26
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>N(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=C.basename(e,C.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,r;return t?(n=u=>this._outputConfiguration.writeErr(u),i=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(n=u=>this._outputConfiguration.writeOut(u),i=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:t,write:u=>(i||(u=this._outputConfiguration.stripColor(u)),n(u)),hasColors:i,helpWidth:r}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation({error:n.error});if(t&&(r=t(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(m.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
27
|
-
Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,r=>{let o;typeof t=="function"?o=t({error:r.error,command:r.command}):o=t,o&&r.write(`${o}
|
|
28
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ee(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],n=r[3],i=r[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function te(){if(m.env.NO_COLOR||m.env.FORCE_COLOR==="0"||m.env.FORCE_COLOR==="false")return!1;if(m.env.FORCE_COLOR||m.env.CLICOLOR_FORCE!==void 0)return!0}var et=new $;function he(s){let[,e,t,...n]=s;if(e===void 0||e==="list")return{kind:"config",action:"list"};if(e==="path")return{kind:"config",action:"path"};if(e==="set"){if(t===void 0||!W.includes(t))throw d(`Unknown config setting ${t??"(none)"}.`,`Try one of: ${W.join(", ")}.`);let i=n.join(" ");if(i.length===0)throw d(`forge config set ${t} needs a value.`);return{kind:"config",action:"set",key:t,value:i}}throw d(`Unknown config action ${e}.`,"Try: forge config list, forge config set <setting> <value>, or forge config path.")}var de={jpg:"jpeg",tif:"tiff",heif:"heic"};function I(s){let e=s.toLowerCase().replace(/^\./,""),t=z(de[e]??e);if(!t)throw d(`${s} is not a format Forge knows.`,"Run forge --formats to see what is available.");return t.id}function P(s,e,t,n,i){let r=Number(String(e).replace(/k$/i,""));if(!Number.isFinite(r)||r<t||r>n)throw d(`${s} takes ${t} to ${n}, not ${e}.`,`For example ${s} ${i}.`);return r}function pe(s){let e={};if(s.cut!==void 0){let t=J(String(s.cut));if(!t)throw d(`--cut takes a start and an end, the end after the start, not ${s.cut}.`,"For example --cut 0:03.2-0:41, or --cut 0:10- to keep from 0:10 to the end.");e.cut=t.end===void 0?{start:t.start}:{start:t.start,end:t.end}}return s.mute&&(e.mute=!0),s.speed!==void 0&&(e.speed=P("--speed",s.speed,.25,4,"2")),s.fps!==void 0&&(e.fps=P("--fps",s.fps,1,120,"30")),s.bitrate!==void 0&&(e.bitrate=Math.round(P("--bitrate",s.bitrate,32,320,"128k"))),s.loudness!==void 0&&(e.loudness=P("--loudness",s.loudness,-70,-5,"-16")),s.cleanAudio&&(e.cleanup=!0,e.loudness??=-16),Object.keys(e).length?e:void 0}function S(s){let e=Number(s);if(!Number.isInteger(e)||e<1||e>100)throw d(`Quality must be a whole number between 1 and 100, not ${s}.`);return e}function ne(s,e){let t=/^\d+$/.test(String(e))?Number(e):Number.NaN;if(!Number.isInteger(t)||t<1)throw d(`${s} takes a whole number of pixels, at least 1, not ${e}.`);return t}function fe(s){let e=String(s),t=/^\d+(\.\d+)?%?$/.test(e)?Number.parseFloat(e):Number.NaN;if(!(t>=1&&t<=D))throw d(`--resize takes a percent from 1 to ${D}, not ${s}.`,"Try --resize 50% to halve, or --width 1200 for an exact width.");return t}function j(s){let e=Number(s);if(!Number.isInteger(e)||e<1)throw d(`Concurrency must be a positive whole number, not ${s}.`);return e}var me=`
|
|
29
|
-
Exit codes:
|
|
30
|
-
0 every input succeeded
|
|
31
|
-
1 the command was understood, and at least one input failed or was refused
|
|
32
|
-
2 the command itself was invalid: an unknown flag, a missing argument, contradictory flags`,ie=`
|
|
33
|
-
Other commands:
|
|
34
|
-
forge probe <files...> what each file is and what Forge can do with it
|
|
35
|
-
forge palette <image> an image's main colours (--json, --svg, --inside <hex>)
|
|
36
|
-
forge scale <colour> 50\u2013950 from one colour, with it at 500 (--json, --svg)
|
|
37
|
-
forge card <file> named colours as a card to paste into Figma
|
|
38
|
-
(--svg, --json, --title <text>; - reads stdin)
|
|
39
|
-
forge clip compress the copied image and put it back (--to, --quality,
|
|
40
|
-
--max-size, --save [folder], --undo)
|
|
41
|
-
forge transcribe <file | link>
|
|
42
|
-
a video or audio file, or a YouTube link, into notes
|
|
43
|
-
(--to all | notes | transcript, --detail brief | standard | detailed,
|
|
44
|
-
--format md | docx | pdf | txt, --language <id>, -o <path>, --force)
|
|
45
|
-
forge watch <folder> --to <format>
|
|
46
|
-
convert the folder, then every file added to it, until ctrl-c
|
|
47
|
-
(--quality, --dpi, -o <folder>, --new-only, --json)
|
|
48
|
-
forge config [list | path | set <setting> <value>]
|
|
49
|
-
forge extensions [add | remove <id>] optional extras, such as boost and remove-background
|
|
50
|
-
forge update install a newer Forge, if there is one
|
|
51
|
-
forge uninstall take Forge out of the right-click menu, then remove it
|
|
52
|
-
forge mcp run as a local MCP server over stdio, for AI agents`;function ge(s=process.platform){if(s==="darwin")return ie;let e=s==="win32"?"boost and whisper":"whisper and heic";return ie.replace("a video or audio file, or a YouTube link, into notes","a video or audio file, or a YouTube link, into a transcript").replace("optional extras, such as boost and remove-background",`optional extras, such as ${e}`)}function B(s){let e=L(String(s));if(e===void 0)throw d(`${s} is not a size.`,"Try a number with a unit, for example 500kb, 2mb or 1.5mb.");return e}function be(s){let e=s.slice(1).filter(n=>n!=="--json"),t=e.find(n=>n.startsWith("-"));if(t!==void 0)throw d(`forge probe takes files, not ${t}.`,"Try: forge probe photo.jpg --json");if(e.length===0)throw d("No files given.","Name a file, for example: forge probe scan.pdf --json");return{kind:"probe",inputs:e}}function _e(s){let e={kind:"clip",undo:!1,debug:!1},t=s.slice(1),n=(i,r)=>{let o=t[r+1];if(o===void 0||o.startsWith("-"))throw d(`${i} needs a value.`);return o};for(let i=0;i<t.length;i++){let r=t[i];if(r!=="--json")if(r==="--debug")e.debug=!0;else if(r==="--undo")e.undo=!0;else if(r==="--to"||r==="-t")e.target=I(n(r,i++));else if(r==="--quality"||r==="-q")e.quality=S(n(r,i++));else if(r==="--max-size")e.maxBytes=B(n(r,i++));else if(r==="--save"){let o=t[i+1];e.save=o===void 0||o.startsWith("-")?!0:t[++i]}else throw r.startsWith("-")?d(`forge clip does not take ${r}.`,"Try: forge --help"):d(`forge clip takes no files: it reads the clipboard, not ${r}.`,`To compress a file, try: forge ${r} --quality 80`)}if(e.undo&&Object.keys(e).some(i=>!["kind","undo","debug"].includes(i)))throw d("--undo takes no other flag.","Try: forge clip --undo");if(e.quality!==void 0&&e.maxBytes!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");return e}function we(s){let e=s.slice(1),t=[],n={kind:"transcribe",input:"",notes:!0,transcript:!0,detail:Q,force:!1,debug:!1},i=(l,c)=>{let a=e[c+1];if(a===void 0||a.startsWith("-"))throw d(`${l} needs a value.`);return a},r="Try: forge transcribe talk.mp4";for(let l=0;l<e.length;l++){let c=e[l];if(c==="--debug")n.debug=!0;else if(c==="--force"||c==="-f")n.force=!0;else if(c==="--language"||c==="-l")n.language=i(c,l++);else if(c==="--output"||c==="-o")n.output=i(c,l++);else if(c==="--detail"){let a=i(c,l++).toLowerCase();if(!X.includes(a))throw d(`forge transcribe writes notes in brief, standard or detailed, not ${a}.`,"Try: forge transcribe talk.mp4 --detail brief");n.detail=a}else if(c==="--format"){let a=i(c,l++).toLowerCase(),h=Y.find(p=>p.id===a||p.label.toLowerCase()===a);if(h===void 0)throw d(`forge transcribe writes md, docx, pdf or txt, not ${a}.`,"Try: forge transcribe talk.mp4 --format pdf");n.format=h.id}else if(c==="--to"||c==="-t"){let a=i(c,l++).toLowerCase();if(a!=="all"&&a!=="notes"&&a!=="transcript")throw d(`forge transcribe makes all, notes or a transcript, not ${a}.`,"Try: forge transcribe talk.mp4 --to transcript");n.to=a,n.notes=a!=="transcript",n.transcript=a!=="notes"}else{if(c.startsWith("-"))throw d(`forge transcribe does not take ${c}.`,r);t.push(c)}}let[o,...u]=t;if(o===void 0)throw d("forge transcribe needs a file or a link.",r);if(u.length>0)throw d("forge transcribe takes one file or link at a time.",r);return{...n,input:o}}function ye(s){let e=s.slice(1),t=[],n,i={kind:"watch",newOnly:!1,debug:!1},r={},o=(c,a)=>{let h=e[a+1];if(h===void 0||h.startsWith("-"))throw d(`${c} needs a value.`);return h};for(let c=0;c<e.length;c++){let a=e[c];if(a!=="--json")if(a==="--debug")i.debug=!0;else if(a==="--new-only")i.newOnly=!0;else if(a==="--to"||a==="-t")n=I(o(a,c++));else if(a==="--quality"||a==="-q")r.quality=S(o(a,c++));else if(a==="--output"||a==="-o")r.output=o(a,c++);else if(a==="--dpi"){let h=o(a,c++),p=Number(h);if(!Number.isInteger(p)||p<36||p>600)throw H(h);r.dpi=p}else{if(a.startsWith("-"))throw d(`forge watch does not take ${a}.`,"Try: forge watch ./images --to webp");t.push(a)}}let[u,...l]=t;if(u===void 0)throw d("forge watch needs a folder.","Try: forge watch ./images --to webp");if(l.length>0)throw d("forge watch watches one folder at a time.",`Try: forge watch ${u} --to webp`);if(n===void 0)throw d("forge watch needs a format to convert to.",`Try: forge watch ${u} --to webp`);return{kind:"watch",folder:u,target:n,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:r.dpi},...r.output===void 0?{}:{output:r.output},newOnly:i.newOnly,debug:i.debug}}function xe(s){let e=s.slice(1).filter(o=>o!=="--json"),t=e.find(o=>o.startsWith("-"));if(t!==void 0)throw d(`forge extensions does not take ${t}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");let[n,i,...r]=e;if(n===void 0)return{kind:"extensions",action:"list"};if(n!=="add"&&n!=="remove")throw d(`Unknown extensions action ${n}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");if(i===void 0||r.length>0)throw d(`forge extensions ${n} takes exactly one extension.`,`Try: forge extensions ${n} boost`);return{kind:"extensions",action:n,id:i}}function re(s){if(s===void 0)throw d("No colour given.","Try: forge scale 6579FD \u2014 or quote it, '#6579FD', because an unquoted # starts a comment in the shell.");let e=M(s)?.rgb;if(!e)throw d(`${s} is not a colour.`,"Try a hex code (6579FD), rgb(), hsl(), oklch() or a colour name, quoted: 'rgb(101 121 253)'.");return e}function Oe(s,e=process.platform,t=process.env){let r=e==="linux"&&!t.WAYLAND_DISPLAY&&!!t.DISPLAY?" --svg a card of swatches; pipe to xclip -sel c, paste into Figma":` --svg a card of swatches; pipe to ${e==="win32"?"clip":e==="linux"?"wl-copy":"pbcopy"} and paste into Figma`;return s==="card"?`Usage: forge card <file> [--json] [--svg] [--title <text>]
|
|
53
|
-
|
|
54
|
-
Named colours from design tokens, a CSV, CSS variables or one a line
|
|
55
|
-
(bg #F8F1E6). - reads them from stdin.
|
|
56
|
-
--json one JSON document: card.colours[] with name and hex
|
|
57
|
-
${r}
|
|
58
|
-
--title <text> the card's heading; the file's name if not given
|
|
59
|
-
`:s==="scale"?`Usage: forge scale <colour> [--json] [--svg]
|
|
60
|
-
|
|
61
|
-
50\u2013950 built in OKLCH, with <colour> at 500. Pass the hex without #, or quote it.
|
|
62
|
-
--json one JSON document: scale.steps[] with hex, oklch, white, black
|
|
63
|
-
${r}
|
|
64
|
-
`:`Usage: forge palette <image> [--json] [--svg] [--inside <hex>]
|
|
65
|
-
|
|
66
|
-
An image's main colours, most of the image first.
|
|
67
|
-
--json one JSON document: palette.colours[] with hex, rgb, oklch, share
|
|
68
|
-
${r}
|
|
69
|
-
--inside <hex> the shades of the palette colour nearest <hex>
|
|
70
|
-
`}function Ce(s){let[e,...t]=s;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(Oe(e==="scale"?"scale":e==="card"?"card":"palette")),new O(0,"commander.helpDisplayed","(outputHelp)");if(e==="card")return ve(t);let n=t.filter(l=>l!=="--json"&&l!=="--svg"),i=t.includes("--svg"),r=n.indexOf("--inside"),o=r===-1?void 0:n[r+1];r!==-1&&n.splice(r,2);let u=n.find(l=>l.startsWith("-"));if(u!==void 0)throw d(`forge ${e} does not take ${u}.`,`Try: forge ${e} --help`);if(e==="scale"){if(r!==-1)throw d("--inside is for forge palette.","Try: forge palette photo.jpg --inside F26E69");if(n.length>1)throw d("forge scale takes one colour.","Try: forge scale 6579FD");return{kind:"scale",colour:re(n[0]),svg:i}}if(n.length!==1)throw d(n.length===0?"No image given.":"forge palette takes one image.","Try: forge palette photo.jpg");return{kind:"palette",input:n[0],svg:i,...r===-1?{}:{inside:re(o)}}}function ve(s){let e=s.filter(o=>o!=="--json"&&o!=="--svg"),t=s.includes("--svg"),n=e.indexOf("--title"),i=n===-1?void 0:e[n+1];if(n!==-1){if(i===void 0||i.trim()==="")throw d("--title needs the heading.","Try: forge card palette.csv --title 'Cream blue'");e.splice(n,2)}let r=e.find(o=>o.startsWith("-")&&o!=="-");if(r!==void 0)throw d(`forge card does not take ${r}.`,"Try: forge card --help");if(e.length!==1)throw d(e.length===0?"No file given.":"forge card takes one file.","Try: forge card palette.csv --svg");return{kind:"card",input:e[0],svg:t,...i===void 0?{}:{title:i}}}function mt(s){let e=s.indexOf("--");return(e===-1?s:s.slice(0,e)).includes("--json")}function ke(s){let e=s.indexOf("--"),t=e===-1?s:s.slice(0,e),n=e===-1?[]:s.slice(e),i=[],r;for(let o=0;o<t.length;o++){let u=t[o],l=u.startsWith("--boost=")?u.slice(8):void 0;if(u!=="--boost"&&l===void 0){i.push(u);continue}let c=l;if(c===void 0&&/^\d+$/.test(t[o+1]??"")&&(c=t[++o]),c!==void 0&&c!=="2"&&c!=="3"&&c!=="4")throw d(`--boost takes 2, 3 or 4, not ${c}.`,"Try --boost, --boost 2, --boost 3 or --boost 4.");r=c==="4"?4:c==="3"?3:2}return{rest:[...i,...n],...r===void 0?{}:{scale:r}}}function gt(s){let e=s;if(e[0]==="clip"||e[0]==="watch"||e[0]==="transcribe"||e[0]==="config"||e[0]==="probe"||e[0]==="extensions"||e[0]==="palette"||e[0]==="scale"||e[0]==="card"||e[0]==="update"||e[0]==="uninstall")return Ae(e);let t=ke(e);return $e(t.rest,t.scale)}function Ae(s){if(s[0]==="update"){let e=s.slice(1).filter(t=>t!=="--json");if(e.length>0)throw d(`forge update takes nothing else, got: ${e.join(" ")}.`,"Try: forge update");return{kind:"update"}}if(s[0]==="uninstall"){let e=s.slice(1);if(e.length>0)throw d(`forge uninstall takes nothing else, got: ${e.join(" ")}.`,"Try: forge uninstall");return{kind:"uninstall"}}return s[0]==="clip"?_e(s):s[0]==="watch"?ye(s):s[0]==="transcribe"?we(s):s[0]==="config"?he(s.filter(e=>e!=="--json")):s[0]==="probe"?be(s):s[0]==="palette"||s[0]==="scale"||s[0]==="card"?Ce(s):xe(s)}function $e(s,e){let t=new $().name("forge").description("Convert \u2014 transform your files from the terminal").argument("[inputs...]","files, folders or globs").option("-t, --to <format>","target format").option("-o, --output <path>","output file or directory").option("-q, --quality <n>","quality for lossy formats, 1-100").option("--background <colour>","fill colour when flattening transparency","#ffffff").option("--keep-metadata","preserve EXIF and GPS data",!1).option("--recursive","descend into subfolders",!1).option("--force","allow overwriting existing files",!1).option("--max-size <size>","compress until the file fits, e.g. 500kb").option("--concurrency <n>","how many files to convert at once").option("--debug","show underlying errors",!1).option("--formats","list supported formats",!1).option("--merge","combine several PDFs into one").option("--split <mode>","every-page | every=N | at=N,N").option("--extract <pages>","keep only these pages, e.g. 3-7,12").option("--delete <pages>","drop these pages").option("--rotate <degrees>","90, 180 or 270").option("--separate","with --extract, write one file per page").option("--sharpen","sharpen at the same size; needs the boost extension").option("--boost [2|3|4]","sharpen and enlarge 2x (default), 3x or 4x; needs the boost extension").option("--trim","cut transparent or solid-colour edges; keeps the format").option("--crop <W:H>","cut to a shape, e.g. 1:1, 4:5, 16:9; keeps the subject").option("--resize <percent>","resize to a percent of the size, 1-200, e.g. 50%").option("--width <px>","resize to this width; the height follows").option("--height <px>","resize to this height; the width follows").option("--remove-bg","cut out the subject; needs the remove-background extension").option("--cut <start-end>","video or audio: keep from start to end, e.g. 0:03.2-0:41").option("--mute","video: take the sound out").option("--speed <x>","video or audio: play faster or slower, 0.25-4").option("--fps <n>","video: frames per second").option("--bitrate <kbps>","audio: bitrate, e.g. 128k").option("--loudness <LUFS>","audio: even out loudness to this level, e.g. -16").option("--clean-audio","video or audio: take out rumble and hiss, then even the level").option("--preset <name>","run a preset saved from Done, e.g. --preset blog").option("--pages <ranges>","with --to, which pages to render, e.g. 3-7,12").option("--dpi <n>","rasterisation resolution, 36-600","150").option("--password-stdin","read an encrypted PDF's password from stdin").option("--json","print one JSON document on stdout instead of text").helpOption("-h, --help","show this help").version(K,"-V, --version","show the version").addHelpText("after",`${ge()}
|
|
71
|
-
${me}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(s,{from:"user"})}catch(f){if(f instanceof O&&f.code!=="commander.helpDisplayed"&&f.code!=="commander.version"){let[g="",...b]=f.message.replace(/^error: /,"").split(`
|
|
72
|
-
`),w=b.join(" ").trim().replace(/^\((.*)\)\.?$/,"$1");throw d(`${g.charAt(0).toUpperCase()}${g.slice(1).replace(/\.$/,"")}.`,w||"Run forge --help to see what Forge accepts.")}throw f}let n=t.opts(),i=t.args;if(n.formats)return{kind:"formats"};let r=pe(n);if(r!==void 0&&n.trim)throw d("--trim cuts the empty edges of an image.","To keep part of a video or audio file, use --cut, for example --cut 0:03-0:41.");if(n.preset!==void 0){let f=[["to","--to"],["quality","--quality"],["maxSize","--max-size"],["merge","--merge"],["split","--split"],["extract","--extract"],["delete","--delete"],["rotate","--rotate"],["sharpen","--sharpen"],["trim","--trim"],["crop","--crop"],["resize","--resize"],["width","--width"],["height","--height"],["removeBg","--remove-bg"],["pages","--pages"]].filter(([g])=>n[g]!==void 0&&n[g]!==!1).map(([,g])=>g);if(e!==void 0&&f.push("--boost"),f.length>0)throw d(`--preset already says what to do \u2014 leave out ${f.join(" and ")}.`,"Run the preset alone, or change it from Done with \u2192 continue editing.");return{kind:"preset",inputs:i,name:String(n.preset),...n.output===void 0?{}:{output:String(n.output)},force:n.force===!0,recursive:n.recursive===!0,debug:n.debug===!0}}if(n.pages!==void 0&&n.to===void 0)throw d("--pages needs --to: it chooses which pages to render.");let o=["merge","split","extract","delete","rotate"].filter(f=>n[f]!==void 0);if(o.length>1)throw d(`Use one operation at a time \u2014 got ${o.map(f=>`--${f}`).join(" and ")}.`);let u=[...n.sharpen?["--sharpen"]:[],...e!==void 0?["--boost"]:[],...n.removeBg?["--remove-bg"]:[]],l=[...n.resize!==void 0?["--resize"]:[],...n.width!==void 0?["--width"]:[],...n.height!==void 0?["--height"]:[]],c=r!==void 0&&!n.to&&n.quality===void 0&&n.maxSize===void 0;if(n.trim||n.crop!==void 0||l.length>0||c){if(l.length>1)throw d(`Use one of --resize, --width and --height \u2014 got ${l.join(" and ")}.`);let f=n.crop!==void 0?"--crop":l[0]??(n.trim?"--trim":"--cut"),g=[...n.crop!==void 0&&n.trim?["--trim"]:[],...u,...n.maxSize!==void 0?["--max-size"]:[],...n.pages!==void 0?["--pages"]:[],...o.map(oe=>`--${oe}`)][0];if(g!==void 0)throw d(`${f} cannot be combined with ${g}.`,g!=="--max-size"?"Run them one after the other.":f==="--crop"?"Crop first, then compress the result: forge photo-cropped-1x1.jpg --max-size 500kb":"Resize first, then compress the result: forge photo-1200x900.jpg --max-size 500kb");let b=n.crop!==void 0?{aspect:R(String(n.crop))}:void 0,w=n.resize!==void 0?{percent:fe(n.resize)}:n.width!==void 0?{width:ne("--width",n.width)}:n.height!==void 0?{height:ne("--height",n.height)}:void 0;if(i.length===0)throw d("No files given.","Name an image, for example: forge photo.jpg --resize 50%");let v={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(v.quality=S(String(n.quality)));let y={kind:"edit",inputs:i,trim:!!n.trim,options:v,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return b!==void 0&&(y.crop=b),w!==void 0&&(y.resize=w),r!==void 0&&(y.media=r),n.to&&(y.target=I(String(n.to))),n.output!==void 0&&(y.output=String(n.output)),n.concurrency!==void 0&&(y.concurrency=j(String(n.concurrency))),y}let a=n.sharpen?1:e,h=a!==void 0?"boost":n.removeBg?"remove-background":null;if(h!==null){if(u.length>1)throw d(`Use one operation at a time \u2014 got ${u.join(" and ")}.`);let f=u[0];if(o.length>0)throw d(`${f} cannot be combined with --${o[0]}.`);if(n.maxSize!==void 0||n.pages!==void 0)throw d(`${f} cannot be combined with ${n.maxSize!==void 0?"--max-size":"--pages"}.`);if(i.length===0)throw d("No files given.",`Name an image, for example: forge photo.jpg ${f}`);let g=n.to?I(String(n.to)):"png";if(h==="remove-background"){let v=U(g);if(v)throw v}let b={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(b.quality=S(String(n.quality)));let w={kind:"extension-op",op:h,inputs:i,target:g,options:b,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return a!==void 0&&(w.scale=a),n.output!==void 0&&(w.output=String(n.output)),n.concurrency!==void 0&&(w.concurrency=j(String(n.concurrency))),w}if(o.length===1){let f=o[0];if(i.length===0)throw d("No files given.",`Name a PDF, for example: forge doc.pdf --${f}`);if(n.separate&&f!=="extract")throw d(`--separate only applies to --extract, not --${f}.`);if(n.output!==void 0)throw d(`--output does not apply to --${f}.`,"Page operations name their own outputs, beside the source. Rename the result afterwards.");let g={kind:"pageop",action:f,inputs:i,force:!!n.force,debug:!!n.debug};if(f==="rotate"){let b=Number(n.rotate);if(!Number.isInteger(b)||b%90!==0||b===0||b>=360)throw d(`--rotate takes a multiple of 90 below 360, not "${n.rotate}".`);g.rotate=b}if((f==="extract"||f==="delete")&&(g.pages=String(n[f]),f==="extract"&&n.separate&&(g.separate=!0)),f==="split"){let b=String(n.split),w=b.match(/^every=(\d+)$/),v=b.match(/^at=([\d,\s]+)$/);if(b==="every-page")g.split={mode:"every-page"};else if(w?.[1]!==void 0){let y=Number(w[1]);if(!Number.isInteger(y)||y<1)throw d(`--split every=N takes a whole number of pages, at least 1, not "${w[1]}".`);g.split={mode:"every-n",n:y}}else if(v?.[1])g.split={mode:"points",after:v[1].split(",").map(y=>Number(y.trim()))};else throw d(`--split takes every-page, every=N or at=N,N \u2014 not "${b}".`)}return g}if(i.length===0&&!n.to&&n.quality===void 0&&n.maxSize===void 0)return{kind:"shell"};if(n.quality!==void 0&&n.maxSize!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");if(!n.to&&(n.quality!==void 0||n.maxSize!==void 0)){if(i.length===0)throw d("No files given.","Name a file, for example: forge photo.jpg --max-size 500kb");let f={background:String(n.background),keepMetadata:!!n.keepMetadata};r!==void 0&&(f.media=r);let g={kind:"compress",inputs:i,options:f,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};if(n.quality!==void 0&&(g.quality=S(String(n.quality))),n.maxSize!==void 0&&(g.maxBytes=B(n.maxSize)),n.output!==void 0&&(g.output=String(n.output)),t.getOptionValueSource("dpi")==="cli"){let b=Number(n.dpi);if(!Number.isInteger(b)||b<36||b>600)throw H(n.dpi);g.dpi=b}return n.concurrency!==void 0&&(g.concurrency=j(String(n.concurrency))),g}if(!n.to)throw d("No target format given.","Add --to <format>, for example: forge photo.jpg --to webp");if(i.length===0)throw d("No files given.","Name a file, a folder or a glob, for example: forge photo.jpg --to webp");let p={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(p.quality=S(String(n.quality))),r!==void 0&&(p.media=r);let x=Number(n.dpi);if(!Number.isInteger(x)||x<36||x>600)throw H(n.dpi);let _={kind:"convert",inputs:i,target:I(String(n.to)),options:p,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug,dpi:x,passwordStdin:!!n.passwordStdin};return n.output!==void 0&&(_.output=String(n.output)),n.pages!==void 0&&(_.pages=String(n.pages)),n.maxSize!==void 0&&(_.maxBytes=B(n.maxSize)),n.concurrency!==void 0&&(_.concurrency=j(String(n.concurrency))),_}export{me as a,ie as b,ge as c,Oe as d,mt as e,gt as f};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
var x=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),b=/^[A-Za-z0-9_-]{11}$/,c=n=>n&&b.test(n)?{kind:"video",id:n,url:`https://www.youtube.com/watch?v=${n}`}:void 0;function E(n){let r=n.trim();if(r==="")return;let t;try{t=new URL(/^[a-z]+:\/\//i.test(r)?r:`https://${r}`)}catch{return}let e=t.hostname.toLowerCase();if(e==="youtu.be")return c(t.pathname.slice(1).split("/")[0]);if(!x.has(e))return;let[s,o]=t.pathname.split("/").filter(Boolean);if(s==="watch")return c(t.searchParams.get("v"));if(s==="shorts"||s==="live")return c(o);if(s==="playlist"&&t.searchParams.get("list"))return{kind:"playlist"}}var w="Summary and notes by Apple Intelligence. They may contain mistakes.";function g(n){let r=Math.floor(n),t=o=>String(o).padStart(2,"0"),e=Math.floor(r/3600),s=Math.floor(r/60)%60;return e>0?`${e}:${t(s)}:${t(r%60)}`:`${s}:${t(r%60)}`}var f=n=>n.split(/\s+/).filter(Boolean).length,$=60,S=140,y=1,k=10;function I(n){let r=[],t;for(let e of n){if(t){let s=e.start-t.end;if(!(s>k||s>y&&t.words>=$||t.words>=S)){t.text+=` ${e.text}`,t.end=e.end,t.words+=f(e.text);continue}r.push({start:t.start,text:t.text})}t={start:e.start,end:e.end,text:e.text,words:f(e.text)}}return t&&r.push({start:t.start,text:t.text}),r}var l=n=>I(n).flatMap(r=>[`**${g(r.start)}** ${r.text}`,""]),L=n=>/^https?:\/\/\S+$/.test(n)?`<${n}>`:n;function P(n,r,{transcript:t=!0}={}){let e=[`# ${r.title}`,"",L(r.from),""],s=n.notes;if(!s)return[...e,...l(n.segments)].join(`
|
|
4
|
-
`);let o=s.parts,p=a=>{let i=o[a];return i?`### ${i.refused?`Part ${a+1}`:i.heading} \xB7 ${g(i.start)}`:""};e.push(s.summary,"","## Notes",""),o.forEach((a,i)=>{e.push(p(i),""),a.points.length>0&&e.push(...a.points.map(u=>`- ${u}`),"")});let d=[`_${w}_`,""];return t?(e.push("## Transcript",""),o.forEach((a,i)=>{let u=o[i+1]?.start??Number.POSITIVE_INFINITY,h=n.segments.filter(m=>m.start>=a.start&&m.start<u);e.push(p(i),"",...l(h))}),[...e,...d].join(`
|
|
5
|
-
`)):[...e,...d].join(`
|
|
6
|
-
`)}function M(n){let r=[...n].map(t=>(t.codePointAt(0)??0)<32?" ":t).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return r===""?"transcript":r}export{E as a,g as b,P as c,M as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as w,b as I,d as k,e as m}from"./chunk-W53XNVNH.js";import{a as $,c as O}from"./chunk-SM735FG7.js";import{b as h,d as P,e as R}from"./chunk-T4CLHCLJ.js";import{f as x}from"./chunk-YJ6XLDRA.js";import{a as l}from"./chunk-4OSMYHKQ.js";import{j as B}from"./chunk-RQWWUCGQ.js";import{$ as C,_ as g,ba as v}from"./chunk-ZBMJTIYR.js";import{a as f}from"./chunk-J7FLFHQJ.js";import{b as p}from"./chunk-VLVNA4T3.js";import{a as c}from"./chunk-H3DIRJFE.js";import{dirname as S,join as q}from"node:path";async function T(t){if(t.fallback!==void 0)return t.fallback;let{loadPreferences:r,expandTilde:e}=await import("./preferences-3P4V2EDX.js");return e((await r()).prefs.defaultOutput)}function F(t){if(t.pasteboard)return t.pasteboard;if(!$())throw C();return O()}function E(t,r,e,o){let a=q(r.outDir,`Copied image${c[o].extensions[0]}`),s={inputs:[r.source],output:a,force:!1,recursive:!1,debug:t.debug},n={background:"#ffffff",keepMetadata:!1,...t.quality===void 0?{}:{quality:t.quality}};return o===e?{kind:"compress",...s,options:n,...t.quality===void 0?{}:{quality:t.quality},...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}:{kind:"convert",...s,target:o,options:n,...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}}async function J(t,r={}){let e=r.clip??{},o=F(e),a=await w(o,e.root);if(!a)throw g((await o.peek()).text?"text":"nothing");let s=await B(a.source),n=t.target??s.format,b=E(t,a,s.format,n),i=await P(b,r),y=i.results[0];if(!y||i.failures.length>0)return{report:i,status:"failed"};let u=y.job.outputs[0],d={report:i,output:u,source:{format:s.format,bytes:s.bytes},target:n};if(await I(o,a,u,n)==="changed")return{...d,status:"changed",saved:await m(u,await T(e))};if(t.save===void 0)return{...d,status:"placed"};let j=t.save===!0?await T(e):t.save,{expandTilde:D}=await import("./preferences-3P4V2EDX.js");return{...d,status:"placed",saved:await m(u,D(j))}}function N(t){let r=t.target===t.source.format?"":` as ${c[t.target].label}`,e=` ${f(t.source.bytes)} \u2192 ${f(t.report.outputBytes)} \xB7 ${h(t.source.bytes,t.report.outputBytes)}`;if(t.status==="changed"){let a=t.target===t.source.format?"compressed":"converted";return[`\u2713 Copied image \u2192 ${p(t.saved)}${r}`,e,"","\u26A0 Clipboard changed"," The file you uploaded is no longer in the clipboard.",` The ${a} image is saved to ${p(S(t.saved))}.`]}let o=t.saved===void 0?"":` + ${p(t.saved)}`;return[`\u2713 Copied image \u2192 clipboard${r}${o}`,e]}async function U(t){if(!await k(F(t),t.root))throw v()}async function Z(t,r){if(t.undo)return await U(r.clip??{}),{exitCode:0,stdout:r.json?[JSON.stringify({forge:l,ok:!0,clipboard:"restored"})]:["\u2713 The original is back on the clipboard"],stderr:[]};let e=await J(t,r);if(e.status==="failed")return R(e.report,r);if(r.json){let o={...x(l,e.report),clipboard:e.status,...e.saved===void 0?{}:{saved:e.saved}};return{exitCode:0,stdout:[JSON.stringify(o)],stderr:[]}}return{exitCode:0,stdout:N(e),stderr:[]}}export{J as a,N as b,U as c,Z as d};
|
|
@@ -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-J7FLFHQJ.js";import{c as r}from"./chunk-VLVNA4T3.js";import{a}from"./chunk-H3DIRJFE.js";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 m(e){return e instanceof o}function v(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 k(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 C(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 S(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 T(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 N(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 I(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 P(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 H(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 O(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function R(e){return new o({code:"unsupported-source",title:"No colours",detail:`There are no colours in ${e} that Forge can read.`,hint:"Write one a line, a name and a colour (bg #F8F1E6), or use a CSV with name and hex columns, CSS variables or design tokens."})}function A(e,t){let n=t.slice(0,8).join("; "),i=t.length>8?`; and ${t.length-8} more`:"";return new o({code:"unsupported-source",title:"Not colours",detail:`${t.length===1?"One line":`${t.length} lines`} of ${e} could not be read as a colour: ${n}${i}.`,hint:"Write each as a name and a colour, such as bg #F8F1E6, or take the line out."})}function W(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 U(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 D(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 M(e,t){let n=r(e.path);if(t!==void 0&&t!==e.format){let i=a[t].label;return a[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 ${a[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 ${a[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 J(e){let t=r(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${a[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function j(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 ${s(n)}, which is still over ${s(t)}.`:`${r(e.path)} is ${s(n)} even at the lowest quality, which is still over ${s(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 L(e,t,n){return new o({code:"unsupported-target",title:`Can't convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is a ${a[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${n.join(", ")}`})}function q(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 V(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${a[t].label}`,detail:`${r(e)} is a ${a[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 Y(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 c=e=>e==="convert"||e==="boost"||e==="remove-background";function _(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:c(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 X(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 B(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 G(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:c(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:c(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function w(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 b=new Set(["EACCES","EPERM","EROFS"]);function K(e,t){if(m(t))return t;let n=t?.code;return n!==void 0&&b.has(n)?w(e,t):t}function Q(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 Z(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 ee(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function te(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 oe(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function ne(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 re(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 ie(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 ae(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 se(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 le(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 de(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 ue(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 ce(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 pe(){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 he(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 ge(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 fe(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 me(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 we(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 be(e,t,n,i=process.platform){let l=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 ${l}`,detail:`${r(e)} would take about ${u} ${u===1?"minute":"minutes"} to ${l} on this ${d}.`,hint:"Try a smaller photo."})}function xe(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 x={darwin:"\u2303\u21E7\u23184",win32:"Win+Shift+S"};function $e(e,t=process.platform){let n=x[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 Fe(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 ye(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 Ee(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function ve(e,t,n,i=!1){let l=r(e);if(i)return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} is no smaller even at the lowest quality, so nothing was written.`,short:"nothing written"});let d=n>t?`would grow from ${s(t)} to ${s(n)}`:`would stay at ${s(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} ${d}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function ke(e,t,n){return new o({code:"cannot-compress-more",title:"Already small enough",detail:`${r(e)} is ${s(t)}, already under ${s(n)}, so nothing was written.`,short:"already under that size"})}function Ce(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function Se(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function Te(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Ne(e){return new o({code:"animated-crop",title:"Can't crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function Ie(e){return new o({code:"animated-rotate",title:"Can't rotate an animation",detail:`${r(e)} is animated; rotating works on still images.`})}function Pe(e,t=process.platform,n=!1){let i=p(t),l=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 ${l}, then run Forge again.`})}function He(e,t,n=process.platform){let i=a[e].label,l=/^[AEFHILMNORSX]/.test(t.codec)?"an":"a",d=t.encoders,u=d.length>1?`${d.slice(0,-1).join(", ")} or ${d.at(-1)}`:d[0]??"",h=d.length>1?"any of them":"it",g=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 (${p(n)}), then run Forge again.`:`Install a full build of ffmpeg (${p(n)}), then run Forge again.`;return new o({code:"encoder-missing",title:`Your ffmpeg can't write ${i}`,detail:`${i} needs ${l} ${t.codec} encoder${t.sound?" for its sound":""}: ${u}. Your ffmpeg was built without ${h}.`,short:`Your ffmpeg has no ${t.codec} encoder`,hint:g})}function p(e=process.platform){return e==="win32"?"winget install ffmpeg":e==="linux"?"sudo apt install ffmpeg":"brew install ffmpeg"}function Oe(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 Re(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function Ae(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 We(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 Ue(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function De(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function Me(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 Je(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 je(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{m as a,v as b,k as c,C as d,S as e,T as f,N as g,I as h,P as i,H as j,O as k,R as l,A as m,W as n,U as o,D as p,M as q,J as r,j as s,z as t,L as u,q as v,V as w,Y as x,_ as y,X as z,B as A,G as B,w as C,K as D,Q as E,Z as F,ee as G,te as H,oe as I,ne as J,re as K,ie as L,ae as M,se as N,le as O,de as P,ue as Q,ce as R,pe as S,he as T,ge as U,fe as V,me as W,we as X,be as Y,xe as Z,$e as _,Fe as $,ye as aa,Ee as ba,ve as ca,ke as da,Ce as ea,Se as fa,Te as ga,Ne as ha,Ie as ia,Pe as ja,He as ka,p as la,Oe as ma,Re as na,Ae as oa,We as pa,Ue as qa,De as ra,Me as sa,Je as ta,je as ua,ze as va};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as h}from"./chunk-6RMRWBMB.js";import{execFile as P}from"node:child_process";import{accessSync as U,constants as _}from"node:fs";import{isAbsolute as M,join as a}from"node:path";var D=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function x(e,t){if(typeof e=="string")return`${t}<string>${D(e)}</string>`;if(typeof e=="number")return`${t}<integer>${e}</integer>`;if(typeof e=="boolean")return`${t}<${e}/>`;if(Array.isArray(e))return`${t}<array>
|
|
4
|
-
${e.map(i=>x(i,`${t} `)).join(`
|
|
5
|
-
`)}
|
|
6
|
-
${t}</array>`;let n=Object.entries(e).map(([i,o])=>`${t} <key>${D(i)}</key>
|
|
7
|
-
${x(o,`${t} `)}`);return n.length===0?`${t}<dict/>`:`${t}<dict>
|
|
8
|
-
${n.join(`
|
|
9
|
-
`)}
|
|
10
|
-
${t}</dict>`}var N=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
|
-
${x(e,"")}
|
|
14
|
-
</plist>
|
|
15
|
-
`,v={image:"public.image",folder:"public.folder",pdf:"com.adobe.pdf",video:"public.movie",audio:"public.audio"};function w(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 u=e=>`'${e.replace(/'/g,"'\\''")}'`,E="forge",A=e=>e.preset===void 0?`com.forge-terminal.menu.${e.action}`:`com.forge-terminal.menu.preset.${e.preset}`,G="com.forge-terminal.menu.",I="runWorkflowAsService",Q=e=>`${A(e)} - ${e.label} - ${I}`,k=`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 z(e){return[e.osascript??"/usr/bin/osascript",["-l","JavaScript","-e",k,e.domain??"pbs",...e.on.map(t=>`+${t}`),...e.off.map(t=>`-${t}`)]]}function Z(e,t){let n=N({CFBundleDevelopmentRegion:"English",CFBundleIdentifier:A(e),CFBundleInfoDictionaryVersion:"6.0",CFBundleName:e.label,CFBundlePackageType:"BNDL",CFBundleShortVersionString:"1.0",CFBundleVersion:"1",NSServices:[{NSIconName:E,NSMenuItem:{default:e.label},NSMessage:I,NSRequiredContext:{NSApplicationIdentifier:"com.apple.finder"},NSSendFileTypes:e.kinds.map(c=>v[c])}]}),i=e.preset===void 0?"":` ${u(e.preset)}`,o=`${u(t)} ${e.action}${i} "$@"`,r=N({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:o,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:w(e.kinds),serviceOutputTypeIdentifier:"com.apple.Automator.nothing",serviceProcessesInput:!1,workflowTypeIdentifier:"com.apple.Automator.servicesMenu"}});return{name:`${e.label}.workflow`,files:{"Contents/Info.plist":n,"Contents/document.wflow":r,"Contents/Resources/document.wflow":r}}}var d="forge-terminal-menu";function oe(e){let t=i=>i&&M(i)?i:void 0,n=(e.xdgConfigDirs??"").split(":").filter(i=>M(i));return{dataHome:t(e.xdgDataHome)??a(e.home,".local","share"),configHome:t(e.xdgConfigHome)??a(e.home,".config"),configDirs:n.length>0?n:["/etc/xdg"]}}function S(e,t=process.env.PATH){for(let n of(t??"").split(":"))if(n!=="")try{return U(a(n,e),_.X_OK),!0}catch{}return!1}var F={image:"image/*",folder:"inode/directory",pdf:"application/pdf",video:"video/*",audio:"audio/*"},L=e=>e.map(t=>`${F[t]};`).join(""),b=e=>`${e.paint}.png`,re=e=>a(e.dataHome,"nautilus","scripts","Forge"),f=e=>e.preset===void 0?e.action:`preset-${e.preset}`,g=e=>e.preset===void 0?e.action:`preset ${e.preset}`,se=e=>e.label;function ae(e,t){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 ${u(t)} ${g(e)} "$@"
|
|
39
|
-
`}var ce=e=>a(e.dataHome,"nemo","actions"),ue=(e,t)=>`forge-${e.preset===void 0?t.indexOf(e.action)+1:t.length+1}-${f(e)}.nemo_action`,m=e=>e.replace(/%/g,"%%");function pe(e,t){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(u(t))} ${g(e)} %F
|
|
44
|
-
Selection=notnone
|
|
45
|
-
Mimetypes=${L(e.kinds)}
|
|
46
|
-
`}var le=e=>a(e.dataHome,"kio","servicemenus"),me=e=>`forge-${e}.desktop`,de=["image","folder","pdf","video","audio"],O=e=>m(`"${e.replace(/[\\"`$]/g,"\\$&")}"`).replace(/\\/g,"\\\\");function fe(e,t,n){let i=t.filter(s=>s.kinds.includes(e));if(i.length===0)return;let o=i.length>1,r=["[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=${F[e]};`,`Actions=${i.map(s=>`${f(s)};`).join("")}`,"X-KDE-Priority=TopLevel",...o?["X-KDE-Submenu=Forge",`Icon=${a(n.menuDir,"forge.png")}`]:[]],c=i.map(s=>["",`[Desktop Action ${f(s)}]`,`Name=${s.label}`,`Icon=${a(n.menuDir,b(s))}`,`Exec=${O(n.launcher)} ${g(s)} %F`].join(`
|
|
47
|
-
`));return`${[...r,...c].join(`
|
|
48
|
-
`)}
|
|
49
|
-
`}var ge=e=>a(e.configHome,"Thunar","uca.xml"),$e=e=>e.configDirs.map(t=>a(t,"Thunar","uca.xml")),xe=`<?xml version="1.0" encoding="UTF-8"?>
|
|
50
|
-
<actions>
|
|
51
|
-
</actions>
|
|
52
|
-
`,y=e=>`${d}-${f(e)}`,l=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),j={image:{patterns:["*"],type:"image-files"},folder:{patterns:["*"],type:"directories"},pdf:{patterns:["*.pdf","*.PDF"],type:"other-files"},video:{patterns:["*"],type:"video-files"},audio:{patterns:["*"],type:"audio-files"}};function ye(e,t){return e.flatMap(n=>{let i=n.kinds.filter(r=>r==="pdf"),o=n.kinds.filter(r=>r!=="pdf");return[...o.length>0?[{item:n,kinds:o,id:y(n)}]:[],...i.length>0?[{item:n,kinds:i,id:o.length>0?`${y(n)}-pdf`:y(n)}]:[]]}).map(({item:n,kinds:i,id:o})=>{let r=i.map(p=>j[p]),c=[...new Set(r.flatMap(p=>p.patterns))],s=c.includes("*")?["*"]:c;return["<action>",` <icon>${l(a(t.menuDir,b(n)))}</icon>`,` <name>${l(n.label)}</name>`,` <submenu>${i.includes("pdf")?"":"Forge"}</submenu>`,` <unique-id>${o}</unique-id>`,` <command>${l(m(u(t.launcher)))} ${g(n)} %F</command>`,` <description>${l(n.label)}</description>`," <range></range>",` <patterns>${l(s.join(";"))}</patterns>`,...r.map(p=>` <${p.type}/>`),"</action>"].join(`
|
|
53
|
-
`)}).map(n=>`${n}
|
|
54
|
-
`).join("")}var R=/[ \t]*<action>[\s\S]*?<\/action>[ \t]*\r?\n?/g;function B(e){return e.replace(R,t=>t.includes(`<unique-id>${d}-`)?"":t)}function Se(e,t){let n=B(e),i=n.lastIndexOf("</actions>");if(i===-1||!/<actions>/.test(n))return;let o=n.lastIndexOf(`
|
|
55
|
-
`,i)+1;return/^[ \t]*$/.test(n.slice(o,i))&&(i=o),`${n.slice(0,i)}${t}${n.slice(i)}`}var he=(e,t,n)=>S("thunar",t)||n(a(e.configHome,"Thunar"));var K="ForgeTerminal.Forge",C=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),H=e=>e.replace(/['‘’‚‛]/g,"$&$&"),T=H;function W(e,t){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">${T(C(e))}</text><text id="2">${T(C(t))}</text></binding></visual></toast>')`,`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${K}').Show([Windows.UI.Notifications.ToastNotification]::new($x))`].join("; ")}function X(e,t,n=process.platform){return n==="win32"?["powershell.exe",["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",W(e,t)]]:["/usr/bin/osascript",["-e","on run argv","-e","display notification (item 2 of argv) with title (item 1 of argv)","-e","end run",e,t]]}var $=e=>`"${e.replace(/[\\"]/g,"\\$&").replace(/\n/g,"\\n")}"`;function V(e,t,n={}){let i=n.has??(o=>S(o));if(i("notify-send"))return["notify-send",["--app-name=Forge",...n.icon?[`--icon=${n.icon}`]:[],"--",e,t]];if(i("gdbus"))return["gdbus",["call","--session","--dest","org.freedesktop.Notifications","--object-path","/org/freedesktop/Notifications","--method","org.freedesktop.Notifications.Notify",$("Forge"),"0",$(n.icon??""),$(e),$(t),"[]","{}","-1"]]}function q(e,t,n=process.platform,i={}){let o=n==="linux"?V(e,t,i):X(e,t,n);return new Promise(r=>{if(o===void 0)return r();try{P(o[0],o[1],{timeout:1e4,windowsHide:!0},()=>r())}catch{r()}})}var J=(e,t)=>new Promise((n,i)=>P(e,t,{timeout:2e3},(o,r)=>o?i(o):n(r)));async function Y(e,t=J){let n=(await t("lsappinfo",["front"])).trim();return(await t("lsappinfo",["info","-only","bundleid",n])).match(/bundleID="([^"]*)"/)?.[1]===e}async function Me(e,t,n={}){if(e===void 0||!h(t))return;let i=n.platform??process.platform,o=n.env??process.env;if(o.FORGE_NO_NOTIFY||o.SSH_CONNECTION||o.SSH_TTY)return;let r=o.__CFBundleIdentifier;i==="darwin"&&r&&await Y(r,n.ask).catch(()=>!1)||await(n.post??((c,s)=>q(c,s,i)))(e.title,e.body)}export{u as a,E as b,G as c,Q as d,z as e,Z as f,d as g,oe as h,S as i,b as j,re as k,se as l,ae as m,ce as n,ue as o,pe as p,le as q,me as r,de as s,fe as t,ge as u,$e as v,xe as w,ye as x,B as y,Se as z,he as A,K as B,H as C,W as D,X as E,$ as F,V as G,q as H,Y as I,Me as J};
|
|
@@ -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-Z6IQV737.js";import"./chunk-W53XNVNH.js";import"./chunk-SM735FG7.js";import"./chunk-T4CLHCLJ.js";import"./chunk-TJ5YBJEO.js";import"./chunk-FEFNS6YZ.js";import"./chunk-Q6KQWJ4J.js";import"./chunk-6RMRWBMB.js";import"./chunk-H3KW7HTC.js";import"./chunk-NUW4YOJ6.js";import"./chunk-VBDRWNEG.js";import"./chunk-DHW72U6X.js";import"./chunk-KTCHWHQB.js";import"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import"./chunk-4OSMYHKQ.js";import"./chunk-O7DK3GJT.js";import"./chunk-RQWWUCGQ.js";import"./chunk-EEQSUBBL.js";import"./chunk-6TTONCYR.js";import"./chunk-FAUL5L2W.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.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-OXDRJO4V.js";import"./chunk-SM735FG7.js";import"./chunk-V6GWPR2A.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{a as copy,c as linuxText,b as paste};
|