forge-terminal 0.4.5 → 0.5.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 +104 -19
- package/dist/chunks/{about-credits-TJBWWNH6.js → about-credits-5UQU5WHE.js} +2 -2
- package/dist/chunks/args-QKAIL3E4.js +3 -0
- package/dist/chunks/{available-GYIHVSRX.js → available-M6Z62OWE.js} +1 -1
- package/dist/chunks/boot-MGR26CBU.js +3 -0
- package/dist/chunks/catalog-VPSTQTFD.js +3 -0
- package/dist/chunks/check-B6NP7BEM.js +3 -0
- package/dist/chunks/chunk-37P6QZ5Q.js +3 -0
- package/dist/chunks/chunk-3GJ7GV3V.js +19 -0
- package/dist/chunks/{chunk-EHARO6IS.js → chunk-57M4J2BR.js} +1 -1
- package/dist/chunks/chunk-63XCSYHM.js +3 -0
- package/dist/chunks/{chunk-JFJ3ZJQL.js → chunk-63ZK5SRQ.js} +1 -1
- package/dist/chunks/chunk-C4UCCBCX.js +3 -0
- package/dist/chunks/{chunk-DERIWZAT.js → chunk-CKZBBDAW.js} +1 -1
- package/dist/chunks/chunk-DZOBIUV6.js +3 -0
- package/dist/chunks/chunk-EKTUUKDP.js +80 -0
- package/dist/chunks/chunk-F34DPQFQ.js +63 -0
- package/dist/chunks/chunk-G46QQBT3.js +3 -0
- package/dist/chunks/chunk-GSK2A3TN.js +3 -0
- package/dist/chunks/chunk-H3DIRJFE.js +3 -0
- package/dist/chunks/chunk-HKINXTUW.js +3 -0
- package/dist/chunks/chunk-HOZ6XGQQ.js +6 -0
- package/dist/chunks/chunk-I6754KTB.js +36 -0
- package/dist/chunks/{chunk-YYB3TTGT.js → chunk-JMBEZPYC.js} +1 -1
- package/dist/chunks/chunk-K7KKCR7V.js +6 -0
- package/dist/chunks/chunk-KH5DHZ2U.js +8 -0
- package/dist/chunks/chunk-KXKQDFHX.js +3 -0
- package/dist/chunks/chunk-LVYQVJOF.js +3 -0
- package/dist/chunks/chunk-N6RCLJE6.js +4 -0
- package/dist/chunks/chunk-N72E43Z3.js +3 -0
- package/dist/chunks/chunk-NDECMPOM.js +3 -0
- package/dist/chunks/chunk-NXJGO66P.js +3 -0
- package/dist/chunks/chunk-OK7XOZFO.js +3 -0
- package/dist/chunks/chunk-P4RAYEM7.js +6 -0
- package/dist/chunks/{chunk-EX7KZBI6.js → chunk-PE5LAYGF.js} +1 -1
- package/dist/chunks/chunk-PPR7B5AR.js +3 -0
- package/dist/chunks/chunk-Q6KQWJ4J.js +3 -0
- package/dist/chunks/{chunk-GJ2GZHRI.js → chunk-RMD7F3QX.js} +1 -1
- package/dist/chunks/chunk-SK2UZ25Y.js +3 -0
- package/dist/chunks/chunk-SNDFMJIX.js +3 -0
- package/dist/chunks/{chunk-IGF6ZFTM.js → chunk-SZRSAL64.js} +1 -1
- package/dist/chunks/chunk-THDAQBQ3.js +3 -0
- package/dist/chunks/chunk-TL5MACSF.js +3 -0
- package/dist/chunks/chunk-V3I6DSF4.js +3 -0
- package/dist/chunks/{chunk-A6RK5ALT.js → chunk-W6SY5PPG.js} +2 -2
- package/dist/chunks/chunk-WC6SJN5Y.js +3 -0
- package/dist/chunks/chunk-WE6KP4FR.js +3 -0
- package/dist/chunks/chunk-WIPP5TWQ.js +3 -0
- package/dist/chunks/{chunk-GKECNCKO.js → chunk-XBOMWF34.js} +1 -1
- package/dist/chunks/chunk-XRI5XKEB.js +66 -0
- package/dist/chunks/chunk-Y7LOIHFU.js +3 -0
- package/dist/chunks/chunk-YINYF6C7.js +3 -0
- package/dist/chunks/chunk-ZRHYGR2L.js +134 -0
- package/dist/chunks/chunk-ZZZAPVKM.js +3 -0
- package/dist/chunks/clip-command-R2NKW4TI.js +3 -0
- package/dist/chunks/clipboard-GICOXMMN.js +3 -0
- package/dist/chunks/colour-APVBMEJQ.js +3 -0
- package/dist/chunks/command-GYCYLUHN.js +3 -0
- package/dist/chunks/config-command-6YUMMZF3.js +3 -0
- package/dist/chunks/continue-editing-QE5RRIMG.js +3 -0
- package/dist/chunks/decoded-UNCEUPNW.js +3 -0
- package/dist/chunks/entry-TSLQHDP7.js +6 -0
- package/dist/chunks/execute-S5WN34PS.js +3 -0
- package/dist/chunks/extensions-XI5R74TS.js +3 -0
- package/dist/chunks/{extensions-command-ABJSGDPK.js → extensions-command-25JOL47P.js} +1 -1
- package/dist/chunks/ffmpeg-3CJ6C37W.js +3 -0
- package/dist/chunks/image-QSTDWHJ4.js +3 -0
- package/dist/chunks/install-IDUHZTTS.js +3 -0
- package/dist/chunks/{install-V62EEK54.js → install-L5C2UT6M.js} +1 -1
- package/dist/chunks/install-size-PZUFEDGI.js +3 -0
- package/dist/chunks/launch-LFFWVTFE.js +17 -0
- package/dist/chunks/libs-EK64ACG3.js +3 -0
- package/dist/chunks/lock-PTQUMNYX.js +3 -0
- package/dist/chunks/manager-CQ6NNQY4.js +4 -0
- package/dist/chunks/needed-MYXIUZI4.js +3 -0
- package/dist/chunks/own-WNA6BFYL.js +3 -0
- package/dist/chunks/{paths-5XI5L4KW.js → paths-EOYKOUBC.js} +1 -1
- package/dist/chunks/pdfium-WFGSET5S.js +3 -0
- package/dist/chunks/preferences-3P4V2EDX.js +3 -0
- package/dist/chunks/preset-command-HMOFTZSG.js +3 -0
- package/dist/chunks/registry-4IOXO6DT.js +3 -0
- package/dist/chunks/{reveal-L6TBFOMV.js → reveal-D5FCZYOA.js} +1 -1
- package/dist/chunks/run-HGZVOXRW.js +5 -0
- package/dist/chunks/{server-TUWDAECT.js → server-KKF3XBQG.js} +8 -8
- package/dist/chunks/text-layer-LHZNDMPZ.js +3 -0
- package/dist/chunks/{theme-7IVYHKTP.js → theme-NAWQ77WF.js} +1 -1
- package/dist/chunks/transcribe-Q5NLWSSR.js +3 -0
- package/dist/chunks/transcribe-command-2L7F7MCG.js +3 -0
- package/dist/chunks/{update-command-GMBG7BK6.js → update-command-JCTCRPCS.js} +1 -1
- package/dist/chunks/update-note-FRMHMUMD.js +3 -0
- package/dist/chunks/watch-command-XCCMIQIM.js +3 -0
- package/dist/fonts/NotoSans-Bold.ttf.gz +0 -0
- package/dist/fonts/NotoSans-Regular.ttf.gz +0 -0
- package/dist/fonts/OFL.txt +93 -0
- package/dist/helpers/forge-transcribe +0 -0
- package/dist/helpers/forge-transcribe-whisper.mjs +525 -0
- package/dist/index.js +8 -8
- package/dist/third-party-licenses.txt +98 -0
- package/package.json +43 -12
- package/dist/chunks/args-MGXWV4UD.js +0 -3
- package/dist/chunks/boot-AE6XH7Z3.js +0 -3
- package/dist/chunks/catalog-YSMT3PXT.js +0 -3
- package/dist/chunks/check-KAR72Y4X.js +0 -3
- package/dist/chunks/chunk-3UEQ2OX6.js +0 -3
- package/dist/chunks/chunk-5B5XXH22.js +0 -3
- package/dist/chunks/chunk-5IS7O673.js +0 -6
- package/dist/chunks/chunk-6FUVEO3A.js +0 -78
- package/dist/chunks/chunk-6L6C3GJU.js +0 -3
- package/dist/chunks/chunk-7S5DBC3J.js +0 -66
- package/dist/chunks/chunk-AAXBN572.js +0 -4
- package/dist/chunks/chunk-BZXDNDPG.js +0 -3
- package/dist/chunks/chunk-CEULBUUM.js +0 -63
- package/dist/chunks/chunk-DOWMSJ6R.js +0 -3
- package/dist/chunks/chunk-EXLXSKRH.js +0 -3
- package/dist/chunks/chunk-FH3R2YYD.js +0 -19
- package/dist/chunks/chunk-FWIXOYXE.js +0 -3
- package/dist/chunks/chunk-I63TO22X.js +0 -3
- package/dist/chunks/chunk-IWFVEMDN.js +0 -3
- package/dist/chunks/chunk-JSMGNA55.js +0 -3
- package/dist/chunks/chunk-KAHWYWNT.js +0 -3
- package/dist/chunks/chunk-LDKF7KIZ.js +0 -6
- package/dist/chunks/chunk-LNB5D67B.js +0 -3
- package/dist/chunks/chunk-M66BUNYO.js +0 -3
- package/dist/chunks/chunk-PSEIJXGT.js +0 -3
- package/dist/chunks/chunk-QR6QHTC3.js +0 -3
- package/dist/chunks/chunk-QXTXBMTM.js +0 -3
- package/dist/chunks/chunk-SMBK6BTC.js +0 -3
- package/dist/chunks/chunk-TDW6KQH6.js +0 -3
- package/dist/chunks/chunk-TMQDQLY7.js +0 -21
- package/dist/chunks/chunk-XSOCV3F2.js +0 -3
- package/dist/chunks/chunk-YWKMG5WO.js +0 -3
- package/dist/chunks/clip-command-D3DE2WUR.js +0 -3
- package/dist/chunks/clipboard-CPHPA4FH.js +0 -3
- package/dist/chunks/colour-U6QBTJTQ.js +0 -3
- package/dist/chunks/command-I5M275ZV.js +0 -3
- package/dist/chunks/config-command-TYNYVUMP.js +0 -3
- package/dist/chunks/entry-4GMHXHST.js +0 -6
- package/dist/chunks/execute-D4H7QWGR.js +0 -3
- package/dist/chunks/extensions-DOTV7SIR.js +0 -3
- package/dist/chunks/ffmpeg-PF3VLTHK.js +0 -3
- package/dist/chunks/image-J4FT4ACZ.js +0 -3
- package/dist/chunks/install-2A5BGKQU.js +0 -3
- package/dist/chunks/launch-XVWOLOXM.js +0 -15
- package/dist/chunks/lock-KN7CF4YN.js +0 -3
- package/dist/chunks/manager-TVGSLNBE.js +0 -4
- package/dist/chunks/preferences-4VETUGMN.js +0 -3
- package/dist/chunks/preset-command-HORY7KZQ.js +0 -3
- package/dist/chunks/run-6BK4REXK.js +0 -4
- package/dist/chunks/transcribe-command-YUSBCQEQ.js +0 -3
- package/dist/chunks/update-note-A7C2OJKU.js +0 -3
- package/dist/chunks/watch-command-NOMNFJ75.js +0 -3
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as k}from"./chunk-HON4OV7M.js";import{b as p}from"./chunk-M66BUNYO.js";import{mkdir as A,readFile as O,rename as M,unlink as T,writeFile as D}from"node:fs/promises";import{homedir as F}from"node:os";import{dirname as I,join as S}from"node:path";var C=e=>/^[A-Za-z0-9][A-Za-z0-9-]*$/.test(e),a=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),u=e=>typeof e=="number"&&Number.isInteger(e)&&e>0;function B(e){if(!(!a(e)||Object.keys(e).length!==1)){if(u(e.width))return{width:e.width};if(u(e.height))return{height:e.height};if(u(e.percent))return{percent:e.percent}}}function R(e){if(!a(e))return;let t={};if(e.to!==void 0){if(typeof e.to!="string"||!p(e.to))return;t.to=e.to}if(e.quality!==void 0){if(!u(e.quality)||e.quality>100)return;t.quality=e.quality}if(e.maxBytes!==void 0){if(!u(e.maxBytes))return;t.maxBytes=e.maxBytes}if(e.resize!==void 0){let n=B(e.resize);if(!n)return;t.resize=n}for(let n of["trim","sharpen","removeBackground"])if(e[n]!==void 0){if(typeof e[n]!="boolean")return;t[n]=e[n]}if(e.crop!==void 0){if(!a(e.crop)||!u(e.crop.w)||!u(e.crop.h))return;t.crop={w:e.crop.w,h:e.crop.h}}if(e.boost!==void 0){if(e.boost!==2&&e.boost!==3&&e.boost!==4)return;t.boost=e.boost}if(e.behind!==void 0){if(e.behind!=="white"&&e.behind!=="black")return;t.behind=e.behind}return t}function b(e){if(!a(e)||typeof e.name!="string"||!C(e.name)||typeof e.saveTo!="string"||e.saveTo.trim()==="")return;let t=R(e.steps);if(t)return{name:e.name,steps:t,saveTo:e.saveTo}}var q={white:"#ffffff",black:"#000000"};function U(e,t){let n=[];e.removeBackground&&n.push({kind:"cutout"}),e.boost?n.push({kind:"boost",scale:e.boost}):e.sharpen&&n.push({kind:"boost",scale:1});let i=[];e.trim&&i.push({kind:"cut",trim:!0}),e.crop&&i.push({kind:"cut",crop:e.crop});let s=e.to??t,r={kind:"encode",target:s};if(e.quality!==void 0&&!e.maxBytes&&(r.quality=e.quality),e.maxBytes&&(r.maxBytes=e.maxBytes),e.resize&&(r.resize=e.resize),n.length===0){let o=i.pop();o?.kind==="cut"&&(o.trim&&(r.trim=!0),o.crop&&(r.crop=o.crop))}if(r.maxBytes&&(r.trim||r.crop||r.resize)){let{trim:o,crop:m,resize:y}=r;i.push({kind:"cut",...o?{trim:o}:{},...m?{crop:m}:{},...y?{resize:y}:{}}),delete r.trim,delete r.crop,delete r.resize}if(e.removeBackground&&!p(s)?.hasAlpha&&(r.background=q[e.behind??"white"]),i.length===0&&n.length===0&&Object.keys(r).length===2&&e.to===void 0)return[];let d=i.filter(o=>o.kind==="cut"&&o.resize);return[...i.filter(o=>!d.includes(o)),...n,...d,r]}import{execFileSync as E}from"node:child_process";import{homedir as x}from"node:os";import{join as P}from"node:path";var N={Desktop:"[Environment]::GetFolderPath('Desktop')",Downloads:"(Get-ItemProperty 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders').'{374DE290-123F-4565-9164-39C4925E467B}'"};function j(e){try{let n=E("powershell.exe",["-NoProfile","-NonInteractive","-Command",`[Console]::OutputEncoding=[Text.Encoding]::UTF8; ${N[e]}`],{encoding:"buffer",timeout:5e3,stdio:["ignore","pipe","ignore"]}).toString("utf8").trim();return n.length>0?n:void 0}catch{return}}var w=new Map;function l(e,t=process.platform,n=j){if(t!=="win32")return P(x(),e);let i=w.get(e);if(i!==void 0)return i;let r=n(e)?.replace(/%([^%]+)%/g,(g,o)=>process.env[o]??g),d=(r!==void 0&&!r.includes("%")?r:void 0)??P(x(),e);return w.set(e,d),d}var f={defaultOutput:"~/Desktop",quality:80};function h(){return S(k(),"forge","config.json")}function ee(e,t=process.platform){if(t==="win32"){if(e==="~/Desktop")return l("Desktop",t);if(e==="~/Downloads")return l("Downloads",t)}return e==="~"?F():e.startsWith("~/")?S(F(),e.slice(2)):e}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){let t={...f},n=[];if(e.theme!==void 0&&(e.theme==="dark"||e.theme==="light"?t.theme=e.theme:n.push("theme")),e.defaultOutput!==void 0&&(typeof e.defaultOutput=="string"&&e.defaultOutput.trim().length>0?t.defaultOutput=e.defaultOutput:n.push("defaultOutput")),e.quality!==void 0){let i=e.quality;typeof i=="number"&&Number.isInteger(i)&&i>=1&&i<=100?t.quality=i:n.push("quality")}if(e.updateCheck!==void 0&&(typeof e.updateCheck=="boolean"?t.updateCheck=e.updateCheck:n.push("updateCheck")),e.rightClickMenu!==void 0&&(typeof e.rightClickMenu=="boolean"?t.rightClickMenu=e.rightClickMenu:n.push("rightClickMenu")),e.searchMac!==void 0&&(typeof e.searchMac=="boolean"?t.searchMac=e.searchMac:n.push("searchMac")),e.lastOutput!==void 0&&(typeof e.lastOutput=="string"&&e.lastOutput.trim().length>0?t.lastOutput=e.lastOutput:n.push("lastOutput")),e.presets!==void 0)if(Array.isArray(e.presets)){let i=e.presets.map(b);t.presets=i.filter(s=>s!==void 0),t.presets.length<i.length&&n.push("presets")}else n.push("presets");return{prefs:t,rejected:n}}async function K(){let e;try{e=await O(h(),"utf8")}catch{return}try{let t=JSON.parse(e);return z(t)?t:void 0}catch{return}}async function te(){let e=h(),t;try{t=await O(e,"utf8")}catch(r){return r.code==="ENOENT"?{prefs:f}:{prefs:f,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let n;try{n=JSON.parse(t)}catch{return{prefs:f,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!z(n))return{prefs:f,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:i,rejected:s}=$(n);return s.length===0?{prefs:i}:{prefs:i,warning:`Ignored invalid config ${s.length===1?"setting":"settings"}: ${s.join(", ")}.`}}async function ne(e){let t=h();await A(I(t),{recursive:!0});let i={...await K()??{}};for(let[r,c]of Object.entries(e))c!==void 0&&(i[r]=c);let s=`${t}.${process.pid}.tmp`;try{await D(s,`${JSON.stringify(i,null,2)}
|
|
4
|
-
`,"utf8"),await M(s,t)}catch(r){throw await T(s).catch(()=>{}),r}}export{U as a,l as b,f as c,h as d,ee as e,te as f,ne as g};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as B}from"./chunk-U5TEGDGH.js";import{a as K,b as Y}from"./chunk-HZDYZ5RD.js";import{h as W}from"./chunk-QR6QHTC3.js";import{b as J}from"./chunk-EEQSUBBL.js";import{a as D}from"./chunk-YYB3TTGT.js";import{l as L,n as U}from"./chunk-KAHWYWNT.js";import{F as d,I as H}from"./chunk-3UEQ2OX6.js";import{d as R}from"./chunk-J7FLFHQJ.js";import{a as X}from"./chunk-GKECNCKO.js";import{b as z}from"./chunk-M66BUNYO.js";var x=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}},v=class extends x{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 v(`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 V(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as ae}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 ue}from"node:util";import{stripVTControlCharacters as re}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=>V(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(c,p){return t.formatItem(c,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(c=>r(t.styleArgumentTerm(t.argumentTerm(c)),t.styleArgumentDescription(t.argumentDescription(c))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),c=>c.helpGroupHeading??"Options:").forEach((c,p)=>{let O=c.map(_=>r(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));o=o.concat(this.formatItemList(p,O,t))}),t.showGlobalOptions){let c=t.visibleGlobalOptions(e).map(p=>r(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",c,t))}return this.groupItems(e.commands,t.visibleCommands(e),c=>c.helpGroup()||"Commands:").forEach((c,p)=>{let O=c.map(_=>r(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,O,t))}),o.join(`
|
|
4
|
-
`)}displayWidth(e){return re(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,c;return a<this.minWidthToWrap||i.preformatted(n)?c=n:c=i.boxWrap(n,a).replace(/\n/g,`
|
|
5
|
-
`+" ".repeat(t+l)),o+u+" ".repeat(l)+c.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()],h=this.displayWidth(l[0]);u.forEach(a=>{let c=this.displayWidth(a);if(h+c<=t){l.push(a),h+=c;return}r.push(l.join(""));let p=a.trimStart();l=[p],h=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=oe(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 v(`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?Q(this.name().replace(/^no-/,"")):Q(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}},N=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 Q(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function oe(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 se(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=se(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 ae{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:()=>ee()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>ee()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:t=>ue(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 x(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,h)=>{let a=u.exec(l);return a?a[0]:h},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,c){let p=C.resolve(a,c);if(F.existsSync(p))return p;if(n.includes(C.extname(c)))return;let O=n.find(_=>F.existsSync(`${p}${_}`));if(O)return`${p}${O}`}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 c=C.basename(this._scriptPath,C.extname(this._scriptPath));c!==this._name&&(a=i(o,`${c}-${e._name}`))}r=a||r}let u=n.includes(C.extname(r)),l;m.platform!=="win32"?u?(t.unshift(r),t=Z(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=Z(m.execArgv).concat(t),l=G.spawn(m.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(c=>{m.on(c,()=>{l.killed===!1&&l.exitCode===null&&l.kill(c)})});let h=this._exitCallback;l.on("close",a=>{a=a??1,h?h(new x(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(!h)m.exit(1);else{let c=new x(1,"commander.executeSubCommandAsync","(error)");c.nestedError=a,h(c)}}),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(c=>c.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,u=null,l=null,h=0;for(;h<e.length||l;){let a=l??e[h++];if(l=null,a==="--"){i===n&&i.push(a),i.push(...e.slice(h));break}if(u&&(!r(a)||o(a))){this.emit(`option:${u.name()}`,a);continue}if(u=null,r(a)){let c=this._findOption(a);if(c){if(c.required){let p=e[h++];p===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,p)}else if(c.optional){let p=null;h<e.length&&(!r(e[h])||o(e[h]))&&(p=e[h++]),this.emit(`option:${c.name()}`,p)}else this.emit(`option:${c.name()}`);u=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),l=`-${a.slice(2)}`);continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),p=this._findOption(a.slice(0,c));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,a.slice(c+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(h));break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a,...e.slice(h));break}else if(this._defaultCommandName){n.push(a,...e.slice(h));break}}if(this._passThroughOptions){i.push(a,...e.slice(h));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 N(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),h=this.options.find(c=>c.negate&&u===c.attributeName()),a=this.options.find(c=>!c.negate&&u===c.attributeName());return h&&(h.presetArg===void 0&&l===!1||h.presetArg!==void 0&&l===h.presetArg)?h: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=>V(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 Z(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 ee(){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 Xe=new $;function le(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||!D.includes(t))throw d(`Unknown config setting ${t??"(none)"}.`,`Try one of: ${D.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 he={jpg:"jpeg",tif:"tiff",heif:"heic"};function I(s){let e=s.toLowerCase().replace(/^\./,""),t=z(he[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 ce(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")),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 te(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 de(s){let e=String(s),t=/^\d+(\.\d+)?%?$/.test(e)?Number.parseFloat(e):Number.NaN;if(!(t>=1&&t<=W))throw d(`--resize takes a percent from 1 to ${W}, 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 pe=`
|
|
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`,fe=`
|
|
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 clip compress the copied image and put it back (--to, --quality,
|
|
38
|
-
--max-size, --save [folder], --undo)
|
|
39
|
-
forge transcribe <file | link>
|
|
40
|
-
a video or audio file, or a YouTube link, into Markdown
|
|
41
|
-
(--to all | notes | transcript, --detail brief | standard | detailed,
|
|
42
|
-
--language <id>, -o <path>, --force)
|
|
43
|
-
forge watch <folder> --to <format>
|
|
44
|
-
convert the folder, then every file added to it, until ctrl-c
|
|
45
|
-
(--quality, --dpi, -o <folder>, --new-only, --json)
|
|
46
|
-
forge config [list | path | set <setting> <value>]
|
|
47
|
-
forge extensions [add | remove <id>] optional extras, such as boost and remove-background
|
|
48
|
-
forge update install a newer Forge, if there is one
|
|
49
|
-
forge uninstall take Forge out of the right-click menu, then remove it
|
|
50
|
-
forge mcp run as a local MCP server over stdio, for AI agents`;function M(s){let e=R(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 me(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 ge(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=M(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 be(s){let e=s.slice(1),t=[],n={kind:"transcribe",input:"",notes:!0,transcript:!0,detail:Y,force:!1,debug:!1},i=(l,h)=>{let a=e[h+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 h=e[l];if(h==="--debug")n.debug=!0;else if(h==="--force"||h==="-f")n.force=!0;else if(h==="--language"||h==="-l")n.language=i(h,l++);else if(h==="--output"||h==="-o")n.output=i(h,l++);else if(h==="--detail"){let a=i(h,l++).toLowerCase();if(!K.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(h==="--to"||h==="-t"){let a=i(h,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.notes=a!=="transcript",n.transcript=a!=="notes"}else{if(h.startsWith("-"))throw d(`forge transcribe does not take ${h}.`,r);t.push(h)}}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 _e(s){let e=s.slice(1),t=[],n,i={kind:"watch",newOnly:!1,debug:!1},r={},o=(h,a)=>{let c=e[a+1];if(c===void 0||c.startsWith("-"))throw d(`${h} needs a value.`);return c};for(let h=0;h<e.length;h++){let a=e[h];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,h++));else if(a==="--quality"||a==="-q")r.quality=S(o(a,h++));else if(a==="--output"||a==="-o")r.output=o(a,h++);else if(a==="--dpi"){let c=o(a,h++),p=Number(c);if(!Number.isInteger(p)||p<36||p>600)throw H(c);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 we(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 ne(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=B(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}var ye={palette:`Usage: forge palette <image> [--json] [--svg] [--inside <hex>]
|
|
51
|
-
|
|
52
|
-
An image's main colours, most of the image first.
|
|
53
|
-
--json one JSON document: palette.colours[] with hex, rgb, oklch, share
|
|
54
|
-
--svg a card of swatches; pipe to pbcopy and paste into Figma
|
|
55
|
-
--inside <hex> the shades of the palette colour nearest <hex>
|
|
56
|
-
`,scale:`Usage: forge scale <colour> [--json] [--svg]
|
|
57
|
-
|
|
58
|
-
50\u2013950 built in OKLCH, with <colour> at 500. Pass the hex without #, or quote it.
|
|
59
|
-
--json one JSON document: scale.steps[] with hex, oklch, white, black
|
|
60
|
-
--svg a card of swatches; pipe to pbcopy and paste into Figma
|
|
61
|
-
`};function Oe(s){let[e,...t]=s;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(ye[e==="scale"?"scale":"palette"]),new x(0,"commander.helpDisplayed","(outputHelp)");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:ne(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:ne(o)}}}function ct(s){let e=s.indexOf("--");return(e===-1?s:s.slice(0,e)).includes("--json")}function xe(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 h=l;if(h===void 0&&/^\d+$/.test(t[o+1]??"")&&(h=t[++o]),h!==void 0&&h!=="2"&&h!=="3"&&h!=="4")throw d(`--boost takes 2, 3 or 4, not ${h}.`,"Try --boost, --boost 2, --boost 3 or --boost 4.");r=h==="4"?4:h==="3"?3:2}return{rest:[...i,...n],...r===void 0?{}:{scale:r}}}function dt(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]==="update"||e[0]==="uninstall")return Ce(e);let t=xe(e);return ke(t.rest,t.scale)}function Ce(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"?ge(s):s[0]==="watch"?_e(s):s[0]==="transcribe"?be(s):s[0]==="config"?le(s.filter(e=>e!=="--json")):s[0]==="probe"?me(s):s[0]==="palette"||s[0]==="scale"?Oe(s):we(s)}function ke(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("--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(X,"-V, --version","show the version").addHelpText("after",`${fe}
|
|
62
|
-
${pe}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(s,{from:"user"})}catch(f){if(f instanceof x&&f.code!=="commander.helpDisplayed"&&f.code!=="commander.version"){let[g="",...b]=f.message.replace(/^error: /,"").split(`
|
|
63
|
-
`),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=ce(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"]:[]],h=r!==void 0&&!n.to&&n.quality===void 0&&n.maxSize===void 0;if(n.trim||n.crop!==void 0||l.length>0||h){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(ie=>`--${ie}`)][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:L(String(n.crop))}:void 0,w=n.resize!==void 0?{percent:de(n.resize)}:n.width!==void 0?{width:te("--width",n.width)}:n.height!==void 0?{height:te("--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 k={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(k.quality=S(String(n.quality)));let y={kind:"edit",inputs:i,trim:!!n.trim,options:k,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,c=a!==void 0?"boost":n.removeBg?"remove-background":null;if(c!==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(c==="remove-background"){let k=U(g);if(k)throw k}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:c,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+)$/),k=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(k?.[1])g.split={mode:"points",after:k[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=M(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 O=Number(n.dpi);if(!Number.isInteger(O)||O<36||O>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:O,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=M(n.maxSize)),n.concurrency!==void 0&&(_.concurrency=j(String(n.concurrency))),_}export{pe as a,fe as b,ct as c,dt as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{i as F}from"./chunk-LNB5D67B.js";import{a as y}from"./chunk-QR6QHTC3.js";import{i as h}from"./chunk-6L6C3GJU.js";import{b as g}from"./chunk-EXLXSKRH.js";import{d as b}from"./chunk-3UEQ2OX6.js";import{a as u}from"./chunk-M66BUNYO.js";import{existsSync as I}from"node:fs";import{open as k,readdir as w,stat as K}from"node:fs/promises";import{basename as A,dirname as j,extname as S,join as v,resolve as R}from"node:path";function M(e){return e.startsWith(".")||/\.(crdownload|part|download|tmp)$/i.test(e)}function O(e){return e.kind==="image"?"images":e.format==="pdf"?"pdfs":"documents"}var $=new Set(Object.values(u).flatMap(e=>e.extensions));async function E(e){let r=await k(e,"r"),n=Buffer.alloc(4096),i=0;try{i=(await r.read(n,0,n.length,0)).bytesRead}finally{await r.close()}let t=n.subarray(0,i),o=(c,a)=>t.subarray(c,c+a).toString("latin1");return o(4,4)==="ftyp"?/^(M4A |M4B |M4P )$/.test(o(8,4))?"audio":"video":t[0]===26&&t[1]===69&&t[2]===223&&t[3]===163?"video":o(0,4)==="RIFF"?o(8,4)==="WAVE"?"audio":o(8,3)==="AVI"?"video":"other":t[0]===0&&t[1]===0&&t[2]===1&&(t[3]===186||t[3]===179)?"video":o(0,3)==="ID3"||o(0,4)==="fLaC"||o(0,4)==="OggS"||o(0,4)==="FORM"&&/^AIF[FC]$/.test(o(8,4))||t[0]===255&&t[1]!==void 0&&(t[1]&224)===224?"audio":i>0&&!t.includes(0)&&N(t)?"text":"other"}function N(e){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e,{stream:!0}),!0}catch{return!1}}var x=["images","pdfs","documents","videos","audio","other"];function q(e,r){if(e==="videos"||e==="audio")return"not yet supported";if(e==="other")return r.every(n=>n==="text")?r.length===1?"a text file":"text files":"not supported"}async function G(e){let r=R(e),n=await w(r,{withFileTypes:!0}),i=[],t=[],o=new Map,c=[],a=0;for(let f of n.sort((d,s)=>d.name.localeCompare(s.name))){if(!f.isFile()||M(f.name))continue;let d=v(r,f.name);c.push(d);let s=await D(d);if(s.kind==="source")i.push(s.source),a+=s.source.bytes;else if(s.kind==="failed")t.push(s.failure),a+=s.bytes;else{let p=s.kind,m=o.get(p)??{bytes:0,sniffed:[]};m.bytes+=s.bytes,m.sniffed.push(s.sniffed),o.set(p,m),a+=s.bytes}}let l=[];for(let f of x){let d=i.filter(s=>O(s)===f);d.length>0&&l.push({id:f,count:d.length,bytes:d.reduce((s,p)=>s+p.bytes,0),sources:d})}l.sort((f,d)=>d.count-f.count);for(let f of x){let d=o.get(f);if(!d)continue;let s=q(f,d.sniffed);l.push({id:f,count:d.sniffed.length,bytes:d.bytes,sources:[],...s===void 0?{}:{why:s}})}return{dir:r,sources:i,failures:t,kinds:l,bytes:a,paths:c}}async function D(e){let r=()=>K(e).then(n=>n.size,()=>0);try{let n=await h(e);if(n.kind==="media"){let i=u[n.format].media==="video";return{kind:i?"videos":"audio",sniffed:i?"video":"audio",bytes:n.bytes}}return{kind:"source",source:n}}catch(n){let i=await r(),t=await E(e).catch(()=>"other");if(t==="video"||t==="audio")return{kind:t==="video"?"videos":"audio",sniffed:t,bytes:i};if($.has(S(e).toLowerCase())){let o=b(n)?n:void 0;if(o)return{kind:"failed",failure:{path:e,error:o},bytes:i}}return{kind:"other",sniffed:t,bytes:i}}}function T(e){let r=new Set(e.flatMap(n=>y(n).filter(i=>i!==n.format)));return Object.keys(u).filter(n=>r.has(n))}function H(e,r){let n=T(e),i=e[0],t=i?.kind==="image"?"webp":i?.format==="pdf"?"png":void 0,o=t&&n.includes(t)?t:n[0];if(o)return B(e,o,r)}function B(e,r,n){let i={target:r};return u[r].lossy&&(i.quality=n),e.some(t=>t.kind==="document"&&t.format==="pdf")&&(r==="png"||r==="jpeg")&&(i.dpi=150),i}function Q(e,r,n,i){if(e.format===r.target)return{left:`already ${u[r.target].label}`};if(!y(e).includes(r.target))return{left:`can\u2019t become ${u[r.target].label}`};let[t]=F.plan([e],{target:r.target,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:String(r.dpi)},pages:"all",...i===void 0?{}:{destination:i}});if(t?.op!=="convert")return{left:"not supported"};if(t.outputs.some(o=>I(o)&&!n.has(o)))return{left:"already converted"};t.outputs=t.outputs.map(o=>C(o,n));for(let o of t.outputs)n.add(o);return{job:t}}function C(e,r){if(!r.has(e))return e;let n=S(e),i=A(e,n);for(let t=1;;t++){let o=v(j(e),g(i,` (${t})${n}`));if(!r.has(o)&&!I(o))return o}}export{M as a,O as b,E as c,G as d,D as e,T as f,H as g,B as h,Q as i};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as x}from"./chunk-M66BUNYO.js";import{existsSync as l,statSync as h}from"node:fs";import{basename as f,dirname as E,extname as a,isAbsolute as F,join as o,relative as R,resolve as s,sep as k}from"node:path";function y(t){return t.endsWith("/")||t.endsWith(k)||l(t)&&h(t).isDirectory()?!0:a(t)===""}var O=255;function b(t,r){return r==="darwin"||r==="win32"?t.length:Buffer.byteLength(t)}function c(t,r,e=process.platform){if(b(t+r,e)<=O)return t+r;let n="";for(let i of t){if(b(n+i+r,e)>O)break;n+=i}return n+r}function j(t,r){if(s(t)===s(r))return!0;try{let e=h(t),n=h(r);return e.dev===n.dev&&e.ino===n.ino}catch{return!1}}function A(t,r){let e=f(t),n=a(e),i=n?e.slice(0,-n.length):e;return c(i,x(r))}function S(t,r,e){if(!e)return t;let n=R(s(e),r);return!n||n.startsWith("..")?t:o(t,n)}function L(t){let r=s(t.sourcePath),e=A(r,t.target);if(!t.output)return o(s(r,".."),e);let n=F(t.output)?t.output:s(t.output);return y(t.output)?o(S(n,s(r,".."),t.sourceRoot),e):s(n)}function D(t){let r=L(t);if(t.output&&!y(t.output))return r;let e=a(r);return o(s(r,".."),c(f(r,e),`-${t.suffix}${e}`))}function J(t){if(!l(t))return t;let r=s(t,".."),e=f(t),n=a(e),i=n?e.slice(0,-n.length):e;for(let u=1;u<1e4;u++){let g=o(r,c(i,` (${u})${n}`));if(!l(g))return g}throw new Error(`no free name beside ${e}`)}function p(t){let r=s(t,".."),e=f(t),n=a(e);return{dir:r,stem:n?e.slice(0,-n.length):e,ext:n||".pdf"}}function w(t,r){let{dir:e,stem:n,ext:i}=p(s(t));return o(e,c(n,`-${r}${i}`))}function T(t,r){let{dir:e,stem:n,ext:i}=p(s(t)),u=String(r).length;return Array.from({length:r},(g,m)=>o(e,c(n,`-${String(m+1).padStart(u,"0")}${i}`)))}function z(t,r,e,n,i){let{stem:u}=p(s(t)),g=n?S(s(n),s(t,".."),i):s(t,".."),m=x(e),P=String(Math.max(1,...r.map(d=>d+1))).length,I=r.map(d=>o(g,c(u,`-${String(d+1).padStart(P,"0")}${m}`))),[$,...v]=I;if($===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[$,...v]}function B(t,r,e){if(!e)return[w(t,"extract")];let{dir:n,stem:i,ext:u}=p(s(t));return r.map(g=>o(n,c(i,`-p${g+1}${u}`)))}function C(t){let r=s(t[0]??"merged.pdf");if(new Set(t.map(n=>s(n,".."))).size===1){let n=s(r,"..");return o(n,c(f(n),"-merged.pdf"))}return w(r,"merged")}function N(t,r,e){let n=r?t.map(u=>o(r,f(u))):t,[i]=n;return!e||n.length!==1||i===void 0?n:[o(E(i),`${e}${a(i)}`)]}function G(t,r,e){return N([t],r,e)[0]??t}export{y as a,c as b,j as c,L as d,D as e,J as f,w as g,T as h,z as i,B as j,C as k,N as l,G as m};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as $,h as lt,i as D}from"./chunk-IWFVEMDN.js";import{b as x,c as R,d as H,f as v,g as P,h as X}from"./chunk-QVACE4IE.js";import{i as it}from"./chunk-6L6C3GJU.js";import{D as at,E as st,v as ot}from"./chunk-KAHWYWNT.js";import{d as tt,m as et,o as nt,u as rt}from"./chunk-3UEQ2OX6.js";import{a as Z}from"./chunk-M66BUNYO.js";var xt=[[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 w(t){let{C:e,h:n}=v(R(t));return e<.03?"grey":_(n)}function _(t){let e=(t%360+360)%360;return(xt.find(([n])=>e<n)??[360,"rose"])[1]}var Tt=["full","mono","analogous","opposite","split","triad","pastel"],ct={full:"Full set",mono:"Monochromatic",analogous:"Analogous",opposite:"Complementary",split:"Split complementary",triad:"Triadic",pastel:"Pastel"},B={brightness:0,saturation:0,hue:0,contrast:0},At=t=>!!(t.brightness||t.saturation||t.hue||t.contrast),G=[{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}}],$t={analogous:[-30,0,30],opposite:[0,180],split:[0,150,210],triad:[0,120,240]},wt=.553,yt=.024,b=t=>v(R(t)),C=(t,e,n)=>H(P({L:t,C:Math.max(0,e),h:(n+360)%360})),K=(t,e)=>(t-e+540)%360-180;function ht(t,e,n){let r=P({L:t,C:e,h:n}),a=R(H(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;ht(t,o,e)?n=o:r=o}return n}function W({L:t,C:e,h:n}){let r=L(t,n);return r>0?Math.min(1,e/r):0}var A=(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 T(t,e){if(!(e.brightness||e.saturation||e.hue))return t;let{L:n,C:r,h:a}=b(t),o=A(n,e.brightness),i=(a+e.hue+360)%360,l=q(r,L(o,i),e.saturation);for(let s=0;s<40&&l>0&&!ht(o,l,i);s++)l-=.005;return C(o,l,i)}function k(t,e,n,r){let a=A(t,r.brightness),o=(n+r.hue+360)%360,i=L(a,o);return C(a,Math.min(i,q(e,i,r.saturation)),o)}function Y(t,e,n){if(!e)return t;let r=b(t[n].rgb).L;return t.map((a,o)=>{if(o===n)return a;let i=b(a.rgb),l=Math.max(.02,Math.min(.995,r+(i.L-r)*(1+e/100))),s=C(l,Math.min(i.C,L(l,i.h)),i.h);return{...a,rgb:s,hex:x(s)}})}function Et(t,e,n,r){return Y(t(T(e,n)),n.contrast,r)}function ut(t,e){let n=b(t),r=G.map(s=>b(s.hex)),a=0;r.forEach((s,c)=>{Math.abs(K(n.h,s.h))<Math.abs(K(n.h,r[a].h))&&(a=c)});let o=r[a],i=Math.max(-10,Math.min(10,K(n.h,o.h)/2)),l=W(n);return G.map((s,c)=>{if(c===a)return{name:s.name,role:s.role,rgb:T(t,e),yours:!0};let h=r[c],p=n.L>=o.L?h.L+(n.L-o.L)*(1-h.L)/(1-o.L):h.L*n.L/o.L,f=A(p,e.brightness),g=(h.h+i+e.hue+360)%360,d=L(f,g),u=Math.min(1,W(h)),S=Math.min(d,q(l*u*d,d,e.saturation));return{name:s.name,role:s.role,rgb:C(f,S,g),yours:!1}})}function St(t,e,n){let r=b(t),a=w(t);if(e==="mono")return[{name:a,rgb:T(t,n),yours:!0},{name:`${a} soft`,rgb:k(r.L,r.C*.5,r.h,n),yours:!1},{name:`${a} dusty`,rgb:k(r.L,r.C*.22,r.h,n),yours:!1}];if(e==="pastel")return ut(t,B).map((l,s)=>{let c=b(l.rgb),h=c.C<.01?b(G[s].hex).h:c.h;return{...l,rgb:k(.86,Math.min(.1,L(.86,h))*.85,h,n)}});let o=W(r);return($t[e]??[0]).map(l=>{if(l===0)return{name:a,rgb:T(t,n),yours:!0};let s=(r.h+l+360)%360,c=o*L(r.L,s);return{name:o>0?_(s):w(k(r.L,c,s,B)),rgb:k(r.L,c,s,n),yours:!1}}).sort((l,s)=>Number(s.yours)-Number(l.yours))}function Lt(t,e,n){let r=b(t).h+e.hue,a=Math.max(0,yt*(1+e.saturation/100));return D(C(A(wt,e.brightness),a,r),n)}function Ot(t,e,n=B,r=$){let a=lt(r);return{rows:(e==="full"?ut(t,n):St(t,e,n)).map(({name:l,role:s,rgb:c,yours:h})=>({name:l,...s?{role:s}:{},steps:Y(D(c,r),n.contrast,a),yours:h})),neutral:Y(Lt(t,n,r),n.contrast,a)}}var M=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),E=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"colour",y='font-family="Inter"',O=t=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`;function mt(t){let e=t==="dark";return{ink:e?"#FAFAFA":"#111111",grey:e?"#A1A1AA":"#71717A",edge:e?"#FFFFFF":"#000000",paper:e?"#18181B":"#FFFFFF"}}var Mt=`<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 I(t,e,n,r="light"){let{ink:a,grey:o,edge:i,paper:l}=mt(r),s=n.length>8?64:104,c=10,h=48+n.length*s+Math.max(0,n.length-1)*c,p=84+s+56,f=s>80?12:10,g=`<text id="title" x="24" y="38" ${y} font-size="15" font-weight="600" fill="${a}">${M(t)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${o}">${M(e)}</text>`,d=n.map((u,S)=>`<g id="${E(u.id)}" transform="translate(${24+S*(s+c)} 80)">`+(u.alpha===void 0?"":`<rect id="checker" width="${s}" height="${s}" rx="${f}" fill="url(#checker)"/>`)+`<rect id="swatch" width="${s}" height="${s}" rx="${f}" fill="${u.hex}"`+(u.alpha===void 0?"":` fill-opacity="${u.alpha.toFixed(3)}"`)+` stroke="${i}" stroke-opacity="0.08"/><text id="name" x="1" y="${s+22}" ${y} font-size="13" font-weight="600" fill="${a}">${M(u.name)}</text><text id="value" x="1" y="${s+40}" ${y} font-size="11" fill="${o}">${M(u.value)}</text></g>`).join(`
|
|
5
|
-
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${p}" viewBox="0 0 ${h} ${p}">
|
|
6
|
-
`+(n.some(u=>u.alpha!==void 0)?Mt:"")+`<g id="${E(t)}">
|
|
7
|
-
<rect id="card" width="${h}" height="${p}" rx="0" fill="${l}"/>
|
|
8
|
-
${g}
|
|
9
|
-
${d}
|
|
10
|
-
</g>
|
|
11
|
-
</svg>`}function Ht(t,e,n="light",r){let a=t.replace(/\.[^.]+$/,""),o=e.length;return I(t,r?`${o} shade${o===1?"":"s"} of ${r}`:`${o} colour${o===1?"":"s"}, most of the image first`,e.map((i,l)=>({id:`${a}-${l+1}`,name:i.hex,value:X(i.rgb),hex:i.hex})),n)}function N(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=$;return t.start===e.start&&t.end===e.end?"50\u2013950":`Tailwind ${t.start}\u2013${t.end}`}function Pt(t,e,n="light",r=$){let a=w(t);return I(O(a),`from ${x(t)} \xB7 ${N(r)} in OKLCH`,e.map(o=>({id:`${a}-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),n)}function Dt(t,e,n,r=$,a="light"){let{ink:o,grey:i,edge:l,paper:s}=mt(a),c=`${O(w(t))} palette`,h=`from ${x(t)} \xB7 ${ct[n]} \xB7 ${N(r)} in OKLCH`,p=[...e.rows.map(m=>({name:m.name,steps:m.steps})),{name:"neutral",steps:e.neutral}],f=p[0]?.steps.map(m=>m.step)??[],g=44,d=6,u=g+10,S=92,z=24+Math.max(92,...p.map(m=>m.name.length*8+12)),gt=z+f.length*g+Math.max(0,f.length-1)*d+24,U=Math.max(gt,48+Math.ceil(h.length*6.5)),j=S+p.length*u+24+10,pt=`<text id="title" x="24" y="38" ${y} font-size="15" font-weight="600" fill="${o}">${M(c)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${i}">${M(h)}</text>`,ft=f.map((m,F)=>`<text id="step-${m}" x="${z+F*(g+d)+1}" y="${S-10}" ${y} font-size="11" font-weight="600" fill="${i}">${m}</text>`).join(""),dt=p.map((m,F)=>{let J=S+F*u+(F===p.length-1?10:0),Q=E(m.name);return`<g id="${Q}"><text id="name" x="24" y="${J+g/2+4}" ${y} font-size="13" font-weight="600" fill="${o}">${M(m.name)}</text>`+m.steps.map((V,bt)=>`<g id="${Q}-${V.step}"><rect id="swatch" x="${z+bt*(g+d)}" y="${J}" width="${g}" height="${g}" rx="8" fill="${V.hex}" stroke="${l}" stroke-opacity="0.08"/></g>`).join("")+"</g>"}).join(`
|
|
12
|
-
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${U}" height="${j}" viewBox="0 0 ${U} ${j}">
|
|
13
|
-
<g id="${E(c)}">
|
|
14
|
-
<rect id="card" width="${U}" height="${j}" rx="0" fill="${s}"/>
|
|
15
|
-
${pt}
|
|
16
|
-
<g id="steps">${ft}</g>
|
|
17
|
-
${dt}
|
|
18
|
-
</g>
|
|
19
|
-
</svg>`}function _t(t,e,n,r="light",a=$){return I(`${O(w(t))} neutral`,`from ${x(t)} \xB7 ${n} tint \xB7 ${N(a)} in OKLCH`,e.map(o=>({id:`neutral-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),r)}function Kt(t,e,n,r="light",a=$){let o=w(t);return I(`${O(o)} alpha`,`from ${x(t)} \xB7 over ${n} \xB7 ${N(a)}`,e.map(i=>({id:`${o}-alpha-${i.step}`,name:String(i.step),value:i.hex8,hex:x(i.rgb),alpha:i.a})),r)}async function Qt(t,e=192){let n=await it(t);if(n.kind!=="image")throw et(t,`a ${Z[n.format].label}`);let r=n.format==="heic";if(r&&!await at())throw nt(t);let a=r?await st(t):void 0;try{let i=(await ot())(a?.path??t,{animated:!1}),{data:l,info:s}=await(r?i:i.rotate()).resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:n,pixels:{width:s.width,height:s.height,rgba:new Uint8Array(l.buffer,l.byteOffset,l.length)}}}catch(o){throw tt(o)?o:rt(t,o)}finally{await a?.cleanup()}}export{Tt as a,ct as b,B as c,At as d,Et as e,Ot as f,I as g,Ht as h,Pt as i,Dt as j,_t as k,Kt as l,Qt as m};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as P,d as R,e as B}from"./chunk-A6RK5ALT.js";import{a as w,b as I,c as k,d as $,e as O,f as m}from"./chunk-TMQDQLY7.js";import{e as h}from"./chunk-EHARO6IS.js";import{i as x}from"./chunk-6L6C3GJU.js";import{Y as y,Z as C,_ as v,b as p}from"./chunk-3UEQ2OX6.js";import{a as f}from"./chunk-J7FLFHQJ.js";import{a as l}from"./chunk-GKECNCKO.js";import{a as c}from"./chunk-M66BUNYO.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-4VETUGMN.js");return e((await r()).prefs.defaultOutput)}function F(t){if(t.pasteboard)return t.pasteboard;if(!w())throw C();return I()}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 k(o,e.root);if(!a)throw y((await o.peek()).text?"text":"nothing");let s=await x(a.source),n=t.target??s.format,b=E(t,a,s.format,n),i=await R(b,r),g=i.results[0];if(!g||i.failures.length>0)return{report:i,status:"failed"};let u=g.job.outputs[0],d={report:i,output:u,source:{format:s.format,bytes:s.bytes},target:n};if(await $(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-4VETUGMN.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 ${P(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 O(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 B(e.report,r);if(r.json){let o={...h(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{b as v,d as a,e as $,g as B,i as Q}from"./chunk-LNB5D67B.js";import{a as S}from"./chunk-BZXDNDPG.js";import{a as J,j as E,l as I,m as N}from"./chunk-QR6QHTC3.js";import{a as q,b as k,d as C}from"./chunk-6L6C3GJU.js";import{d as M,k as T,s as y}from"./chunk-KAHWYWNT.js";import{b as R,e as d,g as f,h as F,j,k as D,l as g,m as s}from"./chunk-EXLXSKRH.js";import{F as l,t as w}from"./chunk-3UEQ2OX6.js";import{a as u,c as P}from"./chunk-M66BUNYO.js";var b=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function Pt(t,e){let n=J(t);return n.includes(e)?void 0:w(t,e,n)}function _(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var G=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:u.png.hint}]}),pt=t=>t===1?"sharp":`${t}x`,ut=t=>t===1||t===3||t===4?t:2,X={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7, 3\xD7 or 4\xD7",requires:"boost",appliesTo:t=>b(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"3",label:"3\xD7",hint:"three times the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},G()],plan(t,e){let n=b(t);if(!n)return[];let o=_(e),r=ut(Number(e.scale??2));return n.map(i=>({op:"boost",sources:[i],outputs:[d({sourcePath:i.path,target:o.target,suffix:pt(r),...o.output===void 0?{}:{output:o.output},...o.roots?.get(i.path)===void 0?{}:{sourceRoot:o.roots.get(i.path)}})],scale:r,target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}},H={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>b(t)!==void 0,unavailable:()=>"images only",options:()=>[G()],plan(t,e){let n=b(t);if(!n)return[];let o=_(e);return n.map(r=>({op:"remove-background",sources:[r],outputs:[d({sourcePath:r.path,target:o.target,suffix:"cutout",...o.output===void 0?{}:{output:o.output},...o.roots?.get(r.path)===void 0?{}:{sourceRoot:o.roots.get(r.path)}})],target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}};import{dirname as ct}from"node:path";var mt=t=>u[t.format].media==="video",dt=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,lt=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,ft="-small",c={min:30,max:100,step:35},gt=t=>{let e=Math.ceil((t-c.min)/c.step);return Math.min(c.max,c.min+Math.max(0,e)*c.step)},U={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{if(t.length===1&&t[0]?.kind==="media")return!0;let e=dt(t);if(e!==void 0){let o=u[e.format];return o.lossy||o.quantisable===!0}return(lt(t)?.images?.compressible??0)>0},options(t,e,n){let o=t[0];if(!o)return[];let r=[{kind:"select",id:"mode",label:`Compress ${S(o.path)??"this file"}`,choices:[o.kind==="media"?{value:"quality",label:"By quality"}:{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality"&&o.kind==="media"&&!mt(o))r.push({kind:"slider",id:"bitrate",label:"Quality",min:32,max:320,step:32,default:96});else if(e.mode==="quality"){let i=o.kind==="image"&&u[o.format].quantisable===!0;r.push(i?{kind:"slider",id:"quality",label:"Quality",...c,default:gt(n.quality),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality})}else if(e.mode==="size")r.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return r;return r.push(v(o,n)),r},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw l(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let o=t[0];if(!o)return[];let r=(S(o.path)??"file").replace(/\.[^.]+$/,""),i=typeof e.destination=="string"?e.destination:ct(o.path),p=o.kind==="media"?$(o.format):o.format,st=`${i}/${R(r,`${ft}${P(p)}`)}`,z=o.kind==="media"?B(e):void 0;return[{op:"convert",sources:[o],target:p,outputs:[st],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0},...z?{media:z}:{}}}]}};function bt(t,e){if(e.crop){let n=T(e.crop.aspect);if(!e.resize)return n;let o=e.crop.box??M(t,e.crop.aspect);return`${n}-${I(y(o,e.resize))}`}return e.trim&&e.resize?`trimmed-${N(e.resize)}`:e.resize?I(y(t,e.resize)):"trimmed"}function ht(t,e){if(e.trim&&e.crop)throw new Error("planEdit cannot trim and crop the same image");return t.map(n=>{let o=e.target??E(n),r={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{},...e.crop?{crop:e.crop}:{}},i=e.roots?.get(n.path),p=d({sourcePath:n.path,target:o,suffix:bt(n,e),...e.output===void 0?{}:{output:e.output},...i===void 0?{}:{sourceRoot:i}});return{op:"convert",sources:[n],outputs:[s(p,a(e.destination),a(e.name))],target:o,options:r}})}var x=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,yt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),K=t=>typeof t=="object"&&t!==null&&"aspect"in t&&typeof t.aspect=="object"&&t.aspect!==null&&"w"in t.aspect&&"h"in t.aspect;function A(t,e,n,o){return{id:t,label:e,verb:n,hint:o,appliesTo:r=>x(r)?.every(i=>t==="resize"||i.frames<=1)===!0,unavailable:r=>x(r)?"animated":"images only",options:()=>[],plan(r,i){let p=x(r);return p?t==="crop"&&!K(i.crop)?[]:ht(p,{trim:t==="trim"||i.trim===!0,...yt(i.resize)?{resize:i.resize}:{},...K(i.crop)?{crop:i.crop}:{},...typeof i.target=="string"?{target:i.target}:{},...typeof i.output=="string"?{output:i.output}:{},...i.roots instanceof Map?{roots:i.roots}:{},destination:i.destination,name:i.name,background:typeof i.background=="string"?i.background:"#ffffff",keepMetadata:i.keepMetadata===!0,...typeof i.quality=="number"?{quality:i.quality}:{}}):[]}}}var L=A("trim","Trim edges","Trimming edges","cut empty borders"),V=A("resize","Resize","Resizing","smaller or larger"),W=A("crop","Crop to shape","Cropping","change the shape");var h=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,Y={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:t=>(h(t)?.pages??0)>1,unavailable:t=>h(t)===void 0?"one PDF at a time":"only one page",options(t){let e=h(t);return e?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${e.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(t,e){let n=h(t);if(!n)return[];let o=Array.isArray(e.cuts)?e.cuts:[],r=C(o,n.pages).length,i=g(F(n.path,r),a(e.destination),a(e.name));return[{op:"split",sources:[n],outputs:i,cuts:o}]}};function Xt(t){return Array.from({length:Math.max(0,t-1)},(e,n)=>n)}function Ht(t,e){if(!Number.isInteger(e)||e<1)throw l("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let o=e;o<t;o+=e)n.push(o-1);return n}var m=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0;function Z(t,e){return Array.isArray(e.pages)?k(e.pages):typeof e.pages=="string"?k(q(e.pages,t.pages)):[]}var tt=t=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${t.pages}`}),et={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:t=>m(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=m(t);return e?[tt(e),{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(t,e){let n=m(t);if(!n)return[];let o=Z(n,e),r=e.separate==="many";return[{op:"extract",sources:[n],outputs:g(j(n.path,o,r),a(e.destination),a(e.name)),pages:o,separate:r}]}},ot={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:t=>m(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=m(t);return e?[tt(e)]:[]},plan(t,e){let n=m(t);return n?[{op:"delete",sources:[n],outputs:[s(f(n.path,"trimmed"),a(e.destination),a(e.name))],pages:Z(n,e)}]:[]}};var O=t=>t.filter(e=>e.kind==="document"&&e.format==="pdf"),nt={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:t=>O(t).length>=2&&O(t).length===t.length,unavailable:t=>O(t).length!==t.length?"PDFs only":"needs 2+ files",options:()=>[],plan(t,e){let n=s(D(t.map(o=>o.path)),a(e.destination),a(e.name));return[{op:"merge",sources:t,outputs:[n]}]}};var it=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,rt={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:t=>it(t)!==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(t,e){let n=it(t);if(!n)return[];let r=Number(e.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[s(f(n.path,"rotated"),a(e.destination),a(e.name))],turns:r}]}};var at=[Q,U,nt,Y,et,ot,rt,L,V,W],de=at.filter(t=>!["convert","compress","trim","resize","crop"].includes(t.id)),kt=[X,H];function le(t,e=new Set){return[...at,...kt.filter(n=>n.requires&&e.has(n.requires))].filter(n=>n.appliesTo(t))}function fe(t,e){return t.appliesTo(e)?void 0:t.unavailable?.(e)}export{Pt as a,X as b,H as c,U as d,ht as e,L as f,V as g,W as h,rt as i,Y as j,Xt as k,Ht as l,at as m,de as n,le as o,fe as p};
|
|
@@ -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 S,d as A,e as R,f as T,g}from"./chunk-QVACE4IE.js";import{F as E}from"./chunk-3UEQ2OX6.js";var y={set:"tailwind",start:50,end:950,count:11},O=["tailwind","even","radix"],v=[0,50,100,150,200,250,300,350,400,450],D=[550,600,650,700,750,800,850,900,950,1e3],I=Array.from({length:19},(e,n)=>n+3),$=[20,50,100,150,200,260,330,420,500,560,750,920],N=8;function P({set:e,start:n,end:r,count:o}){if(!O.includes(e))return`The set must be tailwind, even or radix; got ${e}.`;if(e!=="radix"){if(!v.includes(n))return n%50===0?`The start must be from 0 to 450, so the colour (500) stays in the scale; got ${n}.`:`The start must be a multiple of 50; got ${n}.`;if(!D.includes(r))return r%50===0?`The end must be from 550 to 1000, so the colour (500) stays in the scale; got ${r}.`:`The end must be a multiple of 50; got ${r}.`;if(e==="even"&&!I.includes(o))return`An even set has 3 to 21 steps; got ${o}.`}}function d(e){let{set:n,start:r,end:o,count:a}=e;if(n==="radix")return $.map((t,s)=>({step:s+1,at:t}));if(n==="tailwind"){let t=new Set([r,o,500]);for(let s=Math.ceil((r+1)/100)*100;s<o;s+=100)t.add(s);return[...t].sort((s,u)=>s-u).map(s=>({step:s,at:s}))}let i=a-1,f=Math.round(i*(500-r)/(o-r)),c=Math.max(1,Math.min(i-1,f)),p=i-c,b=[];for(let t=0;t<=c;t++)b.push(r+(500-r)*t/c);for(let t=1;t<=p;t++)b.push(500+(o-500)*t/p);for(let t of[10,5,1]){let s=b.map(u=>Math.round(u/t)*t);if(new Set(s).size===s.length)return b.map((u,l)=>({step:s[l],at:u}))}return b.map(t=>({step:t,at:t}))}function _(e){return d(e).map(n=>n.step)}var z=_(y);function K(e){return e.set==="radix"?N:d(e).findIndex(n=>n.at===500)}var W=[[50,1],[100,.86],[200,.68],[300,.46],[400,.22],[500,0]],F=[[500,0],[600,.2],[700,.4],[800,.6],[900,.8],[950,1]];function w(e,n){for(let r=1;r<e.length;r++){let[o,a]=e[r-1],[i,f]=e[r];if(n<=i)return a+(f-a)*(n-o)/(i-o)}return e[e.length-1][1]}var H=.995,U=.35,j=5e-4;function Y(e,n=y){let r=P(n);if(r)throw E(r,"Try: Tailwind, from 50 to 950.");let{L:o,C:a,h:i}=T(S(e)),f=a<j,c=Math.max(.975,o),p=o<.16?.42*o:Math.max(.16,.42*o);return d(n).map(({step:b,at:t})=>{if(t===500)return{step:b,at:t,rgb:{...e},hex:h(e),reference:!0};let s,u;if(t>=50&&t<500){let m=w(W,t);s=o+(c-o)*m,u=a*(1-.88*m)}else if(t<50){let m=(50-t)/50;s=c+(Math.max(H,c)-c)*m,u=a*.12*(1-m)}else if(t<=950){let m=w(F,t);s=o-(o-p)*m,u=a*(1-.45*m)}else{let m=(t-950)/50;s=p*(1-U*m),u=a*.55*(1-.4*m)}for(f&&(u=0);u>0&&!R(g({L:s,C:u,h:i}));)u-=.002;let l=A(g({L:s,C:Math.max(0,u),h:i}));return{step:b,at:t,rgb:l,hex:h(l),reference:!1}})}var x=e=>{let n=e/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4},M=({r:e,g:n,b:r})=>.2126*x(e)+.7152*x(n)+.0722*x(r);function L(e,n){let[r,o]=[M(e),M(n)].sort((a,i)=>i-a);return(r+.05)/(o+.05)}function J(e){return e>=7?"AAA":e>=4.5?"AA":e>=3?"large":"fails"}var k={r:255,g:255,b:255},B={r:0,g:0,b:0},C=e=>Math.floor(e*10)/10;function Q(e){return{white:C(L(e,k)),black:C(L(e,B))}}export{y as a,O as b,v as c,D as d,I as e,d as f,_ as g,K as h,Y as i,L as j,J as k,Q as l};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as h}from"./chunk-YWKMG5WO.js";import{i as P}from"./chunk-6L6C3GJU.js";import{d as y,ga as s}from"./chunk-3UEQ2OX6.js";import{mkdtemp as F,rm as x}from"node:fs/promises";import{tmpdir as z}from"node:os";import{join as v}from"node:path";var f={background:"#ffffff",keepMetadata:!1};function w(e,r,o){switch(e.kind){case"cut":return{op:"convert",sources:[r],outputs:[o],target:"png",options:{...f,...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}};case"cutout":return{op:"remove-background",sources:[r],outputs:[o],target:"png",options:f};case"boost":return{op:"boost",sources:[r],outputs:[o],scale:e.scale,target:"png",options:f};case"encode":return{op:"convert",sources:[r],outputs:[o],target:e.target,options:{...f,...e.background?{background:e.background}:{},...e.quality!==void 0?{quality:e.quality}:{},...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}}}}async function C(e,r,o,n){let E=n.probe??P,l=await F(v(z(),"forge-preset-")),I={force:n.force,...n.signal?{signal:n.signal}:{},...n.onEvent?{onEvent:n.onEvent}:{}};try{let i=e;for(let[d,t]of r.entries()){let u=d===r.length-1,g=u?o:v(l,`${d}.png`),a=await h([w(t,i,g)],{...I,...u?{}:{force:!0},...u&&t.kind==="encode"&&t.maxBytes?{targetBytes:t.maxBytes}:{}});if(a.cancelled)return{kind:"cancelled"};let m=a.refusals[0];if(m)return{kind:"refused",error:m.error};let p=a.unreachable[0];if(p)return{kind:"unreachable",entry:p};let b=a.failures[0];if(b)return{kind:"failed",pass:t,error:b.error};let c=a.results[0];if(!c)return{kind:"failed",pass:t,error:s(e.path,"no result")};if(u){let j=c.job.op==="convert"?{...c.job,sources:[e]}:c.job;return{kind:"done",result:{...c,job:j}}}let k=await E(g);if(k.kind!=="image")return{kind:"failed",pass:t,error:s(e.path,"not an image")};i=k}return{kind:"failed",pass:{kind:"encode",target:e.format},error:s(e.path,"nothing to run")}}catch(i){return{kind:"failed",pass:r[r.length-1]??{kind:"encode",target:e.format},error:y(i)?i:s(e.path,i)}}finally{await x(l,{recursive:!0,force:!0})}}export{C as a};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as gt,b as q,d as yt}from"./chunk-SMBK6BTC.js";import{$ as pt,C as ct,F as B,K as ft,X as dt,ba as ut,c as k,ca as mt,d as C,da as lt,e as et,ea as wt,f as rt,g as W,ga as U,h as it,i as nt,j as ot,k as at,l as st,o as I,u as ht,v as j}from"./chunk-3UEQ2OX6.js";import{a as w}from"./chunk-M66BUNYO.js";import{constants as Jt}from"node:fs";import{access as Vt,readFile as Bt,rm as Xt,stat as Zt,writeFile as Gt}from"node:fs/promises";import{dirname as Kt}from"node:path";var Ft=[{w:1,h:1,label:"1:1"},{w:4,h:5,label:"4:5"},{w:16,h:9,label:"16:9"},{w:9,h:16,label:"9:16"}],ue=20,me=10,E=t=>Math.max(1,Math.round(t)),N=(t,e,r)=>Math.min(Math.max(t,e),r);function A(t,e){let r=E(t.width*e.h/e.w),[i,n]=r<=t.height?[t.width,r]:[Math.min(t.width,E(t.height*e.w/e.h)),t.height];return{left:Math.floor((t.width-i)/2),top:Math.floor((t.height-n)/2),width:i,height:n}}var zt=(t,e)=>e.width===t.width&&e.height===t.height;function le(t){return Ft.filter(e=>!zt(t,A(t,e)))}function we(t,e,r,i){let n=A(t,e),o,a;return e.w>=e.h?(o=E(n.width*i/100),a=Math.min(t.height,E(o*e.h/e.w))):(a=E(n.height*i/100),o=Math.min(t.width,E(a*e.w/e.h))),{left:N(Math.round(r.x-o/2),0,t.width-o),top:N(Math.round(r.y-a/2),0,t.height-a),width:o,height:a}}function ge(t,e,r,i){return{...e,left:N(e.left+r,0,t.width-e.width),top:N(e.top+i,0,t.height-e.height)}}function ye(t,e){return{x:e.width<t.width,y:e.height<t.height}}function xe(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}function be(t,e){return Math.round(e.width*e.height*100/(t.width*t.height))}var J=t=>`${t.w}:${t.h}`,Se=t=>`cropped-${t.w}x${t.h}`;function Ie(t){let e=/^(\d{1,3}):(\d{1,3})$/.exec(t.trim()),r=Number(e?.[1]),i=Number(e?.[2]);if(!e||r<1||r>100||i<1||i>100)throw B(`"${t}" is not a shape; it takes two whole numbers from 1 to 100, as W:H.`,"Try --crop 1:1 or --crop 16:9.");return{w:r,h:i}}function Me(t,e,r){let i=r*2,n=new Uint8Array(e*i*3),o=t.alpha?new Uint8Array(e*i):void 0,a=t.width/e,d=t.height/i;for(let s=0;s<i;s++){let h=s*d,l=h+d;for(let p=0;p<e;p++){let f=p*a,u=f+a,x=0,m=0,g=0,c=0,y=0;for(let b=Math.floor(h);b<Math.min(Math.ceil(l),t.height);b++){let L=Math.min(b+1,l)-Math.max(b,h);for(let O=Math.floor(f);O<Math.min(Math.ceil(u),t.width);O++){let Y=b*t.width+O,tt=(Math.min(O+1,u)-Math.max(O,f))*L,R=tt*(t.alpha?(t.alpha[Y]??0)/255:1),H=Y*3;x+=(t.rgb[H]??0)*R,m+=(t.rgb[H+1]??0)*R,g+=(t.rgb[H+2]??0)*R,c+=R,y+=tt}}let z=s*e+p;c>0&&n.set([x/c,m/c,g/c].map(Math.round),z*3),o&&y>0&&(o[z]=Math.round(c*255/y))}}return{cols:e,dotRows:i,rgb:n,...o?{alpha:o}:{}}}function Oe(t){if(w[t].hasAlpha)return;let e=Object.keys(w).filter(r=>w[r].hasAlpha&&r!=="heic").join(", ");return B(`${w[t].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${e}.`)}var xt="1.1.0";function Rt(t,e){let r=t.split(".").map(n=>Number.parseInt(n,10)||0),i=e.split(".").map(n=>Number.parseInt(n,10)||0);for(let n=0;n<Math.max(r.length,i.length);n++){let o=(r[n]??0)-(i[n]??0);if(o!==0)return o>0}return!0}function V(t){return t!==void 0&&Rt(t,xt)?[2,3,4]:[2,4]}function Be(t,e,r){if(t===1||V(e).some(n=>n===t))return;if(r!==void 0&&V(r).some(n=>n===t))return ft("boost",`boost ${t}\xD7`,e,xt);let i=V(e).map(n=>`--boost ${n}`);return B(`No released boost makes ${t}\xD7 yet.`,`Try ${i.slice(0,-1).join(", ")} or ${i.at(-1)}.`)}var kt=16384,Ct=1e8;function bt(t,e,r){let i=Math.max(t,e)*r;if(i>kt)return{side:i};let n=t*r*e*r;if(n>Ct)return{megapixels:Math.round(n/1e6)}}var v=t=>Math.max(1,Math.round(t));function X(t,e){return"percent"in e?{width:v(t.width*e.percent/100),height:v(t.height*e.percent/100)}:"width"in e?{width:v(e.width),height:v(t.height*e.width/t.width)}:{width:v(t.width*e.height/t.height),height:v(e.height)}}function St(t){return bt(t.width,t.height,1)}import{execFile as Nt}from"node:child_process";import{randomBytes as Dt}from"node:crypto";import{mkdtemp as _t,open as It,readFile as $t,rm as Z}from"node:fs/promises";import{tmpdir as Mt}from"node:os";import{join as _}from"node:path";import{promisify as Lt}from"node:util";function S(t){let e;return()=>(e??=t(),e)}var M=S(async()=>(await import("sharp")).default),ze=S(()=>import("./es-T2U7NBLD.js")),Re=S(()=>import("@hyzyla/pdfium")),ke=S(async()=>(await import("./lib-TPEJ5CJJ.js")).default),Ce=S(async()=>(await import("./word-OGQ2KZAJ.js")).default),Ue=S(async()=>(await import("./adm-zip-SQKLKBDP.js")).default),Ne=S(async()=>(await import("./cfb-V6M2PYOD.js")).default);async function Ut(){let t=Object.getOwnPropertyDescriptor(globalThis,"localStorage");if(!t?.configurable)return import("./dist-J2V6ITHG.js");Object.defineProperty(globalThis,"localStorage",{value:void 0,configurable:!0,enumerable:t.enumerable??!1,writable:!0});try{return await import("./dist-J2V6ITHG.js")}finally{Object.defineProperty(globalThis,"localStorage",t)}}var De=S(Ut);var G=Lt(Nt),Et=async()=>({...await import("./paths-5XI5L4KW.js"),...await import("./run-6BK4REXK.js")}),T;async function P(t=process.platform){if(t==="win32")return await(await Et()).installed("heic")!==void 0;if(T!==void 0)return T;try{await G("/usr/bin/sips",["--help"],{timeout:5e3}),T=!0}catch{T=!1}return T}async function $(t,e=process.platform){if(e==="win32")return Ht(t);let r=_(Mt(),`forge-heic-${Dt(8).toString("hex")}.png`),i=async()=>{await Z(r,{force:!0}).catch(()=>{})};try{return await G("/usr/bin/sips",["-s","format","png",t,"--out",r],{timeout:12e4}),{path:r,cleanup:i}}catch(n){throw await i(),n}}async function At(t){let{installed:e,runExtension:r}=await Et(),i=await e("heic");if(i===void 0)throw I(t,"win32");return{ext:i,runExtension:r}}async function Ht(t){let e=await _t(_(Mt(),"forge-heic-")),r=async()=>{await Z(e,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:i,runExtension:n}=await At(t),o=_(e,"decoded.rgba"),a=_(e,"decoded.png"),{width:d,height:s}=await n(i,["--in",t,"--out",o],{subject:t});return await(await M())(await $t(o),{raw:{width:d,height:s,channels:4}}).png().toFile(a),await Z(o,{force:!0}),{path:a,cleanup:r}}catch(i){throw await r(),i}}var Wt=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),jt=new Set(["avif","avis"]);async function vt(t){let e;try{e=await It(t,"r")}catch{return!1}try{let r=Buffer.alloc(64),{bytesRead:i}=await e.read(r,0,64,0);if(i<12||r.toString("latin1",4,8)!=="ftyp")return!1;let n=Math.min(r.readUInt32BE(0),i),o=[];for(let a=8;a+4<=n;a+=4)o.push(r.toString("latin1",a,a+4));return o.some(a=>jt.has(a))?!1:o.some(a=>Wt.has(a))}catch{return!1}finally{await e.close().catch(()=>{})}}async function Ot(t,e=process.platform){if(e==="win32"){let{ext:a,runExtension:d}=await At(t),s=await d(a,["--info","--in",t],{subject:t});return{width:s.width,height:s.height,hasAlpha:s.hasAlpha??!0}}let{stdout:r}=await G("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",t],{timeout:3e4}),i=Number(/pixelWidth:\s*(\d+)/.exec(r)?.[1]??0),n=Number(/pixelHeight:\s*(\d+)/.exec(r)?.[1]??0),o=await qt(t);return{width:o?n:i,height:o?i:n,hasAlpha:/hasAlpha:\s*yes/i.test(r)}}function*D(t,e,r){let i=e;for(;i+8<=r;){let n=t.readUInt32BE(i),o=8;if(n===1&&i+16<=r?(n=Number(t.readBigUInt64BE(i+8)),o=16):n===0&&(n=r-i),n<o)return;yield{type:t.toString("latin1",i+4,i+8),start:i+o,end:Math.min(i+n,r)},i+=n}}async function qt(t){let e=await It(t,"r");try{let r=Buffer.alloc(262144),{bytesRead:i}=await e.read(r,0,r.length,0),n=[...D(r,0,i)].find(c=>c.type==="meta");if(!n)return!1;let o=[...D(r,n.start+4,n.end)],a=o.find(c=>c.type==="pitm"),d=o.find(c=>c.type==="iprp");if(!a||!d)return!1;let s=r.readUInt8(a.start)===0?r.readUInt16BE(a.start+4):r.readUInt32BE(a.start+4),h=[...D(r,d.start,d.end)],l=h.find(c=>c.type==="ipco"),p=h.find(c=>c.type==="ipma");if(!l||!p)return!1;let f=new Map;if([...D(r,l.start,l.end)].forEach((c,y)=>{c.type==="irot"&&f.set(y+1,r.readUInt8(c.start)&3)}),f.size===0)return!1;let u=r.readUInt8(p.start),x=(r.readUInt8(p.start+3)&1)===1,m=p.start+4,g=r.readUInt32BE(m);m+=4;for(let c=0;c<g&&m<p.end;c++){let y=u<1?r.readUInt16BE(m):r.readUInt32BE(m);m+=u<1?2:4;let z=r.readUInt8(m);m+=1;for(let b=0;b<z;b++){let L=x?r.readUInt16BE(m)&32767:r.readUInt8(m)&127;if(m+=x?2:1,y===s&&(f.get(L)??0)%2===1)return!0}}return!1}catch{return!1}finally{await e.close().catch(()=>{})}}var Qt=new Set(["jpeg","png","webp","avif","heic","gif","tiff"]),Yt=new Set(["jpeg","png","webp","avif","gif","tiff"]),te={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function ee(t,e){if(e.format==="heif")return e.compression==="av1"?"avif":"heic";let r=te[e.format??""];if(!r)throw st(t,e.format??"an unknown format");return r}async function re(t){let e;try{e=await Zt(t)}catch(n){let o=n.code;throw o==="ENOENT"?et(t):o==="EACCES"||o==="EPERM"?W(t):o==="ENOTDIR"?it(t):o==="ELOOP"?nt(t):o==="ENAMETOOLONG"?ot(t):at(t,n)}if(!e.isFile())throw rt(t);try{await Vt(t,Jt.R_OK)}catch{throw W(t)}if(await vt(t)){if(!await P())throw I(t);let n;try{n=await Ot(t)}catch(o){throw j(t,"heic",o)}if(n.width===0||n.height===0)throw j(t,"heic",void 0);return{kind:"image",path:t,format:"heic",width:n.width,height:n.height,bytes:e.size,hasAlpha:n.hasAlpha,frames:1}}let r=await M(),i;try{i=await r(t).metadata()}catch(n){throw ht(t,n)}return{kind:"image",path:t,format:ee(t,i),width:i.autoOrient?.width??i.width??0,height:i.autoOrient?.height??i.height??0,bytes:e.size,hasAlpha:i.hasAlpha??!1,frames:i.pages??1}}function K(t,e,r,i){let n=r??w[e].defaultQuality;if(i&&w[e].quantisable)return ie(t,e,r,i);switch(e){case"jpeg":return t.jpeg({quality:n,mozjpeg:!0});case"webp":return t.webp({quality:n});case"avif":return t.avif({quality:n});case"png":return t.png({compressionLevel:9});case"gif":return t.gif();case"tiff":return t.tiff({compression:"deflate"});case"heic":throw new Error("heic 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(`${e} is not an image target; the capability graph should have prevented this`)}}function ie(t,e,r,{dither:i}){let n=r??100,o=i?1:0;return e==="gif"?t.gif({interFrameMaxError:Math.round(32*(100-n)/100),dither:o}):t.png({palette:!0,quality:n,dither:o,compressionLevel:9,effort:10})}var Q=(t,e)=>t.kind==="image"&&t.frames>1&&w[e].animatable;async function ne(t,e){let r=Kt(e);await q(e);let i=gt(e);try{return await Gt(i,t),await yt(i,e),t.length}catch(n){throw await Xt(i,{force:!0}).catch(()=>{}),ct(e,n)}}async function F(t,e,r,i,n,o){if(t.kind!=="image")throw new Error("pipelineFor received a non-image source");if(n===void 0&&t.format==="heic"&&!await P())throw I(t.path);let a=n===void 0&&t.format==="heic"?await $(t.path):void 0,d=async()=>{await a?.cleanup()},h=(await M())(n??a?.path??t.path,i?{animated:!0}:{});if(h=h.rotate(),r.trim&&(h=h.trim()),r.crop){if(!r.crop.box)throw new Error("pipelineFor needs the crop placed (run does it)");h=h.extract(r.crop.box)}if(r.resize){if(!o&&(r.trim||r.crop))throw new Error("pipelineFor needs the resolved size to resize a cut image");let l=o??X(t,r.resize);h=h.resize(l.width,l.height,{fit:"fill"})}return t.hasAlpha&&!w[e].hasAlpha&&(h=h.flatten({background:r.background})),h=r.keepMetadata?h.keepMetadata():h.keepIccProfile(),{pipeline:h,cleanup:d}}async function ar(t,e){let r={background:"#ffffff",keepMetadata:!1},{pipeline:i,cleanup:n}=await F(t,"png",r,!1);try{await i.png({compressionLevel:1}).toFile(e)}finally{await n()}}async function sr(t,e,r){let{pipeline:i,cleanup:n}=await F(t,e,r,Q(t,e));try{return await K(i,e,r.quality,r.compress).toBuffer()}finally{await n()}}async function oe(t){let e={width:t.width,height:t.height};if(t.frames>1)return{upright:e,trimmed:"animated"};if(t.format==="heic"&&!await P())throw I(t.path);let r=t.format==="heic"?await $(t.path):void 0;try{let i=await M(),{info:n}=await i(r?.path??t.path).rotate().trim().jpeg({quality:1}).toBuffer({resolveWithObject:!0});return n.width===e.width&&n.height===e.height?{upright:e,trimmed:"nothing"}:{upright:e,trimmed:{width:n.width,height:n.height}}}catch(i){throw C(i)?i:U(t.path,i)}finally{await r?.cleanup()}}var Tt=1024;async function ae(t){let e={background:"#ffffff",keepMetadata:!1},{pipeline:r,cleanup:i}=await F(t,"png",e,!1);try{let{data:n,info:o}=await r.resize(Tt,Tt,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0}),a=o.width*o.height,d=o.channels,s=new Uint8Array(a*3),h=new Uint8Array(a),l=!1;for(let p=0;p<a;p++){for(let f=0;f<3;f++)s[p*3+f]=n[p*d+(d>=4?f:0)]??0;h[p]=n[p*d+d-1]??255,h[p]!==255&&(l=!0)}return{size:{width:t.width,height:t.height},thumb:{width:o.width,height:o.height,rgb:s,...l?{alpha:h}:{}}}}catch(n){throw C(n)?n:U(t.path,n)}finally{await i()}}var Pt=128;async function se(t,e){let{thumb:r,size:i}=t,n=A(r,e),o=await M(),{info:a}=await o(he(r),{raw:{width:r.width,height:r.height,channels:3}}).resize(n.width,n.height,{fit:"cover",position:o.strategy.attention}).raw().toBuffer({resolveWithObject:!0}),d=A(i,e),s=Math.round(-(a.cropOffsetLeft??0)*i.width/r.width),h=Math.round(-(a.cropOffsetTop??0)*i.height/r.height);return{...d,left:Math.min(Math.max(s,0),i.width-d.width),top:Math.min(Math.max(h,0),i.height-d.height)}}function he(t){let{alpha:e}=t;if(!e)return t.rgb;let r=new Uint8Array(t.rgb.length);for(let i=0;i<r.length;i++){let n=(e[Math.floor(i/3)]??255)/255;r[i]=Math.round(Pt+((t.rgb[i]??0)-Pt)*n)}return r}async function ce(t,e){if(t.op!=="convert")throw new Error(`image engine cannot ${t.op}`);let r=t.sources[0],i=t.outputs[0];if(r.kind!=="image")throw new Error("the image engine cannot convert a document source");let n=w[t.target],o=[];e({phase:"reading"});let a=r.frames>1,d=Q(r,t.target);a&&!n.animatable&&o.push({code:"animation-flattened",message:`${k(r.path)} has ${r.frames} frames, and ${n.label} cannot animate. Only the first frame was converted.`});let s=t.options,h;if(s.trim||s.crop||s.resize){let f={width:r.width,height:r.height};if(s.trim&&s.crop)throw new Error("a job cannot both trim and crop");if(s.crop){if(a)throw wt(r.path);let{aspect:u}=s.crop,x=c=>c.width===r.width&&c.height===r.height,m=A(f,u),g=s.crop.box??(x(m)?m:await se(await ae(r),u));if(x(g)){if(!s.resize)throw lt(r.path,J(u));o.push({code:"nothing-cropped",message:`${k(r.path)} is already ${J(u)}; resized only.`});let{crop:c,...y}=s;s=y}else s={...s,crop:{aspect:u,box:g}},f={width:g.width,height:g.height}}if(s.trim){if(a)throw mt(r.path);let{trimmed:u}=await oe(r);if(u==="nothing"){if(!s.resize)throw ut(r.path);o.push({code:"nothing-trimmed",message:`${k(r.path)} has no empty edges; resized only.`})}else u!=="animated"&&(f=u)}if(s.resize&&(h=X(f,s.resize),St(h)))throw dt(r.path,h)}e({phase:"decoding"});let{pipeline:l,cleanup:p}=await F(r,t.target,s,d,void 0,h);try{await q(i),e({phase:"encoding"});let f=await K(l,t.target,s.quality,s.compress).toBuffer();if(s.compress&&f.length>=r.bytes)throw pt(r.path,r.bytes,f.length);e({phase:"writing"});let u=await ne(f,i);return{job:t,outputBytes:u,warnings:o}}catch(f){throw C(f)?f:U(r.path,f)}finally{await p()}}async function fe(t){if(t.format!=="heic")return Bt(t.path);if(!await P())throw I(t.path);let e=await $(t.path);try{return await Bt(e.path)}finally{await e.cleanup()}}async function de(t){if(t.op!=="convert")return;let e=w[t.target];if(!e.lossy&&!(e.quantisable&&t.options.compress))return;let r=t.sources[0];if(r.kind!=="image")return;let i=await fe(r);return{ladder:[{}],measure:async n=>{let{pipeline:o}=await F(r,t.target,n,Q(r,t.target),i);return(await K(o,t.target,n.quality,n.compress).toBuffer()).length}}}var hr={id:"image",reads:Qt,writes:Yt,ops:new Set(["convert"]),probe:re,run:ce,measurer:de};export{Ft as a,ue as b,me as c,A as d,le as e,we as f,ge as g,ye as h,xe as i,be as j,Se as k,Ie as l,Me as m,Oe as n,V as o,Be as p,kt as q,bt as r,X as s,St as t,S as u,M as v,ze as w,Re as x,ke as y,Ce as z,Ue as A,Ne as B,De as C,P as D,$ as E,vt as F,K as G,ne as H,ar as I,sr as J,oe as K,ae as L,se as M,hr as N};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{execFile as O,spawn as B}from"node:child_process";import{access as I,constants as T}from"node:fs/promises";import{join as A}from"node:path";import{promisify as K}from"node:util";function E(e){let[n,r]=(e??"").split("/").map(Number);return!n||!r?0:Math.round(n/r*100)/100}function R(e){let n=e.side_data_list?.find(t=>typeof t.rotation=="number")?.rotation,r=n!==void 0?-n:Number(e.tags?.rotate??0);return(Math.round(r/90)*90%360+360)%360}function S(e){let n=e,r=n.streams??[],t=r.find(o=>o.codec_type==="video"&&o.disposition?.attached_pic!==1),i=r.find(o=>o.codec_type==="audio"),a={duration:Number(n.format?.duration)||Math.max(0,...r.map(o=>Number(o.duration)||0))};if(t){let o=R(t),f=o===90||o===270,s=t.width??0,u=t.height??0;a.video={codec:t.codec_name??"",width:f?u:s,height:f?s:u,fps:E(t.avg_frame_rate)||E(t.r_frame_rate),rotation:o,hdr:t.color_transfer==="arib-std-b67"||t.color_transfer==="smpte2084"}}return i&&(a.audio={codec:i.codec_name??"",channels:i.channels??0,sampleRate:Number(i.sample_rate)||0}),a}var _=K(O);function $(e,n){let r=n.PATH??n.Path??"",t=e==="win32"?";":":",i=r.split(t).filter(Boolean);return e==="darwin"&&i.push("/opt/homebrew/bin","/usr/local/bin"),[...new Set(i)]}var L=e=>process.platform==="win32"?`${e}.exe`:e;async function N(e){try{return await I(e,T.X_OK),!0}catch{return!1}}function D(e){let n=new Set;for(let r of e.split(`
|
|
4
|
-
`)){let t=r.match(/^\s*[A-Z.|]{3,6}\s+(\S+)\s/);t?.[1]&&t[1]!=="="&&n.add(t[1])}return n}async function G(){try{let{installed:e}=await import("./paths-5XI5L4KW.js");return(await e("video"))?.dir}catch{return}}async function J(){let e=await G(),n=[...$(process.platform,process.env),...e?[e]:[]];for(let r of n){let t=A(r,L("ffmpeg")),i=A(r,L("ffprobe"));if(!await N(t)||!await N(i))continue;try{await _(t,["-hide_banner","-version"],{timeout:5e3})}catch{continue}let[m,a]=await Promise.all(["-encoders","-filters"].map(f=>_(t,["-hide_banner",f],{timeout:5e3,maxBuffer:4<<20}).then(({stdout:s})=>D(s)).catch(()=>{}))),o=m&&a?new Set([...m,...a]):void 0;return{ffmpeg:t,ffprobe:i,...o?{has:o}:{}}}}var h,y=null;function v(){return y?Promise.resolve(y.value):(h=(h??J()).then(n=>(n||(h=void 0),n)),h)}function U(e){y=e===null?null:{value:e},h=void 0}async function W(e,n){let r=n??await v();if(!r)throw new Error("ffmpeg is not installed");let{stdout:t}=await _(r.ffprobe,["-v","error","-print_format","json","-show_format","-show_streams",e],{timeout:3e4,maxBuffer:16*1024*1024});return S(JSON.parse(t))}async function Y(e,n,r){let t=r??await v();if(!t)return;let i=Math.max(0,n-15),{stdout:m}=await _(t.ffprobe,["-v","error","-select_streams","v:0","-skip_frame","nokey","-show_entries","frame=pts_time","-of","csv=p=0","-read_intervals",`${i}%${n+.01}`,e],{timeout:3e4,maxBuffer:4*1024*1024}),a=m.split(`
|
|
5
|
-
`).map(o=>Number.parseFloat(o)).filter(o=>Number.isFinite(o)&&o<=n+.001);return a.length?Math.max(...a):void 0}var k=4e3;async function ee(e,n,r,t={}){let i=t.tools??await v();if(!i)return null;let m=Math.max(1,Math.round(n*k)),a=Math.max(1,Math.ceil(m/r)),o=new Array(r).fill(0),f=0,s=Buffer.alloc(0);if(!await new Promise((p,d)=>{let c=B(i.ffmpeg,["-hide_banner","-nostdin","-loglevel","error","-i",e,"-map","0:a:0","-ac","1","-ar",String(k),"-f","s16le","-"],{stdio:["ignore","pipe","pipe"]}),b=()=>c.kill("SIGKILL");t.signal?.addEventListener("abort",b,{once:!0}),c.stdout.on("data",l=>{let w=s.length?Buffer.concat([s,l]):l,F=w.length-w.length%2;for(let x=0;x<F;x+=2){let P=Math.abs(w.readInt16LE(x)),M=Math.min(r-1,Math.floor(f/a));P>(o[M]??0)&&(o[M]=P),f++}s=w.subarray(F)}),c.stderr.resume(),c.on("error",d),c.on("close",l=>{t.signal?.removeEventListener("abort",b),t.signal?.aborted?d(t.signal.reason??new Error("aborted")):p(l===0&&f>0)})}))return null;let g=Math.max(1,...o);return o.map(p=>Math.sqrt(p/g))}async function te(e,n,r,t){await C(["-ss",String(Math.max(0,n)),"-i",e,"-frames:v","1","-y",r],{tools:t})}function j(e){let n;for(let r of e.matchAll(/out_time_us=(\d+)/g))n=Number(r[1])/1e6;return n}var q=4e3;async function C(e,n={}){let{signal:r,onTime:t}=n;if(r?.aborted)throw r.reason??new Error("aborted");let i=n.tools??await v();if(!i)throw new Error("ffmpeg is not installed");let a=["-hide_banner","-nostdin","-loglevel",n.report?"info":"error","-progress","pipe:1","-nostats",...e];return new Promise((o,f)=>{let s=B(i.ffmpeg,a,{stdio:["ignore","pipe","pipe"]}),u="",g=()=>s.kill("SIGKILL");r?.addEventListener("abort",g,{once:!0}),s.stdout.setEncoding("utf8");let p="";s.stdout.on("data",d=>{let c=p+d,b=c.lastIndexOf(`
|
|
6
|
-
`);p=c.slice(b+1);let l=j(c.slice(0,b+1));l!==void 0&&t?.(l)}),s.stderr.setEncoding("utf8"),s.stderr.on("data",d=>{u=(u+d).slice(-q)}),s.on("error",d=>{r?.removeEventListener("abort",g),f(d)}),s.on("close",d=>{r?.removeEventListener("abort",g),r?.aborted?f(r.reason??new Error("aborted")):d===0?o(u):f(new Error(u.trim()||`ffmpeg exited with ${d}`))})})}export{$ as a,D as b,v as c,U as d,W as e,Y as f,ee as g,te as h,j as i,C as j};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as A}from"./chunk-BZXDNDPG.js";import{b as w,e as m,l as R}from"./chunk-QR6QHTC3.js";import{a as P,b as l}from"./chunk-6L6C3GJU.js";import{d as k,k as O,s as M}from"./chunk-KAHWYWNT.js";import{c as x,d as I,e as c,i as z,m as F}from"./chunk-EXLXSKRH.js";import{F as S}from"./chunk-3UEQ2OX6.js";import{b as u,e as g}from"./chunk-AAXBN572.js";import{a as f,b as y}from"./chunk-M66BUNYO.js";import{dirname as J,join as E}from"node:path";var C="Same location",j="New subfolder";function L(e,t){return e===t?C:e===u("Desktop")?"Desktop":e===u("Downloads")?"Downloads":t!==void 0&&e===E(t,"converted")?j:A(e)||e}function T(e,t,n={}){return _(J(e.path),t,n)}function _(e,t,{subfolder:n=!1}={}){let i=g(t.defaultOutput),o=t.lastOutput?g(t.lastOutput):void 0,r=p=>({label:L(p,e),path:p}),s=[r(i),...o?[r(o)]:[],r(u("Desktop")),...e===void 0?[]:[{label:C,path:e}],r(u("Downloads")),...n&&e!==void 0?[{label:j,path:E(e,"converted")}]:[]],a=new Set,d=s.filter(p=>a.has(p.path)?!1:(a.add(p.path),!0));return{kind:"path",id:"destination",label:"Save to",default:i,presets:d,...o&&o!==i?{last:o}:{}}}var b=e=>typeof e=="string"&&e!==""?e:void 0;var B=-16;function dt(e){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[e]??e}var D=e=>e.length===1&&e[0]?.kind==="media"?e[0]:void 0,U=e=>e==="cut"||e==="mute"||e==="resize"||e==="crop"||e==="loudness";function Q(e,t){let n=t.media??{},i=e.facts?.video,o=[];return n.cut&&o.push("trimmed"),n.mute&&o.push("muted"),n.loudness!==void 0&&o.push("levelled"),n.speed!==void 0&&o.push(`${n.speed}x`),n.fps!==void 0&&o.push(`${n.fps}fps`),n.bitrate!==void 0&&o.push(`${n.bitrate}k`),t.crop&&o.push(O(t.crop.aspect)),t.resize&&o.push(i?R(M(i,t.resize)):"resized"),o.length===1?o[0]:"edited"}function W(e,t){return e.map(n=>{let i=t.target??n.format,o={background:"#ffffff",keepMetadata:!1};t.media&&Object.keys(t.media).length&&(o.media=t.media),t.resize&&(o.resize=t.resize);let r=n.facts?.video;t.crop&&r&&(o.crop={aspect:t.crop.aspect,box:t.crop.box??k(r,t.crop.aspect)});let s=t.roots?.get(n.path),a=c({sourcePath:n.path,target:i,suffix:Q(n,t),...t.output===void 0?{}:{output:t.output},...s===void 0?{}:{sourceRoot:s}});return{op:"convert",sources:[n],outputs:[F(a,b(t.destination),b(t.name))],target:i,options:o}})}function h(e){let t={},n=e.cut;return n&&typeof n.start=="number"&&(t.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),e.mute===!0&&(t.mute=!0),typeof e.speed=="number"&&(t.speed=e.speed),typeof e.fps=="number"&&(t.fps=e.fps),typeof e.bitrate=="number"&&(t.bitrate=e.bitrate),typeof e.loudness=="number"&&(t.loudness=e.loudness),Object.keys(t).length?t:void 0}var pt={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, resize, crop",appliesTo:e=>D(e)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(e,t){let n=D(e);if(!n||!U(t.tool))return[];let i=t.tool,o={...typeof t.output=="string"?{output:t.output}:{},destination:t.destination,name:t.name};if(i==="cut"){let r=h(t)?.cut;if(!r)return[];o.media={cut:r}}if(i==="mute"&&(o.media={mute:!0}),i==="loudness"&&(o.media={loudness:typeof t.loudness=="number"?t.loudness:B}),i==="resize"){if(typeof t.resize!="object"||t.resize===null)return[];o.resize=t.resize}if(i==="crop"){let r=t.crop;if(!r?.aspect||!n.facts?.video)return[];o.crop=r}return W([n],o)}};function G(e){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${e.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function H(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function K(e,t){return Array.isArray(t)?l(t):t==="first"?[0]:typeof t=="string"&&t!=="all"&&t!==""?l(P(t,e.pages)):Array.from({length:e.pages},(n,i)=>i)}function V(e,t){let n=f[e.format].lossy,i=f[t].lossy;if(n&&!i)return{hint:"likely bigger",tone:"warn"};if(!n&&i)return{hint:"likely smaller",tone:"ok"}}function X(e){let t=w(e).filter(i=>i.id!==e.format),n=t[0];return{kind:"select",id:"target",label:`Convert ${f[e.format].label} to`,choices:t.map(i=>{let o=V(e,i.id);return{value:i.id,label:i.label,hint:o?.hint??i.hint,...o===void 0?{}:{tone:o.tone}}}),default:n?n.id:""}}function Y(e){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:e==="opus"?96:128}}var Z=e=>typeof e=="object"&&e!==null&&("percent"in e||"width"in e||"height"in e);function v(e){let t=e.target,n=typeof t=="string"?y(t):void 0;if(!n)throw S(`convertAction.plan() requires a valid target format, got ${JSON.stringify(t)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var yt={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:e=>e.length>=1,options(e,t,n){let i=e[0];if(!i)return[];let o=[X(i)],r=t.target;if(typeof r!="string")return o;i.kind==="document"&&m(r)&&o.push(G(i),H());let s=f[r];return i.kind==="media"?s?.media==="sound"&&s.lossy&&o.push(Y(r)):s?.lossy&&s.media===void 0&&o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),o.push(T(i,n,{subfolder:!0})),o},plan(e,t){let n=e[0];if(!n)return[];let i=v(t),o=i.id,r={background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0};if(i.lossy&&typeof t.quality=="number"&&(r.quality=t.quality),n.kind==="media"){let d=h(t);d&&(r.media=d),Z(t.resize)&&(r.resize=t.resize)}let s=typeof t.destination=="string"?t.destination:void 0;if(n.kind==="document"&&m(o)){let d=Number(t.dpi);r.dpi=Number.isFinite(d)&&d>0?d:150;let p=K(n,t.pages);r.pages=p;let N=typeof t.sourceRoot=="string"?t.sourceRoot:void 0,$=z(n.path,p,o,s,N);return[{op:"convert",sources:[n],outputs:$,target:o,options:r}]}let a=I({sourcePath:n.path,target:o,...s===void 0?{}:{output:`${s}/`}});return x(a,n.path)&&(a=c({sourcePath:n.path,target:o,suffix:o,...s===void 0?{}:{output:`${s}/`}})),[{op:"convert",sources:[n],outputs:[a],target:o,options:r}]}};export{j as a,T as b,_ as c,b as d,dt as e,W as f,h as g,pt as h,yt as i};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
var a={jpeg:{id:"jpeg",label:"JPEG",extensions:[".jpg",".jpeg"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"universal",defaultQuality:82},png:{id:"png",label:"PNG",extensions:[".png"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"lossless",quantisable:!0},webp:{id:"webp",label:"WebP",extensions:[".webp"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smaller, modern",defaultQuality:80},avif:{id:"avif",label:"AVIF",extensions:[".avif"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smallest",defaultQuality:50},heic:{id:"heic",label:"HEIC",extensions:[".heic",".heif"],hasAlpha:!0,animatable:!1,lossy:!0,hint:"Apple photos"},mp4:{id:"mp4",label:"MP4",extensions:[".mp4",".m4v"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"H.264 \xB7 AAC",media:"video"},mov:{id:"mov",label:"MOV",extensions:[".mov",".qt"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"QuickTime",media:"video",keepsOnly:!0},hevc:{id:"hevc",label:"HEVC",extensions:[".mp4"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"H.265 \xB7 AAC",media:"video"},webm:{id:"webm",label:"WebM",extensions:[".webm"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"VP9 \xB7 Opus",media:"video"},gif:{id:"gif",label:"GIF",extensions:[".gif"],hasAlpha:!0,animatable:!0,lossy:!1,hint:"animation",quantisable:!0,media:"video"},tiff:{id:"tiff",label:"TIFF",extensions:[".tif",".tiff"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"archival"},pdf:{id:"pdf",label:"PDF",extensions:[".pdf"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"document"},docx:{id:"docx",label:"DOCX",extensions:[".docx"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"Word document"},doc:{id:"doc",label:"DOC",extensions:[".doc"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"legacy Word"},mkv:{id:"mkv",label:"MKV",extensions:[".mkv"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"Matroska",media:"video",keepsOnly:!0},avi:{id:"avi",label:"AVI",extensions:[".avi"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"legacy video",media:"video",keepsOnly:!0},mp3:{id:"mp3",label:"MP3",extensions:[".mp3"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"plays anywhere",media:"sound"},m4a:{id:"m4a",label:"M4A",extensions:[".m4a",".m4b"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"AAC",media:"sound"},opus:{id:"opus",label:"Opus",extensions:[".opus"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"smallest",media:"sound"},flac:{id:"flac",label:"FLAC",extensions:[".flac"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"lossless",media:"sound"},aiff:{id:"aiff",label:"AIFF",extensions:[".aiff",".aif",".aifc"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"uncompressed",media:"sound"},wav:{id:"wav",label:"WAV",extensions:[".wav"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"uncompressed",media:"sound"},ogg:{id:"ogg",label:"OGG",extensions:[".ogg",".oga"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"Vorbis",media:"sound",keepsOnly:!0}},l=Object.keys(a);function i(e){return a[e.toLowerCase()]}function t(e){let s=a[e].extensions[0];if(!s)throw new Error(`format ${e} declares no extensions`);return s}export{a,i as b,t as c};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
function o(e){switch(e.op){case"convert":return e.options.crop&&e.options.resize?"cropped and resized":e.options.crop?"cropped":e.options.trim&&e.options.resize?"trimmed and resized":e.options.resize?"resized":e.options.trim?"trimmed":e.target===e.sources[0].format?"compressed":"converted";case"merge":return"merged";case"split":return"split";case"extract":return"extracted";case"delete":return"deleted from";case"rotate":return"rotated";case"boost":return e.scale===1?"sharpened":"boosted";case"remove-background":return"cut out";default:{let t=e;throw new Error(`describeResult has no verb for ${JSON.stringify(t)}`)}}}function i(e){let{job:t}=e,r=t.sources.map(n=>({path:n.path,bytes:n.bytes})),s=r.length===1&&t.outputs.length===1?r[0]:void 0;return{verb:o(t),sources:r,outputs:[...t.outputs],outputBytes:e.outputBytes,...s?{size:{from:s.bytes,to:e.outputBytes}}:{},warnings:e.warnings}}export{i as a};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{f as m,g as i}from"./chunk-6L6C3GJU.js";import{F as f}from"./chunk-3UEQ2OX6.js";import{a as r}from"./chunk-M66BUNYO.js";function a(t){let e=Object.keys(r);return[...t].sort((o,n)=>e.indexOf(o)-e.indexOf(n))}function s(t){let e=new Set;for(let o of i)if(o.reads.has(t.format))for(let n of o.writesFor?.(t)??o.writes)r[n].keepsOnly&&n!==t.format||e.add(n);return a([...e])}function u(t){return s(t).map(e=>({id:e,label:r[e].label,hint:r[e].hint,lossy:r[e].lossy}))}function d(){let t=new Set;for(let e of i)for(let o of e.reads)t.add(o);return a([...t])}function p(){let t=new Set;for(let e of i)for(let o of e.writes)t.add(o);return a([...t])}function F(t){return m.writes.has(t)}function g(){let t=new Set(d()),e=new Set(p());return a([...new Set([...t,...e])]).map(o=>({id:o,label:r[o].label,extensions:[...r[o].extensions],read:t.has(o),write:e.has(o),lossy:r[o].lossy}))}var z=5,R=200,O=5;function $(t){return t.format==="heic"?"jpeg":s(t).includes(t.format)?t.format:"png"}function j(t,e){let o=i.find(n=>n.id==="image")?.writes;if(!o?.has(t))return f(`Cannot ${e} into ${r[t].label}; only an image format can take the edit.`,`Choose one of: ${[...o??[]].join(", ")}.`)}var T=t=>`${t.width}x${t.height}`,C=t=>"percent"in t?`${t.percent}pct`:"width"in t?`${t.width}w`:`${t.height}h`;export{s as a,u as b,d as c,p as d,F as e,g as f,z as g,R as h,O as i,$ as j,j as k,T as l,C as m};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{execFile as s}from"node:child_process";import{access as a}from"node:fs/promises";import{win32 as c}from"node:path";import{promisify as f}from"node:util";var e=f(s);async function i(r){try{await e("explorer.exe",r)}catch(o){if(typeof o.code=="number")return;throw o}}var n=r=>c.normalize(r);async function t(r){try{await a(r)}catch{throw new Error(`The file ${r} does not exist.`)}}async function u(r,o=process.platform){if(o==="win32")return await t(r),i([n(r)]);await e("open",[r])}async function d(r,o=process.platform){if(o==="win32")return i([r]);await e("open",[r])}async function x(r,o=process.platform){if(o==="win32")return await t(r),i(["/select,",n(r)]);await e("open",["-R",r])}function P(r=process.platform){return r==="darwin"?"Show in Finder":r==="win32"?"Show in Explorer":"Show in file manager"}export{u as a,d as b,x as c,P as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as f}from"./chunk-EXLXSKRH.js";import{B as c,C as a,D as m}from"./chunk-3UEQ2OX6.js";import{randomBytes as p}from"node:crypto";import{constants as u}from"node:fs";import{access as S,mkdir as h,rename as w,rm as y,writeFile as P}from"node:fs/promises";import{basename as g,dirname as E,extname as x,join as A}from"node:path";function N(r,e=p(6).toString("hex")){let t=x(r);return A(E(r),f(`.forge-${e}-${g(r,t)}`,t))}async function T(r){let e=E(r);try{await h(e,{recursive:!0})}catch(t){let i=a(r,t);throw i===t?m(r,t):i}try{await S(e,u.W_OK)}catch(t){throw c(r,t)}}var W=new Set(["EPERM","EBUSY","EACCES"]),l=5,B=9;async function _(r,e,t=process.platform,i=o=>new Promise(n=>setTimeout(n,o)),d=l){if(t!=="win32"){await w(r,e);return}for(let o=1;;o++)try{await w(r,e);return}catch(n){let s=n.code;if(o>=d||!s||!W.has(s))throw n;await i(Math.min(50*2**(o-1),1e3))}}async function I(r,e){await T(r);let t=N(r);try{return await P(t,e),await _(t,r),e.byteLength}catch(i){throw await y(t,{force:!0}).catch(()=>{}),a(r,i)}}export{N as a,T as b,B as c,_ as d,I as e};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as E,c as w}from"./chunk-YWKMG5WO.js";import{a as M,b as j,e as S,i as P}from"./chunk-DOWMSJ6R.js";import{watch as k}from"node:fs";import{readdir as I,stat as W}from"node:fs/promises";import{join as z,resolve as x}from"node:path";function A(e,s,n){let r=x(e),c=n.settleMs??1e3,d=n.pollMs??500,i=new Set([...s].map(m=>x(m))),l=new Map,t=!1,a=!1,g=!1,p=async()=>{if(!t){if(a){g=!0;return}a=!0;try{let m=await I(r,{withFileTypes:!0}).catch(()=>[]),h=new Set;for(let o of m){if(!o.isFile()||M(o.name))continue;let f=z(r,o.name);if(h.add(f),i.has(f)||n.ignore?.(f))continue;let y=await W(f).catch(()=>{});if(!y||t)continue;let F=Date.now(),b=l.get(f);if(!b||b.size!==y.size||b.mtimeMs!==y.mtimeMs){l.set(f,{size:y.size,mtimeMs:y.mtimeMs,since:F});continue}F-b.since<c||(l.delete(f),i.add(f),n.onFile(f))}for(let o of[...i,...l.keys()])h.has(o)||(i.delete(o),l.delete(o))}finally{a=!1,g&&!t&&(g=!1,p())}}},v=setInterval(()=>{p()},d),u;try{u=k(r,{persistent:!1},()=>{p()}),u.on("error",()=>{})}catch{}return p(),{close(){t=!0,clearInterval(v),u?.close()}}}function K(e,s,n,r){let c=[],d=[];for(let i of e){let l=s[j(i)];if(!l){d.push({path:i.path,reason:R(s)});continue}let t=P(i,l,n,r);"job"in t?c.push(t.job):d.push({path:i.path,reason:t.left})}return{jobs:c,left:d}}async function G(e,s,n={}){let r=new Set,{jobs:c,left:d}=K(e.sources,s,r,n.destination);return{outcome:await w(c,{force:!1,...n.concurrency===void 0?{}:{concurrency:n.concurrency},...n.onEvent?{onEvent:n.onEvent}:{},...n.signal?{signal:n.signal}:{}}),left:d,claimed:r,jobs:c}}var O={images:"an image",pdfs:"a PDF",documents:"a document",videos:"a video",audio:"audio",other:"a file Forge reads"};function R(e){let s=Object.keys(e).filter(r=>e[r]);if(s.length===0)return"not supported";let n=s.map(r=>O[r]);return`not ${n.length===1?n[0]:`${n.slice(0,-1).join(", ")} or ${n.at(-1)}`}`}var J=(e,s)=>e==="other"?s==="text"?"a text file":"not supported":"not yet supported";function H(e){let s=E(e.concurrency),n=[],r=new Set,c=!1,d=async t=>{e.onEvent({type:"arrived",path:t}),e.onEvent({type:"phase",path:t,phase:"reading"});let a=await S(t);if(a.kind==="failed"){e.onEvent({type:"failed",path:t,error:a.failure.error});return}if(a.kind!=="source"){e.onEvent({type:"left",path:t,reason:J(a.kind,a.sniffed)});return}let{jobs:g,left:p}=K([a.source],e.answers,e.claimed,e.destination),[v]=p;if(v){e.onEvent({type:"left",path:t,reason:v.reason});return}let u=await w(g,{force:!1,concurrency:1,onEvent:o=>{o.type==="job:phase"&&"phase"in o.progress&&o.progress.phase!=="page"&&o.progress.phase!=="time"&&e.onEvent({type:"phase",path:t,phase:o.progress.phase,job:o.job})}}),[m]=u.results,h=[...u.refusals,...u.failures][0];m?e.onEvent({type:"converted",path:t,result:m}):h&&e.onEvent({type:"failed",path:t,error:h.error})},i=()=>{for(;!c&&r.size<s&&n.length>0;){let t=n.shift(),a=d(t).catch(()=>{}).finally(()=>{r.delete(a),i()});r.add(a)}},l=A(e.dir,e.known,{...e.settleMs===void 0?{}:{settleMs:e.settleMs},...e.pollMs===void 0?{}:{pollMs:e.pollMs},ignore:t=>e.claimed.has(t),onFile:t=>{n.push(t),i()}});return{async stop(){c=!0,l.close(),n.length=0,await Promise.all([...r])}}}export{K as a,G as b,H as c};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{d as l,e as f}from"./chunk-SMBK6BTC.js";import{f as g}from"./chunk-EXLXSKRH.js";import{execFile as S}from"node:child_process";import{mkdir as v,rename as N,rm as O}from"node:fs/promises";import{join as d}from"node:path";import{promisify as k}from"node:util";var F=k(S),j=async(e,r)=>{let{stdout:t}=await F("osascript",["-l","JavaScript","-e",e,...r],{timeout:5e3});return t.trim()},b=[{uti:"public.png",ext:"png"},{uti:"public.jpeg",ext:"jpg"},{uti:"org.webmproject.webp",ext:"webp"},{uti:"public.heic",ext:"heic"},{uti:"public.avif",ext:"avif"},{uti:"com.compuserve.gif",ext:"gif"},{uti:"public.tiff",ext:"tiff"}];function I(e){let r=e.includes("public.file-url");return b.find(t=>e.includes(t.uti)&&!(r&&t.uti==="public.tiff"))?.uti??null}function X(e=process.platform,r=process.env){return e==="darwin"&&!r.SSH_CONNECTION&&!r.SSH_TTY}var T={png:"public.png",jpeg:"public.jpeg",webp:"org.webmproject.webp",heic:"public.heic",avif:"public.avif",gif:"com.compuserve.gif",tiff:"public.tiff"};function $(e){return T[e]??"public.data"}var A=`ObjC.import('AppKit')
|
|
4
|
-
const pb = $.NSPasteboard.generalPasteboard
|
|
5
|
-
JSON.stringify({ types: ObjC.deepUnwrap(pb.types) || [], count: Number(pb.changeCount) })`,E=`function run(argv) {
|
|
6
|
-
ObjC.import('AppKit')
|
|
7
|
-
const pb = $.NSPasteboard.generalPasteboard
|
|
8
|
-
const data = pb.dataForType(argv[0])
|
|
9
|
-
if (data.isNil()) return JSON.stringify({ ok: false })
|
|
10
|
-
const ok = data.writeToFileAtomically(argv[1], true)
|
|
11
|
-
return JSON.stringify({ ok: ok, count: Number(pb.changeCount) })
|
|
12
|
-
}`,J=`function run(argv) {
|
|
13
|
-
ObjC.import('AppKit')
|
|
14
|
-
const pb = $.NSPasteboard.generalPasteboard
|
|
15
|
-
const item = $.NSPasteboardItem.alloc.init
|
|
16
|
-
item.setDataForType($.NSData.dataWithContentsOfFile(argv[0]), argv[1])
|
|
17
|
-
item.setStringForType($.NSURL.fileURLWithPath(argv[0]).absoluteString, 'public.file-url')
|
|
18
|
-
pb.clearContents
|
|
19
|
-
pb.writeObjects($.NSArray.arrayWithObject(item))
|
|
20
|
-
return JSON.stringify({ count: Number(pb.changeCount) })
|
|
21
|
-
}`;function z(e=j){let r=async()=>{try{let{types:t,count:n}=JSON.parse(await e(A,[]));return{changeCount:n,image:I(t),text:t.includes("public.utf8-plain-text")}}catch{return{changeCount:-1,image:null,text:!1}}};return{peek:r,async read(t){let{image:n}=await r(),a=b.find(C=>C.uti===n);if(!a)return null;await v(t,{recursive:!0});let i=d(t,`Copied image.${a.ext}`),s=JSON.parse(await e(E,[a.uti,i]));if(!s.ok||s.count===void 0)return null;if(a.uti!=="public.tiff")return{path:i,changeCount:s.count};let{default:x}=await import("sharp"),c=d(t,"Copied image.png");return await x(i).keepIccProfile().png().toFile(`${c}.part`),await N(`${c}.part`,c),await O(i,{force:!0}),{path:c,changeCount:s.count}},async write(t,n){let{count:a}=JSON.parse(await e(J,[t,$(n)]));return a}}}import{randomBytes as h}from"node:crypto";import{copyFile as R,mkdir as y,readdir as P,readFile as D,rename as _,rm as p,stat as K}from"node:fs/promises";import{tmpdir as U}from"node:os";import{extname as u,join as o}from"node:path";function m(){return o(U(),"forge-clip")}var W=5,w={".png":"png",".jpg":"jpeg",".jpeg":"jpeg",".webp":"webp",".heic":"heic",".avif":"avif",".gif":"gif",".tiff":"tiff"};async function at(e,r=m()){let t=`${Date.now().toString(36)}-${h(3).toString("hex")}`,n=o(r,t),a=await e.read(o(n,"in"));if(!a)return await p(n,{recursive:!0,force:!0}),null;let i=o(n,"out");await y(i,{recursive:!0}),await L(r,a.path);let s=o(n,"in","Copied image");return await _(a.path,s),await B(r,t),{source:s,outDir:i,changeCount:a.changeCount}}async function L(e,r){let t=o(e,"last"),n=`Copied image${u(r)}`,a=o(e,`.last-${h(4).toString("hex")}`);await y(a,{recursive:!0}),await R(r,o(a,n)),await p(t,{recursive:!0,force:!0}),await l(a,t)}async function B(e,r){let t=await P(e,{withFileTypes:!0}).catch(()=>[]),a=(await Promise.all(t.filter(i=>i.isDirectory()&&i.name!=="last"&&!i.name.startsWith(".")).map(async i=>({name:i.name,at:(await K(o(e,i.name)).catch(()=>null))?.mtimeMs??0})))).filter(i=>i.name!==r).sort((i,s)=>s.at-i.at).slice(W-1);await Promise.all(a.map(i=>p(o(e,i.name),{recursive:!0,force:!0})))}async function M(e=m()){let r=o(e,"last"),t=(await P(r).catch(()=>[])).find(n=>w[u(n).toLowerCase()]!==void 0);return t===void 0?null:{path:o(r,t),format:w[u(t).toLowerCase()]}}async function nt(e,r,t,n){let{changeCount:a}=await e.peek();return a!==r.changeCount?"changed":(await e.write(t,n),"placed")}async function ot(e,r=m()){let t=await M(r);return t?(await e.write(t.path,t.format),!0):!1}async function st(e,r){let t=g(o(r,`Copied image${u(e)}`));return await f(t,await D(e)),t}export{X as a,z as b,at as c,nt as d,ot as e,st as f};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{execFile as o,execFileSync as n}from"node:child_process";var f=()=>({...process.env,LANG:process.env.LANG??"en_US.UTF-8"});function i(e,t=process.platform){if(e!==""){if(t==="win32"){try{let r=o("clip.exe",()=>{});r.on("error",()=>{}),r.stdin?.end(Buffer.concat([Buffer.from([255,254]),Buffer.from(e,"utf16le")]))}catch{}return}try{let r=o("pbcopy",{env:f()},()=>{});r.on("error",()=>{}),r.stdin?.end(Buffer.from(e,"utf8"))}catch{}}}function u(e=process.platform){if(e==="win32")try{return n("powershell.exe",["-NoProfile","-NonInteractive","-Command","[Console]::OutputEncoding=[Text.Encoding]::UTF8; Get-Clipboard -Raw"],{encoding:"buffer",maxBuffer:67108864,timeout:5e3}).toString("utf8").replace(/\r\n$/,"")}catch{return""}try{return n("pbpaste",{encoding:"buffer",env:f(),maxBuffer:67108864,timeout:2e3}).toString("utf8")}catch{return""}}export{i as a,u as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{h as k}from"./chunk-6L6C3GJU.js";import{c as C}from"./chunk-EXLXSKRH.js";import{$ as I,A as T,aa as B,d as E,ga as v,p as P,s as x,x as w,y as M,z as A}from"./chunk-3UEQ2OX6.js";function N(e=1,t=100){let o=Math.max(1,t-e+1);return 1+Math.max(0,Math.ceil(Math.log2(o)))}async function U(e){let t=e.min??1,o=e.max??100,f=N(t,o),i=0,n=async s=>(i+=1,e.onAttempt?.(i,f),e.encode(s)),l=()=>e.signal?.aborted===!0,u=await n(o);if(l())return{quality:o,bytes:u,missed:!1,cancelled:!0};if(u<=e.targetBytes)return{quality:o,bytes:u,missed:!1};let a=t,y=o,b;for(;a<=y;){let s=Math.floor((a+y)/2),c=await n(s);if(l())return{quality:s,bytes:c,missed:!1,cancelled:!0};c<=e.targetBytes?(b={quality:s,bytes:c,missed:!1},a=s+1):y=s-1}if(b)return b;let h=await e.encode(t);return{quality:t,bytes:h,missed:!0}}import{cpus as _}from"node:os";function D(){return Math.max(1,Math.min(_().length,4))}function J(e){let t=e!==void 0&&Number.isFinite(e)?e:void 0;return Math.max(1,t??D())}async function S(e,t,o){let f=0,i=async()=>{for(;f<e.length;){let l=f++;await o(e[l],l)}},n=Math.min(J(t),e.length);await Promise.all(Array.from({length:n},i))}async function q(e,t){let o=t.onEvent??(()=>{}),f=t.engineFor??k,i=J(t.concurrency),n=e.length,l=[],u=[],a=0;await S(e,i,async(s,c)=>{o({type:"job:start",job:s,index:c,total:n});let F=f(s);if(!F){a++;let m=s.sources[0].path,r={path:m,error:v(m,new Error(`no engine runs ${s.op}`))};u[c]=r,o({type:"job:error",job:s,failure:r,completed:a,total:n});return}try{let m=await F.run(s,r=>o({type:"job:phase",job:s,progress:r}),t.signal);l[c]=m,a++,o({type:"job:done",job:s,result:m,completed:a,total:n})}catch(m){a++;let r=s.sources[0].path,d=E(m)?m:v(r,m),p={path:r,error:d};u[c]=p,o({type:"job:error",job:s,failure:p,completed:a,total:n})}});let y=l.filter(s=>s!==void 0),b=u.filter(s=>s!==void 0),h={results:y,failures:b,inputBytes:y.reduce((s,c)=>s+c.job.sources[0].bytes,0),outputBytes:y.reduce((s,c)=>s+c.outputBytes,0)};return o({type:"batch:done",summary:h}),h}import{existsSync as L}from"node:fs";import{resolve as R}from"node:path";function W(e){let t=e.sources[0]?.path??e.outputs[0]??"",o=new Set;for(let f of e.outputs){let i=R(f);if(o.has(i))return{output:f,error:A(t,f)};o.add(i)}}function z(e,t,o){let f=W(e);if(f)return f;let i=e.sources[0]?.path??e.outputs[0]??"";for(let n of e.outputs){let l=R(n);if(e.sources.some(a=>C(a.path,l))&&!o)return{output:n,error:T(n,e.op)};let u=t.get(l);if(u){let a=u.sources[0]?.path??u.outputs[0]??"";return{output:n,error:M([a,i],n)}}if(L(l)&&!o)return{output:n,error:w(n,e.op)}}}function O(e,t){let o=[],f=[],i=new Map;for(let n of e){let l=z(n,i,t.force);if(l){let u=n.sources[0]?.path??l.output;f.push({path:u,error:l.error});continue}for(let u of n.outputs)i.set(R(u),n);o.push(n)}return{jobs:o,failures:f}}async function X(e,t,o,f,i){let n=e.sources[0].path,l=r=>({kind:"failed",failure:{path:n,error:E(r)?r:v(n,r)}}),u=o(e);if(u?.sizeTo){let r=e.sources[0],d=e.options.compress!==void 0;if(d&&r.bytes<=t)return{kind:"failed",failure:{path:n,error:B(n,r.bytes,t)}};let p=t,g=u.sizeTo(e,p);return g&&d&&g.floor>=r.bytes?{kind:"failed",failure:{path:n,error:I(n,r.bytes,g.floor,!0)}}:g?{kind:"unreachable",entry:{job:e,smallest:g.floor,settings:{quality:1,media:{...e.options.media,targetBytes:g.floor}},error:x(r,t,g.floor)}}:(e.options={...e.options,media:{...e.options.media,targetBytes:p}},{kind:"ready"})}let a;try{a=await o(e)?.measurer?.(e)}catch(r){return l(r)}if(!a||a.ladder.length===0)return{kind:"refused",failure:{path:n,error:P(e.sources[0],e.target)}};let y=a,b=e.sources[0],h=e.options.compress!==void 0&&b.bytes<=t,s=h?b.bytes-1:t;if(i?.aborted)return{kind:"cancelled"};let c=Number.POSITIVE_INFINITY,F;try{for(let r of y.ladder){let d=await U({encode:p=>y.measure({...e.options,...r,quality:p}),targetBytes:s,onAttempt:(p,g)=>f({type:"search:attempt",job:e,attempt:p,of:g,rung:r}),...i===void 0?{}:{signal:i}});if(d.cancelled)return{kind:"cancelled"};if(d.bytes<c&&(c=d.bytes,F={...r,quality:d.quality}),!d.missed)return e.options={...e.options,...r,quality:d.quality},{kind:"ready"}}}catch(r){return l(r)}return h?{kind:"failed",failure:{path:n,error:I(n,b.bytes,c,!0)}}:{kind:"unreachable",entry:{job:e,smallest:c,settings:F??{quality:1},error:x(e.sources[0],t,c)}}}async function ue(e,t){let o=t.onEvent??(()=>{}),f=t.engineFor??k,i=t.targetBytes,n=O(e,{force:t.force}),l=i===void 0?0:n.jobs.filter(r=>r.op==="convert").length,u=[],a=0;await S(n.jobs,J(t.concurrency),async(r,d)=>{if(i===void 0||r.op!=="convert"){u[d]={kind:"ready"};return}if(t.signal?.aborted){u[d]={kind:"cancelled"};return}let p=await X(r,i,f,o,t.signal);u[d]=p,p.kind!=="cancelled"&&(a+=1,o({type:"search:settled",job:r,completed:a,total:l}))});let y=[...n.failures],b=[],h=[],s=[],c=!1;for(let[r,d]of n.jobs.entries()){let p=u[r]??{kind:"ready"};p.kind==="ready"?s.push(d):p.kind==="refused"?y.push(p.failure):p.kind==="failed"?h.push(p.failure):p.kind==="unreachable"?b.push(p.entry):c=!0}if(c)return{results:[],refusals:y,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let F=new Set,m=await q(s,{...t.concurrency===void 0?{}:{concurrency:t.concurrency},...t.engineFor===void 0?{}:{engineFor:t.engineFor},...t.signal===void 0?{}:{signal:t.signal},onEvent:r=>{r.type==="job:error"&&!t.signal?.aborted&&F.add(r.failure),o(r)}});if(t.signal?.aborted&&m.failures.length>0){let r=m.failures.filter(d=>F.has(d));return{...m,refusals:y,unreachable:b,failures:[...h,...r],cancelled:!0}}return{results:m.results,refusals:y,unreachable:b,failures:[...h,...m.failures],inputBytes:m.inputBytes,outputBytes:m.outputBytes}}export{J as a,O as b,ue as c};
|