forge-terminal 0.5.9 → 0.7.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 +53 -16
- package/dist/chunks/{about-credits-32BUKO4K.js → about-credits-PWTKZG3Y.js} +1 -1
- package/dist/chunks/args-RHIBM3R3.js +3 -0
- package/dist/chunks/{available-TNMISSBA.js → available-FPBRQ3LS.js} +1 -1
- package/dist/chunks/boot-PHDTJAFT.js +3 -0
- package/dist/chunks/{catalog-FMHWWMUX.js → catalog-G44MXIAF.js} +1 -1
- package/dist/chunks/check-BFHBPCGW.js +3 -0
- package/dist/chunks/chunk-2YU4EI24.js +3 -0
- package/dist/chunks/chunk-3IAJTXYM.js +3 -0
- package/dist/chunks/chunk-3OCPO5V6.js +3 -0
- package/dist/chunks/chunk-42IEPG2K.js +3 -0
- package/dist/chunks/{chunk-WE6KP4FR.js → chunk-4AL5QJLM.js} +1 -1
- package/dist/chunks/chunk-56B3VZCM.js +3 -0
- package/dist/chunks/chunk-56QHX7QR.js +3 -0
- package/dist/chunks/chunk-6NCN7OJ5.js +7 -0
- package/dist/chunks/chunk-6PUV4HSU.js +3 -0
- package/dist/chunks/chunk-72UR37EG.js +3 -0
- package/dist/chunks/chunk-7NP76V4U.js +3 -0
- package/dist/chunks/{chunk-7XFLG32B.js → chunk-AETM2PCZ.js} +1 -1
- package/dist/chunks/chunk-BQV3DSUZ.js +23 -0
- package/dist/chunks/chunk-BSFBZBAI.js +16 -0
- package/dist/chunks/chunk-DC2DHMXO.js +3 -0
- package/dist/chunks/{chunk-WBW6G4N6.js → chunk-DKHBJ52G.js} +1 -1
- package/dist/chunks/chunk-E5VPEBUQ.js +3 -0
- package/dist/chunks/chunk-EYOO35US.js +3 -0
- package/dist/chunks/chunk-F4TUCI6D.js +3 -0
- package/dist/chunks/{chunk-MF3KKEFB.js → chunk-FEJSM3E4.js} +1 -1
- package/dist/chunks/chunk-FGR6QCG5.js +3 -0
- package/dist/chunks/{chunk-W53XNVNH.js → chunk-G2V33TMN.js} +1 -1
- package/dist/chunks/{chunk-ILQDMVJR.js → chunk-G4M2XYFJ.js} +1 -1
- package/dist/chunks/chunk-H332YFSO.js +4 -0
- package/dist/chunks/chunk-HAOKWLD3.js +4 -0
- package/dist/chunks/chunk-I2LPGKUU.js +3 -0
- package/dist/chunks/{chunk-YRXJDFP3.js → chunk-I3C3SRF2.js} +1 -1
- package/dist/chunks/{chunk-SM735FG7.js → chunk-ID4GJZJ6.js} +1 -1
- package/dist/chunks/chunk-ID75X37Z.js +3 -0
- package/dist/chunks/chunk-JPASVE56.js +3 -0
- package/dist/chunks/chunk-JZM37DG2.js +3 -0
- package/dist/chunks/chunk-KPUKMAYK.js +19 -0
- package/dist/chunks/{chunk-SZRSAL64.js → chunk-M7HB4L6L.js} +1 -1
- package/dist/chunks/chunk-NUCGWLOY.js +8 -0
- package/dist/chunks/{chunk-4KGC5ZBZ.js → chunk-OK56WDPA.js} +1 -1
- package/dist/chunks/{chunk-I25E2XDH.js → chunk-OLKPV4WO.js} +1 -1
- package/dist/chunks/chunk-OPDC577C.js +3 -0
- package/dist/chunks/chunk-OQ6DTE56.js +3 -0
- package/dist/chunks/chunk-PA7AG2NK.js +55 -0
- package/dist/chunks/chunk-PNPAHKJR.js +3 -0
- package/dist/chunks/chunk-PON65UTS.js +3 -0
- package/dist/chunks/{chunk-GVVQP3LF.js → chunk-PXCEMDOY.js} +2 -2
- package/dist/chunks/chunk-QMNERJL2.js +3 -0
- package/dist/chunks/{chunk-OXDRJO4V.js → chunk-R6QVLPGC.js} +1 -1
- package/dist/chunks/chunk-S44LAUHZ.js +3 -0
- package/dist/chunks/chunk-SCJ2QXZF.js +80 -0
- package/dist/chunks/{chunk-4MJEEEFA.js → chunk-SJIDFYPT.js} +1 -1
- package/dist/chunks/{chunk-3374PCO5.js → chunk-TQEGSODD.js} +1 -1
- package/dist/chunks/chunk-ULX4ZD2Y.js +3 -0
- package/dist/chunks/chunk-W6QOV4RP.js +6 -0
- package/dist/chunks/chunk-WWWWXOM4.js +3 -0
- package/dist/chunks/{chunk-6RCS3KBP.js → chunk-XIR3VWQY.js} +1 -1
- package/dist/chunks/chunk-XUJLUOGD.js +6 -0
- package/dist/chunks/chunk-Y3DMALHT.js +66 -0
- package/dist/chunks/chunk-YXV3PYVI.js +3 -0
- package/dist/chunks/chunk-Z3PQ5TMU.js +3 -0
- package/dist/chunks/chunk-ZL7E7PZN.js +4 -0
- package/dist/chunks/clip-command-6Q7BTXR5.js +3 -0
- package/dist/chunks/clipboard-QWNPA3GM.js +3 -0
- package/dist/chunks/colour-7HPH6KTY.js +3 -0
- package/dist/chunks/command-JTK4IOS7.js +3 -0
- package/dist/chunks/config-command-DIQTU7DM.js +3 -0
- package/dist/chunks/continue-editing-FTUY6UFG.js +3 -0
- package/dist/chunks/decoded-IXLPWTGZ.js +3 -0
- package/dist/chunks/{entry-BZYPZONY.js → entry-ZF7D32ZI.js} +2 -2
- package/dist/chunks/execute-RP7ZMWLZ.js +3 -0
- package/dist/chunks/extensions-YOZ4IF4E.js +3 -0
- package/dist/chunks/{extensions-command-JZSOQJEV.js → extensions-command-O7UHUJ3Y.js} +1 -1
- package/dist/chunks/ffmpeg-2ZP3GXJX.js +3 -0
- package/dist/chunks/image-6A7FXKIR.js +3 -0
- package/dist/chunks/{install-KGFOAQCU.js → install-4L7JGP3X.js} +1 -1
- package/dist/chunks/install-XJAPLIH2.js +3 -0
- package/dist/chunks/launch-2KSJ4GGN.js +18 -0
- package/dist/chunks/link-inputs-GTEW6ZH4.js +3 -0
- package/dist/chunks/lock-KNR7XS7Q.js +3 -0
- package/dist/chunks/manager-YH5XAMZA.js +4 -0
- package/dist/chunks/{needed-DYERJ72M.js → needed-TB3OC76N.js} +1 -1
- package/dist/chunks/notify-UD7FQAWX.js +3 -0
- package/dist/chunks/{own-2QGMHSKL.js → own-KUGTZ3BV.js} +1 -1
- package/dist/chunks/{paths-6OENILJ4.js → paths-BBUKTDDP.js} +1 -1
- package/dist/chunks/pdfium-MJ65YOXW.js +3 -0
- package/dist/chunks/preferences-7S7YZOFK.js +3 -0
- package/dist/chunks/preset-command-KMKR6KMG.js +3 -0
- package/dist/chunks/registry-657JRJR5.js +3 -0
- package/dist/chunks/run-VJDF5WRF.js +3 -0
- package/dist/chunks/server-6PH2DSFW.js +81 -0
- package/dist/chunks/signals-VY2XE3LV.js +3 -0
- package/dist/chunks/text-layer-PFIDCTEL.js +5 -0
- package/dist/chunks/theme-FVQOSLPB.js +3 -0
- package/dist/chunks/transcribe-FUN2SKRN.js +3 -0
- package/dist/chunks/transcribe-command-KNSUHROE.js +3 -0
- package/dist/chunks/update-command-X4OSYETA.js +3 -0
- package/dist/chunks/update-note-LV7G4CHE.js +3 -0
- package/dist/chunks/video-link-CF7GUA6V.js +3 -0
- package/dist/chunks/watch-command-3C4AWM7A.js +3 -0
- package/dist/helpers/forge-transcribe +0 -0
- package/dist/index.js +16 -15
- package/package.json +15 -3
- package/skills/forge/SKILL.md +7 -3
- package/dist/chunks/args-ZVZQR23M.js +0 -3
- package/dist/chunks/boot-2YFTQOMG.js +0 -3
- package/dist/chunks/check-B6NP7BEM.js +0 -3
- package/dist/chunks/chunk-4RNVZQRC.js +0 -3
- package/dist/chunks/chunk-6KUWZQGG.js +0 -3
- package/dist/chunks/chunk-6MWJO3GB.js +0 -4
- package/dist/chunks/chunk-6PEIZZNE.js +0 -3
- package/dist/chunks/chunk-7FW7JX74.js +0 -36
- package/dist/chunks/chunk-7XDMC7FL.js +0 -72
- package/dist/chunks/chunk-AR3M2PLK.js +0 -3
- package/dist/chunks/chunk-ASLKQXZ2.js +0 -3
- package/dist/chunks/chunk-BKLPRILS.js +0 -3
- package/dist/chunks/chunk-EEQSUBBL.js +0 -3
- package/dist/chunks/chunk-FAUL5L2W.js +0 -3
- package/dist/chunks/chunk-FBVRKMAF.js +0 -3
- package/dist/chunks/chunk-GHYODKA3.js +0 -3
- package/dist/chunks/chunk-H3DIRJFE.js +0 -3
- package/dist/chunks/chunk-HTA25PO2.js +0 -3
- package/dist/chunks/chunk-J7FLFHQJ.js +0 -3
- package/dist/chunks/chunk-K253E723.js +0 -3
- package/dist/chunks/chunk-KH5DHZ2U.js +0 -8
- package/dist/chunks/chunk-L44NRTP4.js +0 -3
- package/dist/chunks/chunk-N32JL4UI.js +0 -3
- package/dist/chunks/chunk-N6RCLJE6.js +0 -4
- package/dist/chunks/chunk-NDYMC3HY.js +0 -66
- package/dist/chunks/chunk-NMECUMJD.js +0 -7
- package/dist/chunks/chunk-OQBIYNGK.js +0 -6
- package/dist/chunks/chunk-Q6KQWJ4J.js +0 -3
- package/dist/chunks/chunk-QQV7CCAY.js +0 -3
- package/dist/chunks/chunk-RCWFUBTG.js +0 -3
- package/dist/chunks/chunk-TFGK7IRZ.js +0 -19
- package/dist/chunks/chunk-TGC24JEW.js +0 -4
- package/dist/chunks/chunk-TLHUFIXD.js +0 -3
- package/dist/chunks/chunk-V6GWPR2A.js +0 -3
- package/dist/chunks/chunk-VJMOZPHW.js +0 -3
- package/dist/chunks/chunk-YPAFAG4W.js +0 -6
- package/dist/chunks/chunk-ZBMJTIYR.js +0 -3
- package/dist/chunks/chunk-ZX5FDZZW.js +0 -55
- package/dist/chunks/clip-command-MDSM6KJP.js +0 -3
- package/dist/chunks/clipboard-IZJTBTSW.js +0 -3
- package/dist/chunks/colour-2MYODUDY.js +0 -3
- package/dist/chunks/command-GAGAD65W.js +0 -3
- package/dist/chunks/config-command-CKPJXJEE.js +0 -3
- package/dist/chunks/continue-editing-M6WESEVB.js +0 -3
- package/dist/chunks/decoded-XWKU23RG.js +0 -3
- package/dist/chunks/execute-7M6WA4W7.js +0 -3
- package/dist/chunks/extensions-E3OUBT36.js +0 -3
- package/dist/chunks/ffmpeg-KDZEPLNA.js +0 -3
- package/dist/chunks/image-R5C3AWHT.js +0 -3
- package/dist/chunks/install-MFYGS5TG.js +0 -3
- package/dist/chunks/launch-VNW4YQ4Z.js +0 -17
- package/dist/chunks/lock-BG3CLOHA.js +0 -3
- package/dist/chunks/manager-L753MI7U.js +0 -4
- package/dist/chunks/notify-NQNNOBFC.js +0 -3
- package/dist/chunks/pdfium-77L526HZ.js +0 -3
- package/dist/chunks/preferences-3P4V2EDX.js +0 -3
- package/dist/chunks/preset-command-UNMXHW5A.js +0 -3
- package/dist/chunks/registry-RS7LQ3UA.js +0 -3
- package/dist/chunks/run-GUFPETHF.js +0 -3
- package/dist/chunks/server-PIXRL5PA.js +0 -77
- package/dist/chunks/text-layer-LHZNDMPZ.js +0 -3
- package/dist/chunks/theme-P3ZE2ZYB.js +0 -3
- package/dist/chunks/transcribe-KXQXEVBJ.js +0 -3
- package/dist/chunks/transcribe-command-JHWN4RWU.js +0 -3
- package/dist/chunks/update-command-DWEBUFT5.js +0 -3
- package/dist/chunks/update-note-CY3LCBCJ.js +0 -3
- package/dist/chunks/watch-command-QGVXM23I.js +0 -3
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as D}from"./chunk-FBVRKMAF.js";import{a as X,b as Q}from"./chunk-HZDYZ5RD.js";import{j as M}from"./chunk-N32JL4UI.js";import{a as K}from"./chunk-TGC24JEW.js";import{b as J}from"./chunk-EEQSUBBL.js";import{a as W}from"./chunk-HTA25PO2.js";import{a as Y}from"./chunk-KH5DHZ2U.js";import{a as U}from"./chunk-TLHUFIXD.js";import{m as R}from"./chunk-4MJEEEFA.js";import{G as d,J as H}from"./chunk-ZBMJTIYR.js";import{d as L}from"./chunk-J7FLFHQJ.js";import{b as z}from"./chunk-H3DIRJFE.js";var O=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},k=class extends O{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var E=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new k(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function N(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as le}from"node:events";import G from"node:child_process";import C from"node:path";import F from"node:fs";import m from"node:process";import{stripVTControlCharacters as ce}from"node:util";import{stripVTControlCharacters as se}from"node:util";var T=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,r)=>i.name().localeCompare(r.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),r=n.long&&e._findOption(n.long);!i&&!r?t.push(n):n.long&&!r?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(r=>!r.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>N(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[])}),t.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[]),i.get(o).push(r)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function r(h,p){return t.formatItem(h,n,p,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(u),i),""]));let l=t.visibleArguments(e).map(h=>r(t.styleArgumentTerm(t.argumentTerm(h)),t.styleArgumentDescription(t.argumentDescription(h))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),h=>h.helpGroupHeading??"Options:").forEach((h,p)=>{let x=h.map(_=>r(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));o=o.concat(this.formatItemList(p,x,t))}),t.showGlobalOptions){let h=t.visibleGlobalOptions(e).map(p=>r(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",h,t))}return this.groupItems(e.commands,t.visibleCommands(e),h=>h.helpGroup()||"Commands:").forEach((h,p)=>{let x=h.map(_=>r(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,x,t))}),o.join(`
|
|
4
|
-
`)}displayWidth(e){return se(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let o=" ".repeat(2);if(!n)return o+e;let u=e.padEnd(t+e.length-i.displayWidth(e)),l=2,a=(this.helpWidth??80)-t-l-2,h;return a<this.minWidthToWrap||i.preformatted(n)?h=n:h=i.boxWrap(n,a).replace(/\n/g,`
|
|
5
|
-
`+" ".repeat(t+l)),o+u+" ".repeat(l)+h.replace(/\n/g,`
|
|
6
|
-
${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,r=[];return n.forEach(o=>{let u=o.match(i);if(u===null){r.push("");return}let l=[u.shift()],c=this.displayWidth(l[0]);u.forEach(a=>{let h=this.displayWidth(a);if(c+h<=t){l.push(a),c+=h;return}r.push(l.join(""));let p=a.trimStart();l=[p],c=this.displayWidth(p)}),r.push(l.join(""))}),r.join(`
|
|
7
|
-
`)}};var A=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=ae(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new k(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Z(this.name().replace(/^no-/,"")):Z(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},V=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,r=i!==void 0?i:!1;return t.negate===(r===e)}};function Z(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ae(s){let e,t,n=/^-[^-]$/,i=/^--[^-]/,r=s.split(/[ |,]+/).concat("guard");if(n.test(r[0])&&(e=r.shift()),i.test(r[0])&&(t=r.shift()),!e&&n.test(r[0])&&(e=r.shift()),!e&&i.test(r[0])&&(e=t,t=r.shift()),r[0].startsWith("-")){let o=r[0],u=`option creation failed due to '${o}' in option flags '${s}'`;throw/^-[^-][^-]/.test(o)?new Error(`${u}
|
|
8
|
-
- a short flag is a single dash and a single character
|
|
9
|
-
- either use a single dash and a single character (for a short flag)
|
|
10
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(o)?new Error(`${u}
|
|
11
|
-
- too many short flags`):i.test(o)?new Error(`${u}
|
|
12
|
-
- too many long flags`):new Error(`${u}
|
|
13
|
-
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${s}'.`);return{shortFlag:e,longFlag:t}}function ue(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let n=0;n<=s.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=s.length;i++){let r;s[i-1]===e[n-1]?r=0:r=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+r),i>1&&n>1&&s[i-1]===e[n-2]&&s[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[s.length][e.length]}function q(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(o=>o.slice(2)));let n=[],i=3,r=.4;return e.forEach(o=>{if(o.length<=1)return;let u=ue(s,o),l=Math.max(s.length,o.length);(l-u)/l>r&&(u<i?(i=u,n=[o]):u===i&&n.push(o))}),n.sort((o,u)=>o.localeCompare(u)),t&&(n=n.map(o=>`--${o}`)),n.length>1?`
|
|
14
|
-
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
15
|
-
(Did you mean ${n[0]}?)`:""}var $=class s extends le{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>m.stdout.write(t),writeErr:t=>m.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>te()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>te()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:t=>ce(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let i=t,r=n;typeof i=="object"&&i!==null&&(r=i,i=null),r=r||{};let[,o,u]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),r.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(r.noHelp||r.hidden),l._executableFile=r.executableFile||null,u&&l.arguments(u),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(e){return new s(e)}createHelp(){return Object.assign(new T,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
16
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new E(e,t)}argument(e,t,n,i){let r=this.createArgument(e,t);return typeof n=="function"?r.default(i).argParser(n):r.default(n),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,r]=n.match(/([^ ]+) *(.*)/),o=t??"display help for command",u=this.createCommand(i);return u.helpOption(!1),r&&u.arguments(r),o&&u.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=u,(e||t)&&this._initCommandGroup(u),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
17
|
-
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new O(e,t,n)),m.exit(e)}action(e){let t=n=>{let i=this.registeredArguments.length,r=n.slice(0,i);return this._storeOptionsAsProperties?r[i]=this:r[i]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new A(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${i} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
18
|
-
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(r,o,u)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let l=this.getOptionValue(n);r!==null&&e.parseArg?r=this._callParseArg(e,r,l,o):r!==null&&e.variadic&&(r=e._collectValue(r,l)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(n,r,u)};return this.on("option:"+t,r=>{let o=`error: option '${e.flags}' argument '${r}' is invalid.`;i(r,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let o=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;i(r,o,"env")}),this}_optionEx(e,t,n,i,r){if(typeof t=="object"&&t instanceof A)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,n);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(r).argParser(i);else if(i instanceof RegExp){let u=i;i=(l,c)=>{let a=u.exec(l);return a?a[0]:c},o.default(r).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){m.versions?.electron&&(t.from="electron");let i=m.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=m.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":m.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
19
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(F.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",r=`'${e}' does not exist
|
|
20
|
-
- if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
21
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
22
|
-
- ${i}`;throw new Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(a,h){let p=C.resolve(a,h);if(F.existsSync(p))return p;if(n.includes(C.extname(h)))return;let x=n.find(_=>F.existsSync(`${p}${_}`));if(x)return`${p}${x}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||"";if(this._scriptPath){let a;try{a=F.realpathSync(this._scriptPath)}catch{a=this._scriptPath}o=C.resolve(C.dirname(a),o)}if(o){let a=i(o,r);if(!a&&!e._executableFile&&this._scriptPath){let h=C.basename(this._scriptPath,C.extname(this._scriptPath));h!==this._name&&(a=i(o,`${h}-${e._name}`))}r=a||r}let u=n.includes(C.extname(r)),l;m.platform!=="win32"?u?(t.unshift(r),t=ee(m.execArgv).concat(t),l=G.spawn(m.argv[0],t,{stdio:"inherit"})):l=G.spawn(r,t,{stdio:"inherit"}):(this._checkForMissingExecutable(r,o,e._name),t.unshift(r),t=ee(m.execArgv).concat(t),l=G.spawn(m.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{m.on(h,()=>{l.killed===!1&&l.exitCode===null&&l.kill(h)})});let c=this._exitCallback;l.on("close",a=>{a=a??1,c?c(new O(a,"commander.executeSubCommandAsync","(close)")):m.exit(a)}),l.on("error",a=>{if(a.code==="ENOENT")this._checkForMissingExecutable(r,o,e._name);else if(a.code==="EACCES")throw new Error(`'${r}' not executable`);if(!c)m.exit(1);else{let h=new O(1,"commander.executeSubCommandAsync","(error)");h.nestedError=a,c(h)}}),this.runningCommand=l}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let r;return r=this._chainOrCallSubCommandHook(r,i,"preSubcommand"),r=this._chainOrCall(r,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),r}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,r)=>{let o=i;if(i!==null&&n.parseArg){let u=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;o=this._callParseArg(n,i,r,u)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let r=n.defaultValue;n.variadic?i<this.args.length?(r=this.args.slice(i),n.parseArg&&(r=r.reduce((o,u)=>e(n,u,o),n.defaultValue))):r===void 0&&(r=[]):i<this.args.length&&(r=this.args[i],n.parseArg&&(r=e(n,r,n.defaultValue))),t[i]=r}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(o=>{i.push({hookedCommand:r,callback:o})})}),t==="postAction"&&i.reverse(),i.forEach(r=>{n=this._chainOrCall(n,()=>r.callback(r.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(r=>{i=this._chainOrCall(i,()=>r(this,t))}),i}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(r))i(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(r=>n.conflictsWith.includes(r.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function r(a){return a.length>1&&a[0]==="-"}let o=a=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(a)?!this._getCommandAndAncestors().some(h=>h.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,u=null,l=null,c=0;for(;c<e.length||l;){let a=l??e[c++];if(l=null,a==="--"){i===n&&i.push(a),i.push(...e.slice(c));break}if(u&&(!r(a)||o(a))){this.emit(`option:${u.name()}`,a);continue}if(u=null,r(a)){let h=this._findOption(a);if(h){if(h.required){let p=e[c++];p===void 0&&this.optionMissingArgument(h),this.emit(`option:${h.name()}`,p)}else if(h.optional){let p=null;c<e.length&&(!r(e[c])||o(e[c]))&&(p=e[c++]),this.emit(`option:${h.name()}`,p)}else this.emit(`option:${h.name()}`);u=h.variadic?h:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let h=this._findOption(`-${a[1]}`);if(h){h.required||h.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${h.name()}`,a.slice(2)):(this.emit(`option:${h.name()}`),l=`-${a.slice(2)}`);continue}}if(/^--[^=]+=/.test(a)){let h=a.indexOf("="),p=this._findOption(a.slice(0,h));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,a.slice(h+1));continue}}if(i===t&&r(a)&&!(this.commands.length===0&&o(a))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(a)){t.push(a),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a,...e.slice(c));break}else if(this._defaultCommandName){n.push(a,...e.slice(c));break}}if(this._passThroughOptions){i.push(a,...e.slice(c));break}i.push(a)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
23
|
-
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
24
|
-
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
25
|
-
`),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,r=n.code||"commander.error";this._exit(i,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in m.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,m.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new V(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=o=>{let u=o.attributeName(),l=this.getOptionValue(u),c=this.options.find(h=>h.negate&&u===h.attributeName()),a=this.options.find(h=>!h.negate&&u===h.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:a||o},i=o=>{let u=n(o),l=u.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},r=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(u=>u.long).map(u=>u.long);i=i.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);t=q(e,i)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",i=e.length,r=this.parent?` for '${this.name()}'`:"",o=e.join(", "),u=`error: too many arguments${r}. Expected ${t} argument${n} but got ${i}: ${o}.`;this.error(u,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(r=>{i.push(r.name()),r.alias()&&i.push(r.alias())}),t=q(e,i)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
26
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>N(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=C.basename(e,C.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,r;return t?(n=u=>this._outputConfiguration.writeErr(u),i=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(n=u=>this._outputConfiguration.writeOut(u),i=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:t,write:u=>(i||(u=this._outputConfiguration.stripColor(u)),n(u)),hasColors:i,helpWidth:r}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation({error:n.error});if(t&&(r=t(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(m.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
27
|
-
Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,r=>{let o;typeof t=="function"?o=t({error:r.error,command:r.command}):o=t,o&&r.write(`${o}
|
|
28
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ee(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],n=r[3],i=r[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function te(){if(m.env.NO_COLOR||m.env.FORCE_COLOR==="0"||m.env.FORCE_COLOR==="false")return!1;if(m.env.FORCE_COLOR||m.env.CLICOLOR_FORCE!==void 0)return!0}var et=new $;function he(s){let[,e,t,...n]=s;if(e===void 0||e==="list")return{kind:"config",action:"list"};if(e==="path")return{kind:"config",action:"path"};if(e==="set"){if(t===void 0||!W.includes(t))throw d(`Unknown config setting ${t??"(none)"}.`,`Try one of: ${W.join(", ")}.`);let i=n.join(" ");if(i.length===0)throw d(`forge config set ${t} needs a value.`);return{kind:"config",action:"set",key:t,value:i}}throw d(`Unknown config action ${e}.`,"Try: forge config list, forge config set <setting> <value>, or forge config path.")}var de={jpg:"jpeg",tif:"tiff",heif:"heic"};function I(s){let e=s.toLowerCase().replace(/^\./,""),t=z(de[e]??e);if(!t)throw d(`${s} is not a format Forge knows.`,"Run forge --formats to see what is available.");return t.id}function P(s,e,t,n,i){let r=Number(String(e).replace(/k$/i,""));if(!Number.isFinite(r)||r<t||r>n)throw d(`${s} takes ${t} to ${n}, not ${e}.`,`For example ${s} ${i}.`);return r}function pe(s){let e={};if(s.cut!==void 0){let t=J(String(s.cut));if(!t)throw d(`--cut takes a start and an end, the end after the start, not ${s.cut}.`,"For example --cut 0:03.2-0:41, or --cut 0:10- to keep from 0:10 to the end.");e.cut=t.end===void 0?{start:t.start}:{start:t.start,end:t.end}}return s.mute&&(e.mute=!0),s.speed!==void 0&&(e.speed=P("--speed",s.speed,.25,4,"2")),s.fps!==void 0&&(e.fps=P("--fps",s.fps,1,120,"30")),s.bitrate!==void 0&&(e.bitrate=Math.round(P("--bitrate",s.bitrate,32,320,"128k"))),s.loudness!==void 0&&(e.loudness=P("--loudness",s.loudness,-70,-5,"-16")),s.cleanAudio&&(e.cleanup=!0,e.loudness??=-16),Object.keys(e).length?e:void 0}function S(s){let e=Number(s);if(!Number.isInteger(e)||e<1||e>100)throw d(`Quality must be a whole number between 1 and 100, not ${s}.`);return e}function ne(s,e){let t=/^\d+$/.test(String(e))?Number(e):Number.NaN;if(!Number.isInteger(t)||t<1)throw d(`${s} takes a whole number of pixels, at least 1, not ${e}.`);return t}function fe(s){let e=String(s),t=/^\d+(\.\d+)?%?$/.test(e)?Number.parseFloat(e):Number.NaN;if(!(t>=1&&t<=D))throw d(`--resize takes a percent from 1 to ${D}, not ${s}.`,"Try --resize 50% to halve, or --width 1200 for an exact width.");return t}function j(s){let e=Number(s);if(!Number.isInteger(e)||e<1)throw d(`Concurrency must be a positive whole number, not ${s}.`);return e}var me=`
|
|
29
|
-
Exit codes:
|
|
30
|
-
0 every input succeeded
|
|
31
|
-
1 the command was understood, and at least one input failed or was refused
|
|
32
|
-
2 the command itself was invalid: an unknown flag, a missing argument, contradictory flags`,ie=`
|
|
33
|
-
Other commands:
|
|
34
|
-
forge probe <files...> what each file is and what Forge can do with it
|
|
35
|
-
forge palette <image> an image's main colours (--json, --svg, --inside <hex>)
|
|
36
|
-
forge scale <colour> 50\u2013950 from one colour, with it at 500 (--json, --svg)
|
|
37
|
-
forge card <file> named colours as a card to paste into Figma
|
|
38
|
-
(--svg, --json, --title <text>; - reads stdin)
|
|
39
|
-
forge clip compress the copied image and put it back (--to, --quality,
|
|
40
|
-
--max-size, --save [folder], --undo)
|
|
41
|
-
forge transcribe <file | link>
|
|
42
|
-
a video or audio file, or a YouTube link, into notes
|
|
43
|
-
(--to all | notes | transcript, --detail brief | standard | detailed,
|
|
44
|
-
--format md | docx | pdf | txt, --language <id>, -o <path>, --force)
|
|
45
|
-
forge watch <folder> --to <format>
|
|
46
|
-
convert the folder, then every file added to it, until ctrl-c
|
|
47
|
-
(--quality, --dpi, -o <folder>, --new-only, --json)
|
|
48
|
-
forge config [list | path | set <setting> <value>]
|
|
49
|
-
forge extensions [add | remove <id>] optional extras, such as boost and remove-background
|
|
50
|
-
forge update install a newer Forge, if there is one
|
|
51
|
-
forge uninstall take Forge out of the right-click menu, then remove it
|
|
52
|
-
forge mcp run as a local MCP server over stdio, for AI agents`;function ge(s=process.platform){if(s==="darwin")return ie;let e=s==="win32"?"boost and whisper":"whisper and heic";return ie.replace("a video or audio file, or a YouTube link, into notes","a video or audio file, or a YouTube link, into a transcript").replace("optional extras, such as boost and remove-background",`optional extras, such as ${e}`)}function B(s){let e=L(String(s));if(e===void 0)throw d(`${s} is not a size.`,"Try a number with a unit, for example 500kb, 2mb or 1.5mb.");return e}function be(s){let e=s.slice(1).filter(n=>n!=="--json"),t=e.find(n=>n.startsWith("-"));if(t!==void 0)throw d(`forge probe takes files, not ${t}.`,"Try: forge probe photo.jpg --json");if(e.length===0)throw d("No files given.","Name a file, for example: forge probe scan.pdf --json");return{kind:"probe",inputs:e}}function _e(s){let e={kind:"clip",undo:!1,debug:!1},t=s.slice(1),n=(i,r)=>{let o=t[r+1];if(o===void 0||o.startsWith("-"))throw d(`${i} needs a value.`);return o};for(let i=0;i<t.length;i++){let r=t[i];if(r!=="--json")if(r==="--debug")e.debug=!0;else if(r==="--undo")e.undo=!0;else if(r==="--to"||r==="-t")e.target=I(n(r,i++));else if(r==="--quality"||r==="-q")e.quality=S(n(r,i++));else if(r==="--max-size")e.maxBytes=B(n(r,i++));else if(r==="--save"){let o=t[i+1];e.save=o===void 0||o.startsWith("-")?!0:t[++i]}else throw r.startsWith("-")?d(`forge clip does not take ${r}.`,"Try: forge --help"):d(`forge clip takes no files: it reads the clipboard, not ${r}.`,`To compress a file, try: forge ${r} --quality 80`)}if(e.undo&&Object.keys(e).some(i=>!["kind","undo","debug"].includes(i)))throw d("--undo takes no other flag.","Try: forge clip --undo");if(e.quality!==void 0&&e.maxBytes!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");return e}function we(s){let e=s.slice(1),t=[],n={kind:"transcribe",input:"",notes:!0,transcript:!0,detail:Q,force:!1,debug:!1},i=(l,c)=>{let a=e[c+1];if(a===void 0||a.startsWith("-"))throw d(`${l} needs a value.`);return a},r="Try: forge transcribe talk.mp4";for(let l=0;l<e.length;l++){let c=e[l];if(c==="--debug")n.debug=!0;else if(c==="--force"||c==="-f")n.force=!0;else if(c==="--language"||c==="-l")n.language=i(c,l++);else if(c==="--output"||c==="-o")n.output=i(c,l++);else if(c==="--detail"){let a=i(c,l++).toLowerCase();if(!X.includes(a))throw d(`forge transcribe writes notes in brief, standard or detailed, not ${a}.`,"Try: forge transcribe talk.mp4 --detail brief");n.detail=a}else if(c==="--format"){let a=i(c,l++).toLowerCase(),h=Y.find(p=>p.id===a||p.label.toLowerCase()===a);if(h===void 0)throw d(`forge transcribe writes md, docx, pdf or txt, not ${a}.`,"Try: forge transcribe talk.mp4 --format pdf");n.format=h.id}else if(c==="--to"||c==="-t"){let a=i(c,l++).toLowerCase();if(a!=="all"&&a!=="notes"&&a!=="transcript")throw d(`forge transcribe makes all, notes or a transcript, not ${a}.`,"Try: forge transcribe talk.mp4 --to transcript");n.to=a,n.notes=a!=="transcript",n.transcript=a!=="notes"}else{if(c.startsWith("-"))throw d(`forge transcribe does not take ${c}.`,r);t.push(c)}}let[o,...u]=t;if(o===void 0)throw d("forge transcribe needs a file or a link.",r);if(u.length>0)throw d("forge transcribe takes one file or link at a time.",r);return{...n,input:o}}function ye(s){let e=s.slice(1),t=[],n,i={kind:"watch",newOnly:!1,debug:!1},r={},o=(c,a)=>{let h=e[a+1];if(h===void 0||h.startsWith("-"))throw d(`${c} needs a value.`);return h};for(let c=0;c<e.length;c++){let a=e[c];if(a!=="--json")if(a==="--debug")i.debug=!0;else if(a==="--new-only")i.newOnly=!0;else if(a==="--to"||a==="-t")n=I(o(a,c++));else if(a==="--quality"||a==="-q")r.quality=S(o(a,c++));else if(a==="--output"||a==="-o")r.output=o(a,c++);else if(a==="--dpi"){let h=o(a,c++),p=Number(h);if(!Number.isInteger(p)||p<36||p>600)throw H(h);r.dpi=p}else{if(a.startsWith("-"))throw d(`forge watch does not take ${a}.`,"Try: forge watch ./images --to webp");t.push(a)}}let[u,...l]=t;if(u===void 0)throw d("forge watch needs a folder.","Try: forge watch ./images --to webp");if(l.length>0)throw d("forge watch watches one folder at a time.",`Try: forge watch ${u} --to webp`);if(n===void 0)throw d("forge watch needs a format to convert to.",`Try: forge watch ${u} --to webp`);return{kind:"watch",folder:u,target:n,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:r.dpi},...r.output===void 0?{}:{output:r.output},newOnly:i.newOnly,debug:i.debug}}function xe(s){let e=s.slice(1).filter(o=>o!=="--json"),t=e.find(o=>o.startsWith("-"));if(t!==void 0)throw d(`forge extensions does not take ${t}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");let[n,i,...r]=e;if(n===void 0)return{kind:"extensions",action:"list"};if(n!=="add"&&n!=="remove")throw d(`Unknown extensions action ${n}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");if(i===void 0||r.length>0)throw d(`forge extensions ${n} takes exactly one extension.`,`Try: forge extensions ${n} boost`);return{kind:"extensions",action:n,id:i}}function re(s){if(s===void 0)throw d("No colour given.","Try: forge scale 6579FD \u2014 or quote it, '#6579FD', because an unquoted # starts a comment in the shell.");let e=M(s)?.rgb;if(!e)throw d(`${s} is not a colour.`,"Try a hex code (6579FD), rgb(), hsl(), oklch() or a colour name, quoted: 'rgb(101 121 253)'.");return e}function Oe(s,e=process.platform,t=process.env){let r=e==="linux"&&!t.WAYLAND_DISPLAY&&!!t.DISPLAY?" --svg a card of swatches; pipe to xclip -sel c, paste into Figma":` --svg a card of swatches; pipe to ${e==="win32"?"clip":e==="linux"?"wl-copy":"pbcopy"} and paste into Figma`;return s==="card"?`Usage: forge card <file> [--json] [--svg] [--title <text>]
|
|
53
|
-
|
|
54
|
-
Named colours from design tokens, a CSV, CSS variables or one a line
|
|
55
|
-
(bg #F8F1E6). - reads them from stdin.
|
|
56
|
-
--json one JSON document: card.colours[] with name and hex
|
|
57
|
-
${r}
|
|
58
|
-
--title <text> the card's heading; the file's name if not given
|
|
59
|
-
`:s==="scale"?`Usage: forge scale <colour> [--json] [--svg]
|
|
60
|
-
|
|
61
|
-
50\u2013950 built in OKLCH, with <colour> at 500. Pass the hex without #, or quote it.
|
|
62
|
-
--json one JSON document: scale.steps[] with hex, oklch, white, black
|
|
63
|
-
${r}
|
|
64
|
-
`:`Usage: forge palette <image> [--json] [--svg] [--inside <hex>]
|
|
65
|
-
|
|
66
|
-
An image's main colours, most of the image first.
|
|
67
|
-
--json one JSON document: palette.colours[] with hex, rgb, oklch, share
|
|
68
|
-
${r}
|
|
69
|
-
--inside <hex> the shades of the palette colour nearest <hex>
|
|
70
|
-
`}function Ce(s){let[e,...t]=s;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(Oe(e==="scale"?"scale":e==="card"?"card":"palette")),new O(0,"commander.helpDisplayed","(outputHelp)");if(e==="card")return ve(t);let n=t.filter(l=>l!=="--json"&&l!=="--svg"),i=t.includes("--svg"),r=n.indexOf("--inside"),o=r===-1?void 0:n[r+1];r!==-1&&n.splice(r,2);let u=n.find(l=>l.startsWith("-"));if(u!==void 0)throw d(`forge ${e} does not take ${u}.`,`Try: forge ${e} --help`);if(e==="scale"){if(r!==-1)throw d("--inside is for forge palette.","Try: forge palette photo.jpg --inside F26E69");if(n.length>1)throw d("forge scale takes one colour.","Try: forge scale 6579FD");return{kind:"scale",colour:re(n[0]),svg:i}}if(n.length!==1)throw d(n.length===0?"No image given.":"forge palette takes one image.","Try: forge palette photo.jpg");return{kind:"palette",input:n[0],svg:i,...r===-1?{}:{inside:re(o)}}}function ve(s){let e=s.filter(o=>o!=="--json"&&o!=="--svg"),t=s.includes("--svg"),n=e.indexOf("--title"),i=n===-1?void 0:e[n+1];if(n!==-1){if(i===void 0||i.trim()==="")throw d("--title needs the heading.","Try: forge card palette.csv --title 'Cream blue'");e.splice(n,2)}let r=e.find(o=>o.startsWith("-")&&o!=="-");if(r!==void 0)throw d(`forge card does not take ${r}.`,"Try: forge card --help");if(e.length!==1)throw d(e.length===0?"No file given.":"forge card takes one file.","Try: forge card palette.csv --svg");return{kind:"card",input:e[0],svg:t,...i===void 0?{}:{title:i}}}function mt(s){let e=s.indexOf("--");return(e===-1?s:s.slice(0,e)).includes("--json")}function ke(s){let e=s.indexOf("--"),t=e===-1?s:s.slice(0,e),n=e===-1?[]:s.slice(e),i=[],r;for(let o=0;o<t.length;o++){let u=t[o],l=u.startsWith("--boost=")?u.slice(8):void 0;if(u!=="--boost"&&l===void 0){i.push(u);continue}let c=l;if(c===void 0&&/^\d+$/.test(t[o+1]??"")&&(c=t[++o]),c!==void 0&&c!=="2"&&c!=="3"&&c!=="4")throw d(`--boost takes 2, 3 or 4, not ${c}.`,"Try --boost, --boost 2, --boost 3 or --boost 4.");r=c==="4"?4:c==="3"?3:2}return{rest:[...i,...n],...r===void 0?{}:{scale:r}}}function gt(s){let e=s;if(e[0]==="clip"||e[0]==="watch"||e[0]==="transcribe"||e[0]==="config"||e[0]==="probe"||e[0]==="extensions"||e[0]==="palette"||e[0]==="scale"||e[0]==="card"||e[0]==="update"||e[0]==="uninstall")return Ae(e);let t=ke(e);return $e(t.rest,t.scale)}function Ae(s){if(s[0]==="update"){let e=s.slice(1).filter(t=>t!=="--json");if(e.length>0)throw d(`forge update takes nothing else, got: ${e.join(" ")}.`,"Try: forge update");return{kind:"update"}}if(s[0]==="uninstall"){let e=s.slice(1);if(e.length>0)throw d(`forge uninstall takes nothing else, got: ${e.join(" ")}.`,"Try: forge uninstall");return{kind:"uninstall"}}return s[0]==="clip"?_e(s):s[0]==="watch"?ye(s):s[0]==="transcribe"?we(s):s[0]==="config"?he(s.filter(e=>e!=="--json")):s[0]==="probe"?be(s):s[0]==="palette"||s[0]==="scale"||s[0]==="card"?Ce(s):xe(s)}function $e(s,e){let t=new $().name("forge").description("Convert \u2014 transform your files from the terminal").argument("[inputs...]","files, folders or globs").option("-t, --to <format>","target format").option("-o, --output <path>","output file or directory").option("-q, --quality <n>","quality for lossy formats, 1-100").option("--background <colour>","fill colour when flattening transparency","#ffffff").option("--keep-metadata","preserve EXIF and GPS data",!1).option("--recursive","descend into subfolders",!1).option("--force","allow overwriting existing files",!1).option("--max-size <size>","compress until the file fits, e.g. 500kb").option("--concurrency <n>","how many files to convert at once").option("--debug","show underlying errors",!1).option("--formats","list supported formats",!1).option("--merge","combine several PDFs into one").option("--split <mode>","every-page | every=N | at=N,N").option("--extract <pages>","keep only these pages, e.g. 3-7,12").option("--delete <pages>","drop these pages").option("--rotate <degrees>","90, 180 or 270").option("--separate","with --extract, write one file per page").option("--sharpen","sharpen at the same size; needs the boost extension").option("--boost [2|3|4]","sharpen and enlarge 2x (default), 3x or 4x; needs the boost extension").option("--trim","cut transparent or solid-colour edges; keeps the format").option("--crop <W:H>","cut to a shape, e.g. 1:1, 4:5, 16:9; keeps the subject").option("--resize <percent>","resize to a percent of the size, 1-200, e.g. 50%").option("--width <px>","resize to this width; the height follows").option("--height <px>","resize to this height; the width follows").option("--remove-bg","cut out the subject; needs the remove-background extension").option("--cut <start-end>","video or audio: keep from start to end, e.g. 0:03.2-0:41").option("--mute","video: take the sound out").option("--speed <x>","video or audio: play faster or slower, 0.25-4").option("--fps <n>","video: frames per second").option("--bitrate <kbps>","audio: bitrate, e.g. 128k").option("--loudness <LUFS>","audio: even out loudness to this level, e.g. -16").option("--clean-audio","video or audio: take out rumble and hiss, then even the level").option("--preset <name>","run a preset saved from Done, e.g. --preset blog").option("--pages <ranges>","with --to, which pages to render, e.g. 3-7,12").option("--dpi <n>","rasterisation resolution, 36-600","150").option("--password-stdin","read an encrypted PDF's password from stdin").option("--json","print one JSON document on stdout instead of text").helpOption("-h, --help","show this help").version(K,"-V, --version","show the version").addHelpText("after",`${ge()}
|
|
71
|
-
${me}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(s,{from:"user"})}catch(f){if(f instanceof O&&f.code!=="commander.helpDisplayed"&&f.code!=="commander.version"){let[g="",...b]=f.message.replace(/^error: /,"").split(`
|
|
72
|
-
`),w=b.join(" ").trim().replace(/^\((.*)\)\.?$/,"$1");throw d(`${g.charAt(0).toUpperCase()}${g.slice(1).replace(/\.$/,"")}.`,w||"Run forge --help to see what Forge accepts.")}throw f}let n=t.opts(),i=t.args;if(n.formats)return{kind:"formats"};let r=pe(n);if(r!==void 0&&n.trim)throw d("--trim cuts the empty edges of an image.","To keep part of a video or audio file, use --cut, for example --cut 0:03-0:41.");if(n.preset!==void 0){let f=[["to","--to"],["quality","--quality"],["maxSize","--max-size"],["merge","--merge"],["split","--split"],["extract","--extract"],["delete","--delete"],["rotate","--rotate"],["sharpen","--sharpen"],["trim","--trim"],["crop","--crop"],["resize","--resize"],["width","--width"],["height","--height"],["removeBg","--remove-bg"],["pages","--pages"]].filter(([g])=>n[g]!==void 0&&n[g]!==!1).map(([,g])=>g);if(e!==void 0&&f.push("--boost"),f.length>0)throw d(`--preset already says what to do \u2014 leave out ${f.join(" and ")}.`,"Run the preset alone, or change it from Done with \u2192 continue editing.");return{kind:"preset",inputs:i,name:String(n.preset),...n.output===void 0?{}:{output:String(n.output)},force:n.force===!0,recursive:n.recursive===!0,debug:n.debug===!0}}if(n.pages!==void 0&&n.to===void 0)throw d("--pages needs --to: it chooses which pages to render.");let o=["merge","split","extract","delete","rotate"].filter(f=>n[f]!==void 0);if(o.length>1)throw d(`Use one operation at a time \u2014 got ${o.map(f=>`--${f}`).join(" and ")}.`);let u=[...n.sharpen?["--sharpen"]:[],...e!==void 0?["--boost"]:[],...n.removeBg?["--remove-bg"]:[]],l=[...n.resize!==void 0?["--resize"]:[],...n.width!==void 0?["--width"]:[],...n.height!==void 0?["--height"]:[]],c=r!==void 0&&!n.to&&n.quality===void 0&&n.maxSize===void 0;if(n.trim||n.crop!==void 0||l.length>0||c){if(l.length>1)throw d(`Use one of --resize, --width and --height \u2014 got ${l.join(" and ")}.`);let f=n.crop!==void 0?"--crop":l[0]??(n.trim?"--trim":"--cut"),g=[...n.crop!==void 0&&n.trim?["--trim"]:[],...u,...n.maxSize!==void 0?["--max-size"]:[],...n.pages!==void 0?["--pages"]:[],...o.map(oe=>`--${oe}`)][0];if(g!==void 0)throw d(`${f} cannot be combined with ${g}.`,g!=="--max-size"?"Run them one after the other.":f==="--crop"?"Crop first, then compress the result: forge photo-cropped-1x1.jpg --max-size 500kb":"Resize first, then compress the result: forge photo-1200x900.jpg --max-size 500kb");let b=n.crop!==void 0?{aspect:R(String(n.crop))}:void 0,w=n.resize!==void 0?{percent:fe(n.resize)}:n.width!==void 0?{width:ne("--width",n.width)}:n.height!==void 0?{height:ne("--height",n.height)}:void 0;if(i.length===0)throw d("No files given.","Name an image, for example: forge photo.jpg --resize 50%");let v={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(v.quality=S(String(n.quality)));let y={kind:"edit",inputs:i,trim:!!n.trim,options:v,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return b!==void 0&&(y.crop=b),w!==void 0&&(y.resize=w),r!==void 0&&(y.media=r),n.to&&(y.target=I(String(n.to))),n.output!==void 0&&(y.output=String(n.output)),n.concurrency!==void 0&&(y.concurrency=j(String(n.concurrency))),y}let a=n.sharpen?1:e,h=a!==void 0?"boost":n.removeBg?"remove-background":null;if(h!==null){if(u.length>1)throw d(`Use one operation at a time \u2014 got ${u.join(" and ")}.`);let f=u[0];if(o.length>0)throw d(`${f} cannot be combined with --${o[0]}.`);if(n.maxSize!==void 0||n.pages!==void 0)throw d(`${f} cannot be combined with ${n.maxSize!==void 0?"--max-size":"--pages"}.`);if(i.length===0)throw d("No files given.",`Name an image, for example: forge photo.jpg ${f}`);let g=n.to?I(String(n.to)):"png";if(h==="remove-background"){let v=U(g);if(v)throw v}let b={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(b.quality=S(String(n.quality)));let w={kind:"extension-op",op:h,inputs:i,target:g,options:b,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return a!==void 0&&(w.scale=a),n.output!==void 0&&(w.output=String(n.output)),n.concurrency!==void 0&&(w.concurrency=j(String(n.concurrency))),w}if(o.length===1){let f=o[0];if(i.length===0)throw d("No files given.",`Name a PDF, for example: forge doc.pdf --${f}`);if(n.separate&&f!=="extract")throw d(`--separate only applies to --extract, not --${f}.`);if(n.output!==void 0)throw d(`--output does not apply to --${f}.`,"Page operations name their own outputs, beside the source. Rename the result afterwards.");let g={kind:"pageop",action:f,inputs:i,force:!!n.force,debug:!!n.debug};if(f==="rotate"){let b=Number(n.rotate);if(!Number.isInteger(b)||b%90!==0||b===0||b>=360)throw d(`--rotate takes a multiple of 90 below 360, not "${n.rotate}".`);g.rotate=b}if((f==="extract"||f==="delete")&&(g.pages=String(n[f]),f==="extract"&&n.separate&&(g.separate=!0)),f==="split"){let b=String(n.split),w=b.match(/^every=(\d+)$/),v=b.match(/^at=([\d,\s]+)$/);if(b==="every-page")g.split={mode:"every-page"};else if(w?.[1]!==void 0){let y=Number(w[1]);if(!Number.isInteger(y)||y<1)throw d(`--split every=N takes a whole number of pages, at least 1, not "${w[1]}".`);g.split={mode:"every-n",n:y}}else if(v?.[1])g.split={mode:"points",after:v[1].split(",").map(y=>Number(y.trim()))};else throw d(`--split takes every-page, every=N or at=N,N \u2014 not "${b}".`)}return g}if(i.length===0&&!n.to&&n.quality===void 0&&n.maxSize===void 0)return{kind:"shell"};if(n.quality!==void 0&&n.maxSize!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");if(!n.to&&(n.quality!==void 0||n.maxSize!==void 0)){if(i.length===0)throw d("No files given.","Name a file, for example: forge photo.jpg --max-size 500kb");let f={background:String(n.background),keepMetadata:!!n.keepMetadata};r!==void 0&&(f.media=r);let g={kind:"compress",inputs:i,options:f,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};if(n.quality!==void 0&&(g.quality=S(String(n.quality))),n.maxSize!==void 0&&(g.maxBytes=B(n.maxSize)),n.output!==void 0&&(g.output=String(n.output)),t.getOptionValueSource("dpi")==="cli"){let b=Number(n.dpi);if(!Number.isInteger(b)||b<36||b>600)throw H(n.dpi);g.dpi=b}return n.concurrency!==void 0&&(g.concurrency=j(String(n.concurrency))),g}if(!n.to)throw d("No target format given.","Add --to <format>, for example: forge photo.jpg --to webp");if(i.length===0)throw d("No files given.","Name a file, a folder or a glob, for example: forge photo.jpg --to webp");let p={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(p.quality=S(String(n.quality))),r!==void 0&&(p.media=r);let x=Number(n.dpi);if(!Number.isInteger(x)||x<36||x>600)throw H(n.dpi);let _={kind:"convert",inputs:i,target:I(String(n.to)),options:p,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug,dpi:x,passwordStdin:!!n.passwordStdin};return n.output!==void 0&&(_.output=String(n.output)),n.pages!==void 0&&(_.pages=String(n.pages)),n.maxSize!==void 0&&(_.maxBytes=B(n.maxSize)),n.concurrency!==void 0&&(_.concurrency=j(String(n.concurrency))),_}export{me as a,ie as b,ge as c,Oe as d,mt as e,gt as f};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as E}from"./chunk-O7DK3GJT.js";import{i as R}from"./chunk-K253E723.js";import{a as F,ma as y}from"./chunk-ZBMJTIYR.js";function P(n=process.env){let r=Number(n.UV_THREADPOOL_SIZE),o=E();return Number.isInteger(r)&&r>0?Math.min(o,r):o}function w(n){let r=n!==void 0&&Number.isFinite(n)?n:void 0;return Math.max(1,r??P())}async function x(n,r,o,f){let b=[],l=[];for(let[i,u]of n.entries())(f?.(u)?l:b).push(i);let p=0,m=0,t,g=async()=>{for(;;){let i=b[p],u=t?void 0:l[m];if(i!==void 0&&(u===void 0||i<u))p++,await o(n[i],i);else if(u!==void 0)m++,t=o(n[u],u).finally(()=>{t=void 0}),await t;else if(t)await t;else return}},d=Math.min(w(r),n.length);await Promise.all(Array.from({length:d},g))}async function T(n,r){let o=r.onEvent??(()=>{}),f=r.engineFor??R,b=w(r.concurrency),l=n.length,p=[],m=[],t=0;await x(n,b,async(e,a)=>{if(r.signal?.aborted)return;o({type:"job:start",job:e,index:a,total:l});let h=f(e);if(!h){t++;let s=e.sources[0].path,c={path:s,error:y(s,new Error(`no engine runs ${e.op}`))};m[a]=c,o({type:"job:error",job:e,failure:c,completed:t,total:l});return}try{let s=await h.run(e,c=>o({type:"job:phase",job:e,progress:c}),r.signal);p[a]=s,t++,o({type:"job:done",job:e,result:s,completed:t,total:l})}catch(s){t++;let c=e.sources[0].path,J=F(s)?s:y(c,s),v={path:c,error:J};m[a]=v,o({type:"job:error",job:e,failure:v,completed:t,total:l})}},e=>f(e)?.alone===!0);let d=p.filter(e=>e!==void 0),i=m.filter(e=>e!==void 0),u={results:d,failures:i,inputBytes:d.reduce((e,a)=>e+a.job.sources[0].bytes,0),outputBytes:d.reduce((e,a)=>e+a.outputBytes,0)};return o({type:"batch:done",summary:u}),u}export{P as a,w as b,x as c,T as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as h,c as A,g as o,m as y,n as I,t as v,u as O,v as P}from"./chunk-BKLPRILS.js";import{a as x,b as u,d as S}from"./chunk-K253E723.js";import{g as s,h as f,j as g,k as b,l as c,m as a}from"./chunk-V6GWPR2A.js";import{G as d}from"./chunk-ZBMJTIYR.js";var l=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0,k={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:e=>(l(e)?.pages??0)>1,unavailable:e=>l(e)===void 0?"one PDF at a time":"only one page",options(e){let t=l(e);return t?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${t.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(e,t){let n=l(e);if(!n)return[];let r=Array.isArray(t.cuts)?t.cuts:[],i=S(r,n.pages).length,C=c(f(n.path,i),o(t.destination),o(t.name));return[{op:"split",sources:[n],outputs:C,cuts:r}]}};function $(e){return Array.from({length:Math.max(0,e-1)},(t,n)=>n)}function B(e,t){if(!Number.isInteger(t)||t<1)throw d("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let r=t;r<e;r+=t)n.push(r-1);return n}var p=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0;function D(e,t){return Array.isArray(t.pages)?u(t.pages):typeof t.pages=="string"?u(x(t.pages,e.pages)):[]}var w=e=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${e.pages}`}),T={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:e=>p(e)!==void 0,unavailable:()=>"one PDF at a time",options:e=>{let t=p(e);return t?[w(t),{kind:"select",id:"separate",label:"Output",default:"one",choices:[{value:"one",label:"One file",hint:"all selected pages together"},{value:"many",label:"Separate files",hint:"one per page"}]}]:[]},plan(e,t){let n=p(e);if(!n)return[];let r=D(n,t),i=t.separate==="many";return[{op:"extract",sources:[n],outputs:c(g(n.path,r,i),o(t.destination),o(t.name)),pages:r,separate:i}]}},j={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:e=>p(e)!==void 0,unavailable:()=>"one PDF at a time",options:e=>{let t=p(e);return t?[w(t)]:[]},plan(e,t){let n=p(e);return n?[{op:"delete",sources:[n],outputs:[a(s(n.path,"trimmed"),o(t.destination),o(t.name))],pages:D(n,t)}]:[]}};var m=e=>e.filter(t=>t.kind==="document"&&t.format==="pdf"),J={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:e=>m(e).length>=2&&m(e).length===e.length,unavailable:e=>m(e).length!==e.length?"PDFs only":"needs 2+ files",options:()=>[],plan(e,t){let n=a(b(e.map(r=>r.path)),o(t.destination),o(t.name));return[{op:"merge",sources:e,outputs:[n]}]}};var N=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0,E={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:e=>N(e)!==void 0,unavailable:()=>"one PDF at a time",options:()=>[{kind:"select",id:"degrees",label:"Turn",default:"90",choices:[{value:"90",label:"90\xB0 right",hint:"a quarter turn"},{value:"180",label:"180\xB0",hint:"upside down"},{value:"270",label:"90\xB0 left",hint:"a quarter turn back"}]}],plan(e,t){let n=N(e);if(!n)return[];let i=Number(t.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[a(s(n.path,"rotated"),o(t.destination),o(t.name))],turns:i}]}};var R=[I,y,J,k,T,j,E,v,O,P],se=R.filter(e=>!["convert","compress","trim","resize","crop"].includes(e.id)),F=[h,A];function ce(e,t=new Set){return[...R,...F.filter(n=>n.requires&&t.has(n.requires))].filter(n=>n.appliesTo(e))}function le(e,t){return e.appliesTo(t)?void 0:e.unavailable?.(t)}export{E as a,k as b,$ as c,B as d,R as e,se as f,ce as g,le as h};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as b,c as G}from"./chunk-Q6KQWJ4J.js";import{d as W,f as y,g as K}from"./chunk-FBVRKMAF.js";import{a as Q,b as X,e as w}from"./chunk-3374PCO5.js";import{a as H,b as P}from"./chunk-K253E723.js";import{a as h,d as R}from"./chunk-N6RCLJE6.js";import{i as F,j as U,k as g}from"./chunk-TLHUFIXD.js";import{d as I,l as z}from"./chunk-4MJEEEFA.js";import{b as B,c as J,d as L,e as u,i as _,m as O}from"./chunk-V6GWPR2A.js";import{G as k,u as N}from"./chunk-ZBMJTIYR.js";import{a as s,b as D,c as $}from"./chunk-H3DIRJFE.js";var M=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function Gt(t,e){let n=Q(t);return n.includes(e)?void 0:N(t,e,n)}function V(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 Y=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:s.png.hint}]}),dt=t=>t===1?"sharp":`${t}x`,ut=t=>t===1||t===3||t===4?t:2,Ht={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=>M(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"}]},Y()],plan(t,e){let n=M(t);if(!n)return[];let o=V(e),i=ut(Number(e.scale??2));return n.map(r=>({op:"boost",sources:[r],outputs:[u({sourcePath:r.path,target:o.target,suffix:dt(i),...o.output===void 0?{}:{output:o.output},...o.roots?.get(r.path)===void 0?{}:{sourceRoot:o.roots.get(r.path)}})],scale:i,target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}},Wt={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>M(t)!==void 0,unavailable:()=>"images only",options:()=>[Y()],plan(t,e){let n=M(t);if(!n)return[];let o=V(e);return n.map(i=>({op:"remove-background",sources:[i],outputs:[u({sourcePath:i.path,target:o.target,suffix:"cutout",...o.output===void 0?{}:{output:o.output},...o.roots?.get(i.path)===void 0?{}:{sourceRoot:o.roots.get(i.path)}})],target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}};var ft=[{degrees:90,label:"90\xB0 right",suffix:"rotated-right"},{degrees:180,label:"180\xB0",suffix:"rotated-180"},{degrees:270,label:"90\xB0 left",suffix:"rotated-left"}],S=t=>t===90||t===180||t===270,Vt=(t,e)=>e===180?{...t}:{width:t.height,height:t.width},T=t=>ft.find(e=>e.degrees===t).suffix;import{dirname as ct,join as Z}from"node:path";var q="Same location",v="New subfolder";function mt(t,e,n){return t===e?q:t===h("Desktop")?"Desktop":t===h("Downloads")?"Downloads":e!==void 0&&n!==void 0&&t===Z(e,n)?v:b(t)||t}function A(t,e,n={}){return lt(ct(t.path),e,n)}function lt(t,e,{subfolder:n}={}){let o=R(e.defaultOutput),i=e.lastOutput?R(e.lastOutput):void 0,r=f=>({label:mt(f,t,n),path:f}),a=[r(o),...i?[r(i)]:[],r(h("Desktop")),...t===void 0?[]:[{label:q,path:t}],r(h("Downloads")),...n!==void 0&&t!==void 0?[{label:v,path:Z(t,n)}]:[]],p=new Set,d=a.filter(f=>p.has(f.path)?!1:(p.add(f.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:d,...i&&i!==o?{last:i}:{}}}var c=t=>typeof t=="string"&&t!==""?t:void 0;var pe=[2,1.5,1.25,.75,.5],gt=.25,ht=4,tt=-16;function nt(t){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[t]??t}var et=t=>t.length===1&&t[0]?.kind==="media"?t[0]:void 0,bt=t=>t==="cut"||t==="mute"||t==="speed"||t==="resize"||t==="crop"||t==="rotate"||t==="loudness"||t==="extract"||t==="cleanup";function yt(t,e){let n=e.media??{},o=t.facts?.video,i=[];return e.extract&&i.push("audio"),n.cut&&i.push("trimmed"),n.mute&&i.push("muted"),n.cleanup?i.push("cleaned"):n.loudness!==void 0&&i.push("levelled"),n.speed!==void 0&&i.push(`${n.speed}x`),n.fps!==void 0&&i.push(`${n.fps}fps`),n.bitrate!==void 0&&i.push(`${n.bitrate}k`),e.crop&&i.push(z(e.crop.aspect)),e.resize&&i.push(o?y(g(o,e.resize)):"resized"),e.rotate&&i.push(T(e.rotate)),i.length===1?i[0]:"edited"}function St(t,e){return t.map(n=>{let o=e.target??n.format,i={background:"#ffffff",keepMetadata:!1};e.media&&Object.keys(e.media).length&&(i.media=e.media),e.resize&&(i.resize=e.resize),e.rotate&&(i.rotate=e.rotate);let r=n.facts?.video;e.crop&&r&&(i.crop={aspect:e.crop.aspect,box:e.crop.box??I(r,e.crop.aspect)});let a=e.roots?.get(n.path),p=u({sourcePath:n.path,target:o,suffix:yt(n,e),...e.output===void 0?{}:{output:e.output},...a===void 0?{}:{sourceRoot:a}});return{op:"convert",sources:[n],outputs:[O(p,c(e.destination),c(e.name))],target:o,options:i}})}function x(t){let e={},n=t.cut;return n&&typeof n.start=="number"&&(e.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),t.mute===!0&&(e.mute=!0),typeof t.speed=="number"&&(e.speed=t.speed),typeof t.fps=="number"&&(e.fps=t.fps),typeof t.bitrate=="number"&&(e.bitrate=t.bitrate),typeof t.loudness=="number"&&(e.loudness=t.loudness),t.cleanup===!0&&(e.cleanup=!0),Object.keys(e).length?e:void 0}var de={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, speed, resize, rotate, crop",appliesTo:t=>et(t)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(t,e){let n=et(t);if(!n||!bt(e.tool))return[];let o=e.tool,i={...typeof e.output=="string"?{output:e.output}:{},destination:e.destination,name:e.name};if(o==="cut"){let r=x(e)?.cut;if(!r)return[];i.media={cut:r}}if(o==="mute"&&(i.media={mute:!0}),o==="speed"){let r=e.speed;if(typeof r!="number"||r===1||r<gt||r>ht)return[];i.media={speed:r}}if(o==="loudness"&&(i.media={loudness:typeof e.loudness=="number"?e.loudness:tt}),o==="cleanup"){if(!n.facts?.audio)return[];i.media={cleanup:!0,loudness:tt}}if(o==="extract"){let r=n.facts?.audio;if(!r||!n.facts?.video)return[];i.extract=!0,i.target=G(r.codec)}if(o==="resize"){if(typeof e.resize!="object"||e.resize===null)return[];i.resize=e.resize}if(o==="rotate"){if(!n.facts?.video||!S(e.turn))return[];i.rotate=e.turn}if(o==="crop"){let r=e.crop;if(!r?.aspect||!n.facts?.video)return[];i.crop=r}return St([n],i)}};import{dirname as xt,join as kt}from"node:path";var It=t=>s[t.format].media==="video",zt=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,Ot=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,Mt="-small",m={min:30,max:100,step:35},Tt=t=>{let e=Math.ceil((t-m.min)/m.step);return Math.min(m.max,m.min+Math.max(0,e)*m.step)},ye={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{if(t.length===1&&t[0]?.kind==="media")return!0;let e=zt(t);if(e!==void 0){let o=s[e.format];return o.lossy||o.quantisable===!0}return(Ot(t)?.images?.compressible??0)>0},options(t,e,n){let o=t[0];if(!o)return[];let i=[{kind:"select",id:"mode",label:`Compress ${b(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"&&!It(o))i.push({kind:"slider",id:"bitrate",label:"Quality",min:32,max:320,step:32,default:96});else if(e.mode==="quality"){let r=o.kind==="image"&&s[o.format].quantisable===!0;i.push(r?{kind:"slider",id:"quality",label:"Quality",...m,default:Tt(n.quality),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality})}else if(e.mode==="size")i.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return i;return i.push(A(o,n)),i},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw k(`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 i=(b(o.path)??"file").replace(/\.[^.]+$/,""),r=typeof e.destination=="string"?e.destination:xt(o.path),a=o.kind==="media"?nt(o.format):o.format,p=kt(r,B(i,`${Mt}${$(a)}`)),d=o.kind==="media"?x(e):void 0;return[{op:"convert",sources:[o],target:a,outputs:[p],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0},...d?{media:d}:{}}}]}};function At(t){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${t.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function Ft(){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 Rt(t,e){return Array.isArray(e)?P(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?P(H(e,t.pages)):Array.from({length:t.pages},(n,o)=>o)}function wt(t,e){let n=s[t.format].lossy,o=s[e].lossy;if(n&&!o)return{hint:"likely bigger",tone:"warn"};if(!n&&o)return{hint:"likely smaller",tone:"ok"}}function Pt(t){let e=X(t).filter(o=>o.id!==t.format),n=e[0];return{kind:"select",id:"target",label:`Convert ${s[t.format].label} to`,choices:e.map(o=>{let i=wt(t,o.id);return{value:o.id,label:o.label,hint:i?.hint??o.hint,...i===void 0?{}:{tone:i.tone}}}),default:n?n.id:""}}function Et(t){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:t==="opus"?96:128}}var Ct=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t);function jt(t){let e=t.target,n=typeof e=="string"?D(e):void 0;if(!n)throw k(`convertAction.plan() requires a valid target format, got ${JSON.stringify(e)}.`,"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 Ae={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let o=t[0];if(!o)return[];let i=[Pt(o)],r=e.target;if(typeof r!="string")return i;o.kind==="document"&&w(r)&&i.push(At(o),Ft());let a=s[r];return o.kind==="media"?a?.media==="sound"&&a.lossy&&i.push(Et(r)):a?.lossy&&a.media===void 0&&i.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),i.push(A(o,n)),i},plan(t,e){let n=t[0];if(!n)return[];let o=jt(e),i=o.id,r={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};if(o.lossy&&typeof e.quality=="number"&&(r.quality=e.quality),n.kind==="media"){let d=x(e);d&&(r.media=d),Ct(e.resize)&&(r.resize=e.resize)}let a=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&w(i)){let d=Number(e.dpi);r.dpi=Number.isFinite(d)&&d>0?d:150;let f=Rt(n,e.pages);r.pages=f;let st=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,pt=_(n.path,f,i,a,st);return[{op:"convert",sources:[n],outputs:pt,target:i,options:r}]}let p=L({sourcePath:n.path,target:i,...a===void 0?{}:{output:`${a}/`}});return J(p,n.path)&&(p=u({sourcePath:n.path,target:i,suffix:i,...a===void 0?{}:{output:`${a}/`}})),[{op:"convert",sources:[n],outputs:[p],target:i,options:r}]}};var Dt=[16,4,2],E=t=>typeof t=="number"&&Dt.includes(t),ot=t=>`dithered-${t}`,we=t=>`${t} colours`,it=t=>s[t.format].quantisable?t.format:"png",C=t=>!(t.frames>1)||t.format==="gif";function $t(t,e){if(e.dither)return ot(e.dither);if(e.deband)return U(e.deband);if(!e.rotate)return rt(t,e);let n=T(e.rotate);return e.trim||e.crop||e.resize?`${rt(t,e)}-${n}`:n}function rt(t,e){if(e.crop){let n=z(e.crop.aspect);if(!e.resize)return n;let o=e.crop.box??I(t,e.crop.aspect);return`${n}-${y(g(o,e.resize))}`}return e.trim&&e.resize?`trimmed-${K(e.resize)}`:e.resize?y(g(t,e.resize)):"trimmed"}function Nt(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.dither?it(n):W(n)),i={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}:{},...e.rotate?{rotate:e.rotate}:{},...e.dither?{dither:e.dither}:{},...e.deband?{deband:e.deband}:{},...e.deband&&e.quality===void 0&&s[o].lossy?{quality:95}:{}},r=e.roots?.get(n.path),a=u({sourcePath:n.path,target:o,suffix:$t(n,e),...e.output===void 0?{}:{output:e.output},...r===void 0?{}:{sourceRoot:r}});return{op:"convert",sources:[n],outputs:[O(a,c(e.destination),c(e.name))],target:o,options:i}})}var j=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,Bt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),at=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 l(t,e,n,o){return{id:t,label:e,verb:n,hint:o,appliesTo:i=>j(i)?.every(r=>t==="resize"?!0:t==="dither"?C(r):r.frames<=1)===!0,unavailable:i=>j(i)?"animated":"images only",options:()=>[],plan(i,r){let a=j(i);return a?t==="crop"&&!at(r.crop)?[]:t==="turn"&&!S(r.turn)?[]:t==="deband"&&(!F(r.deband)||a.some(p=>p.frames>1))?[]:t==="dither"&&(!E(r.dither)||!a.every(C))?[]:Nt(a,{trim:t==="trim"||r.trim===!0,...S(r.turn)?{rotate:r.turn}:{},...t==="dither"&&E(r.dither)?{dither:r.dither}:{},...t==="deband"&&F(r.deband)?{deband:r.deband}:{},...Bt(r.resize)?{resize:r.resize}:{},...at(r.crop)?{crop:r.crop}:{},...typeof r.target=="string"?{target:r.target}:{},...typeof r.output=="string"?{output:r.output}:{},...r.roots instanceof Map?{roots:r.roots}:{},destination:r.destination,name:r.name,background:typeof r.background=="string"?r.background:"#ffffff",keepMetadata:r.keepMetadata===!0,...typeof r.quality=="number"?{quality:r.quality}:{}}):[]}}}var Le=l("trim","Trim edges","Trimming edges","cut empty borders"),_e=l("resize","Resize","Resizing","smaller or larger"),Ue=l("crop","Crop to shape","Cropping","change the shape"),Qe=l("turn","Rotate","Rotating","turn it"),Xe=l("dither","Dither","Dithering","fewer colours, scattered"),Ge=l("deband","Remove banding","Removing banding","smooth out stripes");export{Gt as a,Ht as b,Wt as c,v as d,A as e,lt as f,c as g,ft as h,Vt as i,pe as j,St as k,de as l,ye as m,Ae as n,Dt as o,we as p,it as q,C as r,Nt as s,Le as t,_e as u,Ue as v,Qe as w,Xe as x,Ge as y};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
function f(n){let t=n.trim().split(":");if(t.length===0||t.length>3)return;let e=0;for(let[o,i]of t.entries()){if(!(o===t.length-1?/^\d+(\.\d+)?$/:/^\d+$/).test(i))return;let u=Number(i);if(o>0&&u>=60)return;e=e*60+u}return e}function R(n){let t=n.indexOf("-");if(t<0)return;let e=f(n.slice(0,t)),o=n.slice(t+1).trim(),i=o===""?void 0:f(o);if(!(e===void 0||o!==""&&i===void 0)&&!(i!==void 0&&i<=e))return{start:e,end:i}}var s=n=>String(n).padStart(2,"0");function A(n){let t=Math.round(n*10),e=t%600/10,o=Math.floor(t/600)%60,i=Math.floor(t/36e3),d=e.toFixed(1).padStart(4,"0");return i>0?`${i}:${s(o)}:${d}`:`${o}:${d}`}function _(n){let t=Math.round(n),e=t%60,o=Math.floor(t/60)%60,i=Math.floor(t/3600);return i>0?`${i}:${s(o)}:${s(e)}`:`${o}:${s(e)}`}var S=[1,5,10,30,60,300,600,1800];function K(n){return S.filter((t,e)=>e===0||t<=n/4)}function P(n){return n<60?`${n} s`:`${n/60} min`}var w=[1920,1280,854],O=[30,24],E=15,M=64,$=32,x=32,r=n=>Math.max(2,Math.round(n/2)*2);function a(n,t){let e=n.width>=n.height,o=e?n.width:n.height;if(t>=o)return{width:r(n.width-1),height:r(n.height-1)};let i=t/o;return e?{width:r(t),height:r(n.height*i)}:{width:r(n.width*i),height:r(t)}}function c(n){let t=Math.max(n.width,n.height),e=[t,...w.filter(u=>u<t)],o=n.hasAudio?M:0,i=[];for(let u of e){let{width:p,height:l}=a(n,u),g=[...new Set([n.fps,...O].filter(h=>h<=n.fps))];for(let h of g)i.push({width:p,height:l,fps:h,audioKbps:o})}let d=a(n,e[e.length-1]??t);return i.push({...d,fps:Math.min(E,n.fps),audioKbps:n.hasAudio?x:0}),i}var m=n=>n.width*n.height*n.fps*.02/1e3;function b(n){let t=c(n),e=t[t.length-1];return e?Math.ceil((m(e)+e.audioKbps)*1e3/8/.98*n.duration):0}function v(n){let t=n.targetBytes*8/n.duration/1e3*.98;for(let e of c(n)){let o=t-e.audioKbps;if(o>=m(e))return{...e,videoKbps:Math.floor(o)}}return{floor:b(n)}}function z(n,t={}){let e=n.audio!==void 0&&t.mute!==!0;return n.video&&!t.soundOnly?b({duration:n.duration,width:n.video.width,height:n.video.height,fps:n.video.fps,hasAudio:e}):Math.ceil($*1e3/8/.98*n.duration)}export{f as a,R as b,A as c,_ as d,K as e,P as f,v as g,z as h};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{m as l}from"./chunk-TLHUFIXD.js";import{r as f}from"./chunk-V6GWPR2A.js";import{x as m}from"./chunk-ZBMJTIYR.js";import{b as g,d as w}from"./chunk-KXKQDFHX.js";import{readFile as D,rm as E}from"node:fs/promises";var b=new Set(["pdf"]),x=new Set(["jpeg","png"]),I=new Set(["convert"]),y;function R(){return y??=w().then(t=>t.PDFiumLibrary.init()),y}async function h(t,r){return await(await R()).loadDocument(t,r)}async function J(t){let r=await h(t);try{let e=[];for(let n=0;n<r.getPageCount();n++)e.push(r.getPage(n).getText());return e}finally{r.destroy()}}var T={id:"pdfium",reads:b,writes:x,ops:I,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(t,r){if(t.op!=="convert")throw new Error(`pdfium cannot ${t.op}`);let e=t.sources[0];if(e.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(e.encrypted&&t.options.password===void 0)throw m(e.path);let n=t.options.dpi??150,i=t.options.pages??Array.from({length:e.pages},(o,a)=>a);if(i.length!==t.outputs.length)throw new Error(`pdfium was given ${i.length} pages but ${t.outputs.length} outputs`);for(let o of i)if(o<0||o>=e.pages)throw new Error(`pdfium was asked for page ${o}, but ${e.path} has ${e.pages} pages`);let P=await g(),d=await h(await D(e.path),t.options.password);try{let o=[],a=0;try{for(let[s,p]of i.entries()){let u=await d.getPage(p).render({scale:n/72,render:"bitmap",transparent:!0}),F=P(u.data,{raw:{width:u.width,height:u.height,channels:4}}).flatten({background:t.options.background}),S=await l(F,t.target,t.options.quality).toBuffer(),c=t.outputs[s];a+=await f(c,S),o.push(c),r({phase:"page",done:s+1,total:i.length})}}catch(s){throw await Promise.all(o.map(p=>E(p,{force:!0}))),s}return{job:t,outputBytes:a,warnings:[]}}finally{d.destroy()}}};export{h as a,J 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
|
-
import{a as o}from"./chunk-3374PCO5.js";import{f as n}from"./chunk-K253E723.js";import{G as i}from"./chunk-ZBMJTIYR.js";import{a as r}from"./chunk-H3DIRJFE.js";var I=5,h=200,x=5;function z(t){return t.format==="heic"||t.format==="raw"?"jpeg":o(t).includes(t.format)?t.format:"png"}function E(t,m){let e=n.find(f=>f.id==="image")?.writes;if(!e?.has(t))return i(`Cannot ${m} into ${r[t].label}; only an image format can take the edit.`,`Choose one of: ${[...e??[]].join(", ")}.`)}var c=t=>`${t.width}x${t.height}`,u=t=>"percent"in t?`${t.percent}pct`:"width"in t?`${t.width}w`:`${t.height}h`;export{I as a,h as b,x as c,z as d,E as e,c as f,u as g};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as w,b as I,d as k,e as m}from"./chunk-W53XNVNH.js";import{a as $,c as O}from"./chunk-SM735FG7.js";import{b as h,d as P,e as R}from"./chunk-6MWJO3GB.js";import{f as x}from"./chunk-YJ6XLDRA.js";import{a as l}from"./chunk-TGC24JEW.js";import{j as B}from"./chunk-K253E723.js";import{$ as C,_ as g,ba as v}from"./chunk-ZBMJTIYR.js";import{a as f}from"./chunk-J7FLFHQJ.js";import{b as p}from"./chunk-VLVNA4T3.js";import{a as c}from"./chunk-H3DIRJFE.js";import{dirname as S,join as q}from"node:path";async function T(t){if(t.fallback!==void 0)return t.fallback;let{loadPreferences:r,expandTilde:e}=await import("./preferences-3P4V2EDX.js");return e((await r()).prefs.defaultOutput)}function F(t){if(t.pasteboard)return t.pasteboard;if(!$())throw C();return O()}function E(t,r,e,o){let a=q(r.outDir,`Copied image${c[o].extensions[0]}`),s={inputs:[r.source],output:a,force:!1,recursive:!1,debug:t.debug},n={background:"#ffffff",keepMetadata:!1,...t.quality===void 0?{}:{quality:t.quality}};return o===e?{kind:"compress",...s,options:n,...t.quality===void 0?{}:{quality:t.quality},...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}:{kind:"convert",...s,target:o,options:n,...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}}async function J(t,r={}){let e=r.clip??{},o=F(e),a=await w(o,e.root);if(!a)throw g((await o.peek()).text?"text":"nothing");let s=await B(a.source),n=t.target??s.format,b=E(t,a,s.format,n),i=await P(b,r),y=i.results[0];if(!y||i.failures.length>0)return{report:i,status:"failed"};let u=y.job.outputs[0],d={report:i,output:u,source:{format:s.format,bytes:s.bytes},target:n};if(await I(o,a,u,n)==="changed")return{...d,status:"changed",saved:await m(u,await T(e))};if(t.save===void 0)return{...d,status:"placed"};let j=t.save===!0?await T(e):t.save,{expandTilde:D}=await import("./preferences-3P4V2EDX.js");return{...d,status:"placed",saved:await m(u,D(j))}}function N(t){let r=t.target===t.source.format?"":` as ${c[t.target].label}`,e=` ${f(t.source.bytes)} \u2192 ${f(t.report.outputBytes)} \xB7 ${h(t.source.bytes,t.report.outputBytes)}`;if(t.status==="changed"){let a=t.target===t.source.format?"compressed":"converted";return[`\u2713 Copied image \u2192 ${p(t.saved)}${r}`,e,"","\u26A0 Clipboard changed"," The file you uploaded is no longer in the clipboard.",` The ${a} image is saved to ${p(S(t.saved))}.`]}let o=t.saved===void 0?"":` + ${p(t.saved)}`;return[`\u2713 Copied image \u2192 clipboard${r}${o}`,e]}async function U(t){if(!await k(F(t),t.root))throw v()}async function Z(t,r){if(t.undo)return await U(r.clip??{}),{exitCode:0,stdout:r.json?[JSON.stringify({forge:l,ok:!0,clipboard:"restored"})]:["\u2713 The original is back on the clipboard"],stderr:[]};let e=await J(t,r);if(e.status==="failed")return R(e.report,r);if(r.json){let o={...x(l,e.report),clipboard:e.status,...e.saved===void 0?{}:{saved:e.saved}};return{exitCode:0,stdout:[JSON.stringify(o)],stderr:[]}}return{exitCode:0,stdout:N(e),stderr:[]}}export{J as a,N as b,U as c,Z as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
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:!1,lossy:!0,hint:"smallest",defaultQuality:50},heic:{id:"heic",label:"HEIC",extensions:[".heic",".heif"],hasAlpha:!0,animatable:!1,lossy:!0,hint:"Apple photos"},raw:{id:"raw",label:"RAW",extensions:[".dng",".cr2",".cr3",".nef",".nrw",".arw",".srf",".sr2",".raf",".orf",".rw2",".rwl",".pef",".srw",".3fr",".fff",".erf",".dcr",".kdc",".mos"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"camera 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
|
-
import{c as i,e as s,f as o}from"./chunk-N6RCLJE6.js";import{G as n}from"./chunk-ZBMJTIYR.js";var g=["output","theme","quality","update-check"];async function p(a){if(a.action==="path")return{stdout:[i()],exitCode:0,config:{path:i()},warnings:[]};if(a.action==="list"){let{prefs:e,warning:u}=await s(),f=[`output ${e.defaultOutput}`,`theme ${e.theme??"not set"}`,`quality ${e.quality}`,`update-check ${e.updateCheck===!1?"off":"on"}`,"",i()];return u!==void 0&&f.unshift(`\u26A0 ${u}`,""),{stdout:f,exitCode:0,config:{output:e.defaultOutput,theme:e.theme??null,quality:e.quality,"update-check":e.updateCheck===!1?"off":"on",path:i()},warnings:u===void 0?[]:[{code:"config-unreadable",message:u}]}}let{key:r,value:t}=a;if(r==="theme"){if(t!=="dark"&&t!=="light")throw n(`Theme must be dark or light, not ${t}.`);return await o({theme:t}),{stdout:[`theme is now ${t}`],exitCode:0,config:{theme:t},warnings:[]}}if(r==="quality"){let e=Number(t);if(!Number.isInteger(e)||e<1||e>100)throw n(`Quality must be a whole number between 1 and 100, not ${t}.`);return await o({quality:e}),{stdout:[`quality is now ${e}`],exitCode:0,config:{quality:e},warnings:[]}}if(r==="update-check"){if(t!=="on"&&t!=="off")throw n(`update-check must be on or off, not ${t}.`);return await o({updateCheck:t==="on"}),{stdout:[`update-check is now ${t}`],exitCode:0,config:{"update-check":t},warnings:[]}}if(t.trim().length===0)throw n("Output must be a folder path.");return await o({defaultOutput:t}),{stdout:[`output is now ${t}`],exitCode:0,config:{output:t},warnings:[]}}export{g as a,p as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
function o(n){let[e,r]=n>=1e9?[n/1e9,"GB"]:n>=1e6?[n/1e6,"MB"]:n>=1e3?[n/1e3,"KB"]:[n,"B"];return r==="B"?`${Math.round(e)} B`:`${e>=100?Math.round(e).toString():(Math.round(e*10)/10).toString()} ${r}`}function c(n,e){if(n===e)return{pct:0,direction:"same"};if(n===0)return{pct:0,direction:"larger"};let r=(n-e)/n*100;return{pct:Math.round(Math.abs(r)*10)/10,direction:r>0?"smaller":"larger"}}var i={b:1,kb:1e3,mb:1e6,gb:1e9},u={b:"B",kb:"KB",mb:"MB",gb:"GB"};function s(n){if(d(n)===void 0)return;let e=/^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?\s*$/i.exec(n);if(e)return`${Number(e[1])} ${u[(e[2]??"b").toLowerCase()]}`}function d(n){let e=/^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?\s*$/i.exec(n);if(!e)return;let r=Number(e[1]);if(!Number.isFinite(r)||r<=0)return;let t=i[(e[2]??"b").toLowerCase()];if(t!==void 0)return Math.round(r*t)}export{o as a,c as b,s as c,d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as re,g as at,h as ct}from"./chunk-EEQSUBBL.js";import{c as ge,d as ft,f as he,g as pt,k as dt}from"./chunk-OQBIYNGK.js";import{b as st,c as it}from"./chunk-FAUL5L2W.js";import{b as Ue,c as ze,d as qe,f as He,m as tt,n as ot,o as nt,t as rt}from"./chunk-TLHUFIXD.js";import{n as Ge,o as Ve,q as Ke,r as $}from"./chunk-V6GWPR2A.js";import{G as Te,H as Y,I as le,K as Ne,O as Le,X as Je,a as T,ca as oe,ja as We,ka as Ce,ma as C,t as Be,v as ee,x as te}from"./chunk-ZBMJTIYR.js";import{a as Ae}from"./chunk-J7FLFHQJ.js";import{c as B}from"./chunk-VLVNA4T3.js";import{a as S}from"./chunk-H3DIRJFE.js";import{a as Ye,b as ne,c as O,e as Ze,f as Qe,g as Xe,h as je,i as et}from"./chunk-KXKQDFHX.js";import{mkdtemp as Jt,rm as Wt}from"node:fs/promises";import{tmpdir as Ct}from"node:os";import{join as se}from"node:path";var mt=(e,t,o)=>He(e,t,o)===void 0;function ut(e,t,o=Number.POSITIVE_INFINITY,n=[2,4]){return[...n].reverse().find(s=>s<o&&mt(e,t,s))??0}async function Ut(e,t,o){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=e.op,{assetFor:i,catalogEntry:a,offeredHere:f}=await import("./catalog-FMHWWMUX.js");if(!f(r,process.platform,process.arch))throw Le(a(r)?.title??r);let{installed:p,extensionsRoot:u}=await import("./paths-6OENILJ4.js"),h=await p(r);if(!h)throw Ne(r);let l=ze(h.version);if(e.op==="boost"){let y=a(r),x=qe(e.scale,h.version,y&&i(y)?.version);if(x)throw x}if(e.op==="boost"&&!mt(n.width,n.height,e.scale))throw Je(n.path,ut(n.width,n.height,Number.POSITIVE_INFINITY,l),e.scale);let{runExtension:w}=await import("./run-GUFPETHF.js"),g=[];n.frames>1&&g.push({code:"animation-flattened",message:`${B(n.path)} has ${n.frames} frames. Only the first frame was used.`});let I=await Jt(se(Ct(),"forge-ext-"));try{t({phase:"decoding"});let y=se(I,"in.png"),x=se(I,"out.png");await nt(n,y);let _=e.op==="boost"?["--in",y,"--out",x,"--scale",String(e.scale),"--cache",se(u(),"boost","cache")]:[y,x],R=e.op==="boost"&&Ue(h.version);await w({...h,serve:R},_,{subject:n.path,what:`${zt(e)} is running on ${B(n.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),onProgress:(P,E)=>t({phase:"tiles",done:P,total:E}),...e.op==="boost"?{maxScale:ut(n.width,n.height,e.scale,l)}:{},...o===void 0?{}:{signal:o}});let b=(await ne())(x);S[e.target].hasAlpha||(b=b.flatten({background:e.options.background}));let F=await tt(b,e.target,e.options.quality).toBuffer();t({phase:"writing"});let v=await ot(F,s);return{job:e,outputBytes:v,warnings:g}}catch(y){throw T(y)?y:C(n.path,y)}finally{await Wt(I,{recursive:!0,force:!0}).catch(()=>{})}}function zt(e){return e.op!=="boost"?"Remove background":e.scale===1?"Sharpen":`Boost resolution ${e.scale}\xD7`}var lt={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Ut};import{randomBytes as mo}from"node:crypto";import{rm as lo,stat as ie}from"node:fs/promises";import{dirname as go,join as ho}from"node:path";import{open as qt}from"node:fs/promises";async function U(e,t){let o=await qt(e,"r");try{let n=Buffer.alloc(t),{bytesRead:s}=await o.read(n,0,t,0);return n.subarray(0,s)}finally{await o.close()}}var we="%NOISE_FLOOR%",Ht=["highpass=f=80",`afftdn=nr=12:nf=${we}`],Gt="highpass=f=80,astats=measure_perchannel=none:measure_overall=RMS_trough";function vt(e){let t=/RMS trough dB:\s*(-?[\d.]+|-?inf)/i.exec(e)?.[1],o=t===void 0?Number.NaN:Number(t);return Number.isFinite(o)?Math.min(-30,Math.max(-70,Math.round(o+8))):-50}var be="%LOUDNORM_MEASURED%",Vt={mp4:"mp4",hevc:"mp4",mov:"mov",webm:"webm",mkv:"matroska",avi:"avi",gif:"gif",mp3:"mp3",m4a:"ipod",opus:"opus",flac:"flac",wav:"wav",aiff:"aiff",ogg:"ogg"},Kt={mp4:["h264","hevc","mpeg4","av1"],mov:["h264","hevc","mpeg4","prores","av1"],mkv:["h264","hevc","mpeg4","vp8","vp9","av1"],hevc:["hevc"],webm:["vp8","vp9","av1"],avi:["mpeg4","h264","mjpeg","msmpeg4v3"]},Yt={mp4:["aac","alac","mp3"],hevc:["aac","alac","mp3"],mov:["aac","alac","mp3","pcm_s16le","pcm_s16be","pcm_s24le"],m4a:["aac","alac"],mkv:["aac","mp3","opus","vorbis","flac","ac3","eac3"],webm:["opus","vorbis"],opus:["opus"],mp3:["mp3"],flac:["flac"],wav:["pcm_s16le"],aiff:["pcm_s16be"],ogg:["vorbis","opus","flac"],avi:["mp3","ac3","aac","pcm_s16le"]},gt=[48e3,24e3,16e3,12e3,8e3];function Zt(e,t,o){let n={encoder:"opus",kbps:96,args:["-strict","-2"],rates:[48e3]};switch(e){case"webm":return o("libopus")?{encoder:"libopus",kbps:96,rates:gt}:o("libvorbis")?{encoder:"libvorbis",kbps:128}:o("opus")?n:{codec:"Opus or Vorbis",encoders:["libopus","libvorbis","opus"],sound:!0};case"opus":return o("libopus")?{encoder:"libopus",kbps:96,rates:gt}:o("opus")?n:{codec:"Opus",encoders:["libopus","opus"]};case"mp3":return o("libmp3lame")?{encoder:"libmp3lame",kbps:128}:{codec:"MP3",encoders:["libmp3lame"]};case"flac":return{encoder:"flac"};case"wav":return{encoder:"pcm_s16le"};case"aiff":return{encoder:"pcm_s16be"};case"ogg":return o("libvorbis")?{encoder:"libvorbis",kbps:128}:{encoder:"vorbis",kbps:128,args:["-strict","-2","-ac","2"]};default:return{encoder:t==="darwin"&&o("aac_at")?"aac_at":"aac",kbps:128}}}var Z=e=>Math.max(2,Math.floor(e/2)*2),Qt=e=>String(Math.round(e*1e3)/1e3),Xt=e=>String(Math.ceil(e*1e3)/1e3),jt=e=>Math.round(38-(e-1)*20/99),eo=e=>Math.round(50-(e-1)*30/99),to=e=>Math.round(40-(e-1)*18/99),ht=e=>Math.round(20+e*60/100),oo=e=>Math.round(31-(e-1)*29/99);function no(e,t){let o=.15*2**((18-e)/6);return Math.max(64,Math.round(t*o/1e3))}function ro(e,t,o,n,s){let r=e.width,i=e.height;if(o)r=o.width,i=o.height;else{t.crop?.box&&(r=t.crop.box.width,i=t.crop.box.height);let a=t.resize;if(a&&"width"in a){let f=Math.min(a.width,r)/r;r*=f,i*=f}else if(a&&"height"in a){let f=Math.min(a.height,i)/i;r*=f,i*=f}else a&&(r*=a.percent/100,i*=a.percent/100)}return r*i*(n??e.fps*s)}var so="zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";function wt(e){let t=[],o=e;for(;o>2;)t.push("atempo=2"),o/=2;for(;o<.5;)t.push("atempo=0.5"),o/=.5;return t.push(`atempo=${Math.round(o*1e3)/1e3}`),t}var io=800,ao=15,bt=32;function ve(e){let{facts:t,options:o,target:n,platform:s}=e,r=o.media??{},i=t.video,a=t.audio,f=S[n].media==="sound",p=n==="gif",u=o.compress!==void 0,h=s==="darwin",l=c=>e.has===void 0||e.has.has(c),w=c=>Ce(n,c,e.os??s),g=r.cut?.start??0,I=Math.min(r.cut?.end??t.duration,t.duration),y=Math.max(0,I-g),x=r.speed??1,_=y/x,R=i!==void 0&&!f,d=a!==void 0&&!r.mute&&!p,b,F,v,P;if(r.targetBytes!==void 0&&_>0){if(R&&i){let c=at({duration:_,width:i.width,height:i.height,fps:i.fps,hasAudio:d,targetBytes:r.targetBytes});"videoKbps"in c&&(b={width:c.width,height:c.height,fps:c.fps},v=c.videoKbps,F=c.audioKbps)}else if(d){let c=Math.floor(r.targetBytes*8/_/1e3*.98);P=Math.max(bt,Math.min(320,c))}}let E=[];if(R&&i){if(i.hdr&&n!=="hevc"&&l("zscale")&&E.push(so),o.crop?.box){let c=o.crop.box;E.push(`crop=${Z(c.width)}:${Z(c.height)}:${c.left}:${c.top}`)}if(b)E.push(`scale=${b.width}:${b.height}`);else if(o.resize){let c=o.resize;"width"in c?E.push(`scale=trunc(min(${Z(c.width)}\\,iw)/2)*2:-2`):"height"in c?E.push(`scale=-2:trunc(min(${Z(c.height)}\\,ih)/2)*2`):E.push(`scale=trunc(iw*${c.percent/100}/2)*2:-2`)}if(o.rotate&&E.push(o.rotate===90?"transpose=1":o.rotate===270?"transpose=2":"hflip,vflip"),x!==1&&E.push(`setpts=PTS/${x}`),p){let c=Math.min(io,Z(i.width));E.push(`fps=${Math.min(ao,i.fps)},scale=${c}:-2:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=4`)}}let D=b?.fps??r.fps,L=R&&i!==void 0&&E.length===0&&D===void 0&&!u&&r.targetBytes===void 0&&(Kt[n]??[]).includes(i.codec),m=[],pe=!1;if(!R)m.push("-vn");else if(L)m.push("-c:v","copy");else{if(E.length&&m.push("-vf",E.join(",")),p)m.push("-c:v","gif","-loop","0");else if(n==="webm"){if(!l("libvpx-vp9"))throw w({codec:"VP9",encoders:["libvpx-vp9"]});if(pe=v!==void 0,m.push("-c:v","libvpx-vp9","-row-mt","1","-deadline","good","-cpu-used","4"),i?.codec==="gif"&&m.push("-pix_fmt","yuva420p"),v!==void 0)m.push("-b:v",`${v}k`);else{let c=u?eo(o.quality??60):33;m.push("-crf",String(c),"-b:v","0")}}else if(n==="hevc"){let c=l("libx265"),k=h&&l("hevc_videotoolbox");if(!c&&!k)throw w({codec:"HEVC",encoders:["libx265",...h?["hevc_videotoolbox"]:[]]});if(v!==void 0)c?m.push("-c:v","libx265","-preset","fast","-b:v",`${v}k`):m.push("-c:v","hevc_videotoolbox","-b:v",`${v}k`);else if(k&&(!u||!c)){let A=u?ht(o.quality??60):60;m.push("-c:v","hevc_videotoolbox","-q:v",String(A))}else{let A=u?to(o.quality??60):26;m.push("-c:v","libx265","-crf",String(A),"-preset","fast")}m.push("-tag:v","hvc1","-pix_fmt",i?.hdr?"p010le":"yuv420p")}else{let c=u?jt(o.quality??60):21,k=()=>`${v??no(c,i?ro(i,o,b,D,x):0)}k`;if(v===void 0&&!u&&h&&l("h264_videotoolbox"))m.push("-c:v","h264_videotoolbox","-q:v","65");else if(l("libx264"))pe=v!==void 0,v!==void 0?m.push("-c:v","libx264","-preset","medium","-b:v",`${v}k`):u?m.push("-c:v","libx264","-preset","medium","-crf",String(c)):m.push("-c:v","libx264","-preset","veryfast","-crf","21");else if(h&&l("h264_videotoolbox"))v!==void 0?m.push("-c:v","h264_videotoolbox","-b:v",k()):m.push("-c:v","h264_videotoolbox","-q:v",String(ht(o.quality??60)));else if(l("libopenh264"))m.push("-c:v","libopenh264","-b:v",k());else if(s==="win32"&&l("h264_mf"))m.push("-c:v","h264_mf","-b:v",k());else if(n==="avi")if(v!==void 0)m.push("-c:v","mpeg4","-b:v",`${v}k`);else{let A=u?oo(o.quality??60):3;m.push("-c:v","mpeg4","-q:v",String(A))}else throw w({codec:"H.264",encoders:["libx264",...h?["h264_videotoolbox"]:[],"libopenh264",...s==="win32"?["h264_mf"]:[]]});m.push("-pix_fmt","yuv420p")}D!==void 0?m.push("-r",String(D)):n==="avi"?m.push("-fps_mode","cfr"):p||m.push("-fps_mode","passthrough")}let $e=r.cleanup?[...Ht]:[],j=[...$e,...x!==1?wt(x):[]],J=r.loudness;J!==void 0&&j.push(`loudnorm=I=${J}:TP=-1.5:LRA=11:${be}:linear=true`);let _e=r.bitrate??F??P,Me=d&&a!==void 0&&j.length===0&&_e===void 0&&!(u&&f)&&(Yt[n]??[]).includes(a.codec),M=[];if(!d)M.push("-an");else if(Me)M.push("-c:a","copy");else{j.length&&M.push("-af",j.join(","));let c=Zt(n,s,l);if("codec"in c)throw w(c);M.push("-c:a",c.encoder);let k=_e??c.kbps;if(k!==void 0&&c.kbps!==void 0&&M.push("-b:a",`${k}k`),c.args&&M.push(...c.args),!c.args?.includes("-ac")&&F!==void 0&&F<=bt&&M.push("-ac","1"),J!==void 0&&a){let A=!c.rates||c.rates.includes(a.sampleRate);M.push("-ar",String(A?a.sampleRate:c.rates?.[0]))}}let de=[];g>0&&de.push("-ss",Xt(g)),r.cut&&de.push("-t",Qt(y));let V=[...de,"-i",e.input],K=[],ue=[...R?["-map","0:v:0"]:[],...d?["-map","0:a:0"]:[]],ke=o.keepMetadata?[]:["-map_metadata","-1"],Lt=Vt[n]??n,Oe=["mp4","hevc","mov","m4a"].includes(n)?["-movflags","+faststart"]:[],De=["-f",Lt,"-y",e.output],me=s==="win32"?"NUL":"/dev/null",W=[];return r.cleanup&&W.push({args:[...V,...K,"-vn","-af",Gt,"-f","null",me],measures:"noise"}),J!==void 0&&W.push({args:[...V,...K,"-vn","-af",`${[...$e,...x!==1?wt(x):[]].map(c=>`${c},`).join("")}loudnorm=I=${J}:TP=-1.5:LRA=11:print_format=json`,"-f","null",me],measures:"loudness",pass:{at:1,of:2}}),pe?(W.push({args:[...V,...K,...ue.slice(0,2),...m,"-pass","1","-passlogfile",e.passlog,"-an","-f","null",me],pass:{at:1,of:2}}),W.push({args:[...V,...K,...ue,...m,"-pass","2","-passlogfile",e.passlog,...M,...ke,...Oe,...De],pass:{at:2,of:2}})):W.push({args:[...V,...K,...ue,...m,...M,...ke,...Oe,...De],...J!==void 0?{pass:{at:2,of:2}}:{}}),{steps:W,duration:_,copies:{video:L,audio:Me},...b?{fitted:b}:{}}}var z=(e,t,o)=>e.subarray(t,t+o).toString("latin1"),co=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1","avif","avis","crx "]),fo=new Set(["M4A ","M4B ","M4P ","F4A ","F4B "]);function po(e){let t=z(e,8,4);if(!co.has(t))return t==="qt "?"mov":fo.has(t)?"m4a":"mp4"}function yt(e){if(e.length<4)return;if(z(e,4,4)==="ftyp")return po(e);if(e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163)return e.includes("webm",0,"latin1")?"webm":"mkv";let t=z(e,0,4);if(t==="RIFF"){let o=z(e,8,4);return o==="WAVE"?"wav":o==="AVI "?"avi":void 0}if(t==="FORM"){let o=z(e,8,4);return o==="AIFF"||o==="AIFC"?"aiff":void 0}if(t==="fLaC")return"flac";if(t==="OggS")return e.includes("OpusHead",0,"latin1")?"opus":"ogg";if(z(e,0,3)==="ID3"||e[0]===255&&((e[1]??0)&224)===224&&((e[1]??0)&6)===2)return"mp3"}var wo=["mp4","mov","webm","mkv","avi","gif"],Pt=["mp4","mov","hevc","webm","mkv","avi","gif","mp3","m4a","wav"],bo=["mp3","m4a","wav","aiff","flac","opus","ogg"],vo=["mp3","m4a","opus","flac","aiff","wav"];function yo(e){return U(e,64)}function xo(e,t){return t&&!t.video&&(e==="mp4"||e==="mov")?"m4a":e}async function Et(e,t){let o=yt(await yo(e));if(!o)throw new Error("not video or sound");if(o!=="mp4"&&o!=="mov"&&S[o].media!==t)throw new Error(`not ${t}`);let n=(await ie(e)).size,s=await ge(),r;if(s){try{r=await he(e,s)}catch(a){throw ee(e,a)}if(r.duration<=0||!r.video&&!r.audio)throw ee(e,r)}let i=xo(o,r);if(S[i].media!==t)throw new Error(`not ${t}`);return{kind:"media",path:e,format:i,bytes:n,...r?{facts:r}:{}}}async function Po(){let{assetFor:e,catalogEntry:t}=await import("./catalog-FMHWWMUX.js"),o=t("video");return o!==void 0&&e(o)!==void 0}async function Eo(e,t){if(e.kind==="media"&&e.facts)return e.facts;try{return await he(e.path,t)}catch(o){throw ee(e.path,o)}}function Fo(e,t){let o=e.options.media??{},n=o.cut?.start??0,s=Math.min(o.cut?.end??t,t);return Math.max(0,s-n)/(o.speed??1)}function Ft(e,t){if(e.op!=="convert")return;let o=e.sources[0],n=o.kind==="media"?o.facts:void 0;if(!n)return;let s=e.options.media??{},r=ct({...n,duration:Fo(e,n.duration)},{soundOnly:S[e.target].media==="sound",mute:s.mute===!0||e.target==="gif"});return t<r?{floor:r}:void 0}function So(e){let t=e.slice(e.lastIndexOf("{"),e.lastIndexOf("}")+1),o=JSON.parse(t);return[`measured_I=${o.input_i}`,`measured_TP=${o.input_tp}`,`measured_LRA=${o.input_lra}`,`measured_thresh=${o.input_thresh}`,`offset=${o.target_offset}`].join(":")}async function xt(e){await Promise.all(e.map(t=>lo(t,{force:!0}).catch(()=>{})))}async function St(e,t,o){if(e.op!=="convert")throw new Error(`media engines only convert, not ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=await ge();if(!r)throw We(n.path,process.platform,await Po());let i=await Eo(n,r),a=mo(6).toString("hex"),f=Ge(s,a),p=ho(go(s),`.forge-pass-${a}`),u=[f,`${p}-0.log`,`${p}-0.log.temp`,`${p}-0.log.mbtree`,`${p}-0.log.mbtree.temp`],h=[],l=(d,b=e.options)=>ve({input:n.path,output:f,target:e.target,facts:i,options:b,platform:d,os:process.platform,passlog:p,...r.has?{has:r.has}:{}}),w=e.options,g=l(process.platform);if(g.duration<=0)throw Te(`The cut keeps nothing of ${B(n.path)}: it starts at or after its end.`,`It is ${re(i.duration)} long.`);await Ve(s);let I=process.platform,y=w.media?.cut;if(g.copies.video&&y&&y.start>0){let d=await pt(n.path,y.start,r);d!==void 0&&y.start-d>.05&&(w={...w,media:{...w.media,cut:{...y,start:d}}},g=l(process.platform,w),h.push({code:"media-cut-keyframe",message:`It starts at ${re(d)}, the keyframe just before ${re(y.start)}.`}))}let x=0,_=async d=>{let b=x,F="",v="";for(let P of d.steps){let E=P.args.map(L=>L.replace(be,F).replace(we,v)),D=await dt(E,{tools:r,signal:o,report:P.measures!==void 0,onTime:L=>t({phase:"time",done:Math.min(L,d.duration),total:d.duration,...P.pass?{pass:{at:b+P.pass.at,of:b+P.pass.of}}:{}})});P.measures==="loudness"&&(F=So(D)),P.measures==="noise"&&(v=String(vt(D)))}x=b+Math.max(0,...d.steps.map(P=>P.pass?.of??0))};try{try{await _(g)}catch(F){if(o?.aborted||!g.steps.some(v=>v.args.some(P=>P.endsWith("_videotoolbox"))))throw F;I="linux",g=l(I,w),x=0,await _(g)}let d=w.media?.targetBytes;for(let F of[.95,.9]){if(d===void 0||(await ie(f)).size<=d)break;w={...w,media:{...w.media,targetBytes:Math.floor(d*F)}},g=l(I,w),await _(g)}let b=(await ie(f)).size;if(d!==void 0&&b>d)throw Be(n,e.options.media?.targetBytes??d,b);if(e.options.compress!==void 0&&b>=n.bytes)throw oe(n.path,n.bytes,b);await Ke(f,s)}catch(d){throw await xt(u),o?.aborted||T(d)?d:C(n.path,d)}await xt(u.slice(1));let R=i.video;if(g.fitted&&R&&(g.fitted.width<R.width-2||g.fitted.fps<R.fps)){let d=Ae(e.options.media?.targetBytes??0);h.push({code:"media-fitted",message:`To fit ${d} it is now ${g.fitted.width}\xD7${g.fitted.height} at ${g.fitted.fps} fps.`})}return{job:e,outputBytes:(await ie(s)).size,warnings:h}}function Zn(e,t){if(e.kind!=="media"||!e.facts)return;let o=ft()?.has;if(o)try{ve({input:e.path,output:e.path,target:t,facts:e.facts,options:{background:"#ffffff",keepMetadata:!1},platform:process.platform,passlog:"",has:o});return}catch(n){return T(n)&&n.code==="encoder-missing"?n:void 0}}var Q=e=>new Set(e);function Io(e){let t=e.kind==="media"?e.facts:void 0,o=e.kind==="image"||t!==void 0&&t.audio===void 0;return Q(Pt.filter(n=>!(o&&S[n].media==="sound"||n==="hevc"&&t?.video?.codec==="hevc")))}var It={id:"video",reads:Q(wo),writes:Q(Pt),ops:new Set(["convert"]),probe:e=>Et(e,"video"),alone:!0,run:St,sizeTo:Ft,writesFor:Io},Rt={id:"sound",reads:Q(bo),writes:Q(vo),ops:new Set(["convert"]),probe:e=>Et(e,"sound"),alone:!0,run:St,sizeTo:Ft};import{readFile as ae,rm as kt,stat as Ro}from"node:fs/promises";function jn(e,t){let o=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(o.length===0)throw Y(e,"That selects no pages.",t);let n=new Set,s=(r,i)=>{if(!Number.isInteger(r)||r<1||r>t)throw Y(i,`"${i}" is outside 1 and ${t}.`,t);return r};for(let r of o){let i=r.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let a=s(Number(i[1]),r),f=i[2]===""?t:s(Number(i[2]),r);if(f<a)throw Y(r,`"${r}" ends before it starts.`,t);for(let p=a;p<=f;p++)n.add(p-1);continue}if(!/^\d+$/.test(r))throw Y(r,`"${r}" is not a page number.`,t);n.add(s(Number(r),r)-1)}return[...n].sort((r,i)=>r-i)}function $t(e){return[...new Set(e)].sort((t,o)=>t-o)}function er(e){if(e.length===0)return"";let t=[...new Set(e)].sort((r,i)=>r-i),o=[],n=t[0],s=n;for(let r of t.slice(1)){if(r===s+1){s=r;continue}o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),n=r,s=r}return o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),o.join(", ")}function _t(e,t){let o=[...new Set(e)].sort((r,i)=>r-i).filter(r=>r>=0&&r<t-1),n=[],s=0;for(let r of o)n.push({from:s,to:r}),s=r+1;return n.push({from:s,to:t-1}),n}var xe=Ye(()=>import("./pdf-compress-U2E3CNXG.js")),$o=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),_o=new Set(["pdf"]);async function q(e){return(await O()).PDFDocument.load(await ae(e),{ignoreEncryption:!0})}var Mo=1024,Mt=Buffer.from("%PDF-","latin1");async function ko(e){return(await U(e,Mo+Mt.length)).indexOf(Mt)!==-1}async function Oo(e){if(!await ko(e))throw new Error(`${e} is not a PDF`);let{surveyDocument:t}=await xe(),o=await q(e),{size:n}=await Ro(e);return{kind:"document",path:e,format:"pdf",bytes:n,pages:o.getPageCount(),encrypted:o.isEncrypted,images:t(o)}}function H(e){for(let t of e)if(t.encrypted)throw te(t.path)}async function Do(e,t,o){let n=await ne(),s=t.format==="jpeg"||t.format==="png",r=s?(await n(o).metadata()).orientation:void 0;if(s&&(r===void 0||r===1))return t.format==="jpeg"?e.embedJpg(o):e.embedPng(o);if(t.format==="jpeg"){let i=await n(o).rotate().jpeg({quality:S.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await n(o).rotate().png().toBuffer())}async function Ao(e,t){let o=e.sources[0];if(o.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let n=[];o.frames>1&&n.push({code:"animation-flattened",message:`${B(o.path)} has ${o.frames} frames, and ${S.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let s=await ae(o.path);t({phase:"encoding"});let i=await(await O()).PDFDocument.create(),a=await Do(i,o,s);i.addPage([a.width,a.height]).drawImage(a,{x:0,y:0,width:a.width,height:a.height}),t({phase:"writing"});let p=await $(e.outputs[0],await i.save());return{job:e,outputBytes:p,warnings:n}}async function Bo(e,t){H(e.sources.filter(i=>i.kind==="document"));let n=await(await O()).PDFDocument.create();for(let i of e.sources){t({phase:"reading"});let a=await q(i.path),f=await n.copyPages(a,a.getPageIndices());for(let p of f)n.addPage(p)}t({phase:"writing"});let s=await n.save(),r=await $(e.outputs[0],s);return{job:e,outputBytes:r,warnings:[]}}async function To(e,t){let o=e.sources[0];H([o]);let n=await O();t({phase:"reading"});let s=await q(o.path),r=_t(e.cuts,s.getPageCount()),i=[],a=0;try{for(let[f,p]of r.entries()){let u=await n.PDFDocument.create(),h=Array.from({length:p.to-p.from+1},(g,I)=>p.from+I),l=await u.copyPages(s,h);for(let g of l)u.addPage(g);let w=e.outputs[f];if(w===void 0)throw new Error(`split produced ${r.length} parts but was given ${e.outputs.length} outputs`);a+=await $(w,await u.save()),i.push(w),t({phase:"page",done:f+1,total:r.length})}}catch(f){throw await Promise.all(i.map(p=>kt(p,{force:!0}))),f}return{job:e,outputBytes:a,warnings:[]}}async function ye(e,t){let n=await(await O()).PDFDocument.create(),s=await n.copyPages(e,t);for(let r of s)n.addPage(r);return n.save()}async function No(e,t){let o=e.sources[0];if(H([o]),e.pages.length===0)throw le("That extract selects no pages.");t({phase:"reading"});let n=await q(o.path),s=$t(e.pages),r=[],i=0;try{if(e.separate)for(let[a,f]of s.entries()){let p=e.outputs[a];i+=await $(p,await ye(n,[f])),r.push(p),t({phase:"page",done:a+1,total:s.length})}else{t({phase:"writing"});let a=e.outputs[0];i=await $(a,await ye(n,s)),r.push(a)}}catch(a){throw await Promise.all(r.map(f=>kt(f,{force:!0}))),a}return{job:e,outputBytes:i,warnings:[]}}async function Lo(e,t){let o=e.sources[0];H([o]),t({phase:"reading"});let n=await q(o.path),s=new Set(e.pages),r=n.getPageIndices().filter(a=>!s.has(a));if(r.length===0)throw le("That would delete every page.");t({phase:"writing"});let i=await $(e.outputs[0],await ye(n,r));return{job:e,outputBytes:i,warnings:[]}}async function Jo(e,t){let o=e.sources[0];H([o]);let n=await O();t({phase:"reading"});let s=await q(o.path);for(let i of s.getPages()){let f=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(n.degrees(f))}t({phase:"writing"});let r=await $(e.outputs[0],await s.save());return{job:e,outputBytes:r,warnings:[]}}async function Wo(e,t){let o=e.sources[0];H([o]);let{compressPdf:n}=await xe();t({phase:"reading"});let s=await ae(o.path);t({phase:"encoding"});let{bytes:r,recompressed:i,skipped:a,fromDpi:f,toDpi:p}=await n(s,{quality:e.options.quality??60,dpi:e.options.dpi??150});if(e.options.compress&&r.length>=o.bytes)throw oe(o.path,o.bytes,r.length);t({phase:"writing"});let u=await $(e.outputs[0],r),h=w=>w===1?"":"s",l=[];return i===0&&a===0?l.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?l.push({code:"pdf-no-images",message:`None of its ${a} image${h(a)} could be re-encoded \u2014 they are not JPEG data.`}):a>0&&l.push({code:"pdf-images-skipped",message:`${i} image${h(i)} recompressed, ${a} skipped (not JPEG).`}),f!==void 0&&p!==void 0&&l.push({code:"pdf-downsampled",message:`Images reduced from ${f} to ${p} dpi. Pass --dpi ${f} to keep them.`}),{job:e,outputBytes:u,warnings:l}}async function Co(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:o}=await xe(),n=await ae(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(s=>({dpi:s})),measure:async s=>(await o(n,{quality:s.quality??60,...s.dpi===void 0?{}:{dpi:s.dpi}})).bytes.byteLength}}var Ot={id:"pdf",measurer:Co,reads:$o,writes:_o,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:Oo,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Wo(e,t):Ao(e,t);case"merge":return Bo(e,t);case"split":return To(e,t);case"extract":return No(e,t);case"delete":return Lo(e,t);case"rotate":return Jo(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as Uo}from"node:child_process";import{mkdtemp as zo,readFile as Ie,rm as qo}from"node:fs/promises";import{tmpdir as Ho}from"node:os";import{basename as Go,extname as Vo,join as Dt,win32 as Fe}from"node:path";import{pathToFileURL as Ko}from"node:url";import{promisify as Yo}from"node:util";var Se=Yo(Uo),G=Buffer.from([208,207,17,224,161,177,26,225]);async function Zo(e){if(e.length<G.length||!e.subarray(0,G.length).equals(G))return!1;let t=await je();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function Qo(e){let t=await Xe();try{let o=new t(e);if(!o.getEntry("word/document.xml"))return;let n=0,s=o.getEntry("docProps/app.xml");if(s){let r=/<Pages>(\d+)<\/Pages>/.exec(o.readAsText(s));r?.[1]&&(n=Number(r[1]))}return{pages:n}}catch{return}}var At=Buffer.from([80,75,3,4]);async function Xo(e){let t=await U(e,G.length);return t.subarray(0,At.length).equals(At)||t.subarray(0,G.length).equals(G)}async function jo(e){if(!await Xo(e))throw new Error(`${e} is not a Word document`);let t=await Ie(e),o=await Qo(t);if(o)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:o.pages,encrypted:!1};if(await Zo(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}function en(e,t){return e==="win32"?[Fe.join(t.ProgramFiles??"C:\\Program Files","LibreOffice","program","soffice.exe"),Fe.join(t["ProgramFiles(x86)"]??"C:\\Program Files (x86)","LibreOffice","program","soffice.exe")]:["/Applications/LibreOffice.app/Contents/MacOS/soffice"]}var tn=0;async function on(){tn++;try{return await Se("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}for(let e of en(process.platform,process.env))try{return await Se(e,["--version"],{timeout:5e3}),e}catch{}}var Bt,nn=!1,rn;async function sn(){return nn?rn:(Bt??=on(),Bt)}var Re="\f";function ce(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function an(e){if(e.format==="docx"){let o=await Ze(),{value:n}=await o.extractRawText({path:e.path});return ce(n)}if(e.format==="doc"){let o=await Qe(),s=await new o().extract(e.path);return ce(s.getBody())}return(await st(await Ie(e.path))).flatMap((o,n)=>n===0?ce(o):[Re,...ce(o)])}var Pe=612,fe=792,N=54,Ee=11,Tt=14;async function cn(e){let{PDFDocument:t,StandardFonts:o}=await O(),n=await t.create(),s=await n.embedFont(o.Helvetica),r=Pe-N*2,i=n.addPage([Pe,fe]),a=fe-N,f=()=>{i=n.addPage([Pe,fe]),a=fe-N};for(let p of e){if(p===Re){f();continue}let u="";for(let h of p.split(/\s+/).filter(Boolean)){let l=u?`${u} ${h}`:h;u&&s.widthOfTextAtSize(l,Ee)>r?(a<N&&f(),i.drawText(u,{x:N,y:a,size:Ee,font:s}),a-=Tt,u=h):u=l}u&&(a<N&&f(),i.drawText(u,{x:N,y:a,size:Ee,font:s}),a-=Tt)}return n.save()}async function fn(e){let{Document:t,Packer:o,PageBreak:n,Paragraph:s}=await et(),r=e.map(a=>a===Re?new s({children:[new n]}):new s(a)),i=new t({sections:[{children:r}]});return o.toBuffer(i)}var pn=new Set(["docx","doc","pdf"]),dn=new Set(["docx","pdf"]),un=new Set(["convert"]),mn={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};function ln(e=process.platform){return e==="linux"?{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: sudo apt install libreoffice"}:e!=="win32"?mn:{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice from libreoffice.org for full-fidelity conversion."}}function gn(e,t,o,n=process.platform){return[`-env:UserInstallation=${n==="win32"?Ko(Fe.join(e,"profile"),{windows:!0}).href:`file://${e}/profile`}`,"--headless","--convert-to",o,"--outdir",e,t]}async function hn(e,t,o){let n=await zo(Dt(Ho(),"forge-word-"));try{await Se(e,gn(n,t,o),{timeout:12e4});let s=Go(t,Vo(t));return await Ie(Dt(n,`${s}.${o}`))}finally{await qo(n,{recursive:!0,force:!0})}}async function wn(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the word engine can only convert a document source");if(o.encrypted)throw te(o.path);t({phase:"reading"});let n=await sn();t({phase:"encoding"});let s=[],r;try{if(n!==void 0)r=await hn(n,o.path,e.target);else{let a=await an(o);r=e.target==="pdf"?await cn(a):await fn(a),s.push(ln())}}catch(a){throw C(o.path,a)}t({phase:"writing"});let i=await $(e.outputs[0],r);return{job:e,outputBytes:i,warnings:s}}var Nt={id:"word",reads:pn,writes:dn,ops:un,probe:jo,run:wn};var X=[rt,It,Rt,Ot,Nt,lt,it];function Mr(e){return X.find(t=>t.reads.has(e))}function kr(e){return X.find(t=>t.writes.has(e))}function Or(e){if(e.op==="convert"){let t=e.sources[0].format;return X.find(o=>o.reads.has(t)&&o.writes.has(e.target))}return X.find(t=>t.ops.has(e.op))}async function Dr(e){let t;for(let o of X)try{return await o.probe(e)}catch(n){T(t)||(t=n)}throw t}export{jn as a,$t as b,er as c,_t as d,Zn as e,X as f,Mr as g,kr as h,Or as i,Dr as j};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
var p=[{id:"md",label:"Markdown",ext:".md"},{id:"docx",label:"Word",ext:".docx"},{id:"pdf",label:"PDF",ext:".pdf"},{id:"txt",label:"Text",ext:".txt"}],f="md",g=t=>p.some(e=>e.id===t),c=t=>p.find(e=>e.id===t)?.ext??".md",m=t=>p.find(e=>e.id===t)?.label??"Markdown";function o(t){let e=/^(#{1,3}) (.*)$/.exec(t);if(e)return{kind:"heading",level:e[1]?.length,text:e[2]??""};let s=/^<(https?:\/\/\S+)>$/.exec(t);if(s)return{kind:"link",url:s[1]??""};if(t.startsWith("- "))return{kind:"point",text:t.slice(2)};let r=/^\*\*([0-9:]+)\*\* (.*)$/.exec(t);if(r)return{kind:"timed",time:r[1]??"",text:r[2]??""};let i=/^_(.*)_$/.exec(t);return i?{kind:"aside",text:i[1]??""}:t.trim()===""?{kind:"blank"}:{kind:"text",text:t}}function u(t){return t.kind==="blank"?"":t.kind==="link"?t.url:t.kind==="point"?`- ${t.text}`:t.kind==="timed"?`${t.time} ${t.text}`:t.text}function h(t){return t.split(`
|
|
4
|
-
`).map(e=>u(o(e))).join(`
|
|
5
|
-
`)}var d=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),x=['body{font-family:-apple-system,"Helvetica Neue",Helvetica,sans-serif;font-size:11pt;line-height:1.45;color:#1d1d1f}',"h1{font-size:20pt;margin:0 0 6pt}","h2{font-size:15pt;margin:18pt 0 6pt}","h3{font-size:12pt;margin:12pt 0 4pt}","p,ul{margin:0 0 8pt}","li{margin-bottom:4pt}","a{color:#0b57d0}","i{color:#6e6e73}"].join("");function $(t){let e=[],s=[],r=()=>{s.length&&e.push({kind:"list",ordered:!1,items:s}),s=[]};for(let i of t.split(`
|
|
6
|
-
`).map(o)){if(i.kind==="point"){s.push(i.text);continue}r(),i.kind==="heading"?e.push({kind:"heading",level:i.level===1?1:2,text:i.text}):i.kind==="link"?e.push({kind:"paragraph",text:i.url}):i.kind==="timed"?e.push({kind:"paragraph",text:`${i.time} ${i.text}`}):(i.kind==="aside"||i.kind==="text")&&e.push({kind:"paragraph",text:i.text})}return r(),[e]}function b(t){let e=t.split(`
|
|
7
|
-
`).map(o),s=e.find(n=>n.kind==="heading"&&n.level===1),r=[],i=[],a=()=>{i.length&&r.push(`<ul>${i.map(n=>`<li>${n}</li>`).join("")}</ul>`),i=[]};for(let n of e){if(n.kind==="point"){i.push(d(n.text));continue}if(a(),n.kind==="heading")r.push(`<h${n.level}>${d(n.text)}</h${n.level}>`);else if(n.kind==="link"){let l=d(n.url);r.push(`<p><a href="${l}">${l}</a></p>`)}else n.kind==="timed"?r.push(`<p><b>${d(n.time)}</b> ${d(n.text)}</p>`):n.kind==="aside"?r.push(`<p><i>${d(n.text)}</i></p>`):n.kind==="text"&&r.push(`<p>${d(n.text)}</p>`)}return a(),["<!doctype html>",`<html><head><meta charset="utf-8"><title>${s?.kind==="heading"?d(s.text):"Transcript"}</title><style>${x}</style></head><body>`,...r,"</body></html>"].join(`
|
|
8
|
-
`)}export{p as a,f as b,g as c,c as d,m as e,h as f,d as g,x as h,$ as i,b as j};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{l as P}from"./chunk-GVVQP3LF.js";import{c as x,e as k,f as F}from"./chunk-I25E2XDH.js";import{K as E,oa as S,qa as l,x as w}from"./chunk-ZBMJTIYR.js";function R(e){if(e.kind!=="media"){if(e.kind==="image"){let{path:t,format:r,bytes:i,width:n,height:s}=e;return{what:"image",path:t,format:r,bytes:i,width:n,height:s}}if(e.format!=="pdf")throw S(e.path);if(e.encrypted)throw w(e.path);return{what:"pdf",path:e.path,bytes:e.bytes,pages:e.pages}}}import{spawn as T}from"node:child_process";import{mkdtemp as A,rm as _}from"node:fs/promises";import{tmpdir as V}from"node:os";import{join as L}from"node:path";import{createInterface as Y}from"node:readline";var $=[[/private video/i,"This video is private."],[/confirm your age/i,"This video is age-restricted."],[/members-only|join this channel/i,"This video is for channel members only."],[/live event will begin|premieres in/i,"This video has not started yet."],[/unavailable|has been removed|does not exist/i,"This video is unavailable."]],f=class extends Error{};function D(e=process.platform,t=process.arch){let r=k("yt-dlp");return r!==void 0&&F(r,e,t)!==void 0?E("yt-dlp"):l(`YouTube links on ${x(e)} need yt-dlp on your PATH.`,void 0,{hint:"Install yt-dlp (https://github.com/yt-dlp/yt-dlp) and put it on your PATH.",shellHint:"Install yt-dlp and put it on your PATH."})}async function z(e,t={}){let r=await P();if(r===void 0)throw D();let i=await A(L(V(),"forge-yt-"));t.onDir?.(i);let n=()=>_(i,{recursive:!0,force:!0});try{let s;try{s=await I(r.entry,e,i,t)}catch(c){if(!(c instanceof f))throw c;if(r.own)throw l(`yt-dlp could not fetch this video: ${c.message}`,c);await H(r.entry,t.signal);try{s=await I(r.entry,e,i,t)}catch(d){throw d instanceof f?l(`yt-dlp could not fetch this video: ${d.message}`,d):d}}return{...s,dispose:n}}catch(s){throw await n(),s}}function I(e,t,r,i){let{signal:n}=i;if(n?.aborted)return Promise.reject(n.reason??new Error("aborted"));let s=["--js-runtimes",`node:${process.execPath}`,"--no-playlist","--no-warnings","--newline","--progress","-f","bestaudio[ext=m4a]/bestaudio","--print","before_dl:forge-facts %(.{title,uploader,duration,is_live})j","--progress-template","download:forge-bytes %(progress.downloaded_bytes)s %(progress.total_bytes,progress.total_bytes_estimate)s","--print","after_move:forge-file %(filepath)s","--no-simulate","-o",L(r,"sound.%(ext)s"),t];return new Promise((c,d)=>{let u=T(e,s,{stdio:["ignore","pipe","pipe"]}),m,h,b="",y=!1,g=o=>{y||(y=!0,n?.removeEventListener("abort",v),o())},v=()=>{u.kill("SIGKILL"),g(()=>d(n?.reason??new Error("aborted")))};n?.addEventListener("abort",v,{once:!0}),Y({input:u.stdout}).on("line",o=>{if(o.startsWith("forge-facts ")){let a=JSON.parse(o.slice(12));if(a.is_live===!0){u.kill("SIGKILL"),g(()=>d(l("Live streams cannot be transcribed.")));return}m={title:String(a.title??""),uploader:String(a.uploader??""),seconds:Number(a.duration??0)},i.onEvent?.({kind:"facts",facts:m})}else if(o.startsWith("forge-bytes ")){let[a,p]=o.slice(12).split(" ").map(Number);Number.isFinite(a)&&Number.isFinite(p)&&(p??0)>0&&i.onEvent?.({kind:"bytes",done:a,total:p})}else o.startsWith("forge-file ")&&(h=o.slice(11))}),u.stderr.on("data",o=>{b+=o.toString()}),u.on("error",o=>g(()=>d(new f(o.message)))),u.on("close",o=>g(()=>{if(o===0&&m!==void 0&&h!==void 0)return c({path:h,facts:m});let a=b.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",p=$.find(([N])=>N.test(a));d(p?l(p[1]):new f(a||`yt-dlp exited ${o}`))}))})}function H(e,t){return new Promise((r,i)=>{let n=T(e,["--update"],{stdio:"ignore"}),s=()=>n.kill("SIGKILL");t?.addEventListener("abort",s,{once:!0}),n.on("error",()=>r()),n.on("close",()=>{t?.removeEventListener("abort",s),t?.aborted?i(t.reason??new Error("aborted")):r()})})}export{R as a,D as b,z as c};
|