forge-terminal 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -4
- package/dist/chunks/{about-credits-6D6B2JTS.js → about-credits-PFW4OXPX.js} +1 -1
- package/dist/chunks/args-ZMSJ3NBZ.js +3 -0
- package/dist/chunks/{available-HYL2YE56.js → available-GYIHVSRX.js} +1 -1
- package/dist/chunks/boot-M6TQUYUF.js +3 -0
- package/dist/chunks/{catalog-U7IF2BH2.js → catalog-YSMT3PXT.js} +1 -1
- package/dist/chunks/{check-INHBJOBB.js → check-KAR72Y4X.js} +1 -1
- package/dist/chunks/chunk-3UEQ2OX6.js +3 -0
- package/dist/chunks/{chunk-SS7HNRZ5.js → chunk-5B5XXH22.js} +1 -1
- package/dist/chunks/chunk-5IS7O673.js +6 -0
- package/dist/chunks/chunk-6FUVEO3A.js +78 -0
- package/dist/chunks/chunk-6L6C3GJU.js +3 -0
- package/dist/chunks/{chunk-5GJK5LP5.js → chunk-AAXBN572.js} +2 -2
- package/dist/chunks/chunk-BCNMRALN.js +66 -0
- package/dist/chunks/{chunk-6TERL22R.js → chunk-DERIWZAT.js} +1 -1
- package/dist/chunks/chunk-DOWMSJ6R.js +3 -0
- package/dist/chunks/chunk-DTX4OGMY.js +63 -0
- package/dist/chunks/chunk-EEQSUBBL.js +3 -0
- package/dist/chunks/{chunk-C2OZ5ERA.js → chunk-EX7KZBI6.js} +1 -1
- package/dist/chunks/chunk-EXLXSKRH.js +3 -0
- package/dist/chunks/{chunk-BLPVRO4J.js → chunk-FH3R2YYD.js} +1 -1
- package/dist/chunks/{chunk-CLQHW4EF.js → chunk-GJ2GZHRI.js} +1 -1
- package/dist/chunks/chunk-HZDYZ5RD.js +3 -0
- package/dist/chunks/chunk-I63TO22X.js +3 -0
- package/dist/chunks/{chunk-ILWGG424.js → chunk-IGF6ZFTM.js} +1 -1
- package/dist/chunks/{chunk-Z2LELLNV.js → chunk-IWFVEMDN.js} +1 -1
- package/dist/chunks/{chunk-4LTI6JHW.js → chunk-JFJ3ZJQL.js} +2 -2
- package/dist/chunks/{chunk-OVILZLVA.js → chunk-JSMGNA55.js} +1 -1
- package/dist/chunks/chunk-KAHWYWNT.js +3 -0
- package/dist/chunks/chunk-LDKF7KIZ.js +6 -0
- package/dist/chunks/chunk-LNB5D67B.js +3 -0
- package/dist/chunks/chunk-M66BUNYO.js +3 -0
- package/dist/chunks/{chunk-MHW4OOQW.js → chunk-MV7H3QQY.js} +2 -2
- package/dist/chunks/{chunk-SVDVVRVP.js → chunk-P6NXFZZP.js} +1 -1
- package/dist/chunks/chunk-QR6QHTC3.js +3 -0
- package/dist/chunks/chunk-SMBK6BTC.js +3 -0
- package/dist/chunks/chunk-TDW6KQH6.js +3 -0
- package/dist/chunks/chunk-TMQDQLY7.js +21 -0
- package/dist/chunks/chunk-Y2A3HTKQ.js +4 -0
- package/dist/chunks/chunk-YWKMG5WO.js +3 -0
- package/dist/chunks/{chunk-FKPXXNKX.js → chunk-YYB3TTGT.js} +1 -1
- package/dist/chunks/clip-command-LAVVAHHV.js +3 -0
- package/dist/chunks/colour-AJW2JR3S.js +3 -0
- package/dist/chunks/command-I5M275ZV.js +3 -0
- package/dist/chunks/config-command-TYNYVUMP.js +3 -0
- package/dist/chunks/entry-UWADO4ND.js +6 -0
- package/dist/chunks/execute-MUM63CAA.js +3 -0
- package/dist/chunks/extensions-ZKAAFA4J.js +3 -0
- package/dist/chunks/{extensions-command-AITZYSMM.js → extensions-command-73UGWB6L.js} +1 -1
- package/dist/chunks/ffmpeg-PF3VLTHK.js +3 -0
- package/dist/chunks/image-J4FT4ACZ.js +3 -0
- package/dist/chunks/install-2A5BGKQU.js +3 -0
- package/dist/chunks/install-V62EEK54.js +3 -0
- package/dist/chunks/launch-S5BW2LZU.js +5 -0
- package/dist/chunks/lock-KN7CF4YN.js +3 -0
- package/dist/chunks/manager-743RM57Z.js +4 -0
- package/dist/chunks/{paths-KTXPDCDD.js → paths-5XI5L4KW.js} +1 -1
- package/dist/chunks/pdf-compress-U2E3CNXG.js +3 -0
- package/dist/chunks/{preferences-AUFJSKMJ.js → preferences-4VETUGMN.js} +1 -1
- package/dist/chunks/preset-command-HORY7KZQ.js +3 -0
- package/dist/chunks/{run-4Z6CRNHJ.js → run-6BK4REXK.js} +1 -1
- package/dist/chunks/{server-RM4YA6UL.js → server-DPBVFUL7.js} +6 -6
- package/dist/chunks/{theme-LR72ACFF.js → theme-USWAYNEH.js} +1 -1
- package/dist/chunks/transcribe-command-YUSBCQEQ.js +3 -0
- package/dist/chunks/{update-command-2SHKIIQD.js → update-command-GMBG7BK6.js} +1 -1
- package/dist/chunks/{update-note-UH2TQPJ6.js → update-note-VYJKUIIX.js} +1 -1
- package/dist/chunks/watch-command-KULANTL2.js +3 -0
- package/dist/helpers/forge-transcribe +0 -0
- package/dist/index.js +15 -72
- package/package.json +7 -21
- package/dist/chunks/boot-IQ4NYHEG.js +0 -3
- package/dist/chunks/chunk-26NDEWOQ.js +0 -3
- package/dist/chunks/chunk-2CK4RFPI.js +0 -3
- package/dist/chunks/chunk-3A43GEIR.js +0 -4
- package/dist/chunks/chunk-6V6WEBUI.js +0 -66
- package/dist/chunks/chunk-6VOCIMXQ.js +0 -3
- package/dist/chunks/chunk-7ZI3PFFX.js +0 -3
- package/dist/chunks/chunk-BXJ2HTKI.js +0 -3
- package/dist/chunks/chunk-CBE73ZWA.js +0 -3
- package/dist/chunks/chunk-D6JPP65L.js +0 -3
- package/dist/chunks/chunk-DW2EJIUX.js +0 -3
- package/dist/chunks/chunk-FWMFN36F.js +0 -3
- package/dist/chunks/chunk-HBDVKP3X.js +0 -5
- package/dist/chunks/chunk-HCN4BH2H.js +0 -3
- package/dist/chunks/chunk-IMC5NRDC.js +0 -3
- package/dist/chunks/chunk-JBSYGB3F.js +0 -3
- package/dist/chunks/chunk-PGG2OTK6.js +0 -3
- package/dist/chunks/chunk-XNNTF6FW.js +0 -3
- package/dist/chunks/chunk-ZONIA7SX.js +0 -21
- package/dist/chunks/clip-command-Q6SLD4U4.js +0 -3
- package/dist/chunks/colour-JPG24QYI.js +0 -3
- package/dist/chunks/config-command-R7QOBYF4.js +0 -3
- package/dist/chunks/execute-B7UL5RCU.js +0 -3
- package/dist/chunks/extensions-UR4GS47P.js +0 -3
- package/dist/chunks/image-KWRJIHQQ.js +0 -3
- package/dist/chunks/install-WBAFPZ2Q.js +0 -3
- package/dist/chunks/launch-RM5ZVXSU.js +0 -4
- package/dist/chunks/lock-GOOLFLSO.js +0 -3
- package/dist/chunks/manager-KZJ7WC34.js +0 -4
- package/dist/chunks/pdf-compress-IMRFBLZF.js +0 -3
- package/dist/chunks/preset-command-AXYFLVYA.js +0 -3
- package/dist/chunks/restart-TL76JEPU.js +0 -3
- package/dist/chunks/transcribe-command-6YTLVSMW.js +0 -3
- package/dist/chunks/watch-command-NU7QY6QU.js +0 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as h,c as S,d as A,e as R,f as T,g}from"./chunk-QVACE4IE.js";import{F as E}from"./chunk-
|
|
3
|
+
import{b as h,c as S,d as A,e as R,f as T,g}from"./chunk-QVACE4IE.js";import{F as E}from"./chunk-3UEQ2OX6.js";var y={set:"tailwind",start:50,end:950,count:11},O=["tailwind","even","radix"],v=[0,50,100,150,200,250,300,350,400,450],D=[550,600,650,700,750,800,850,900,950,1e3],I=Array.from({length:19},(e,n)=>n+3),$=[20,50,100,150,200,260,330,420,500,560,750,920],N=8;function P({set:e,start:n,end:r,count:o}){if(!O.includes(e))return`The set must be tailwind, even or radix; got ${e}.`;if(e!=="radix"){if(!v.includes(n))return n%50===0?`The start must be from 0 to 450, so the colour (500) stays in the scale; got ${n}.`:`The start must be a multiple of 50; got ${n}.`;if(!D.includes(r))return r%50===0?`The end must be from 550 to 1000, so the colour (500) stays in the scale; got ${r}.`:`The end must be a multiple of 50; got ${r}.`;if(e==="even"&&!I.includes(o))return`An even set has 3 to 21 steps; got ${o}.`}}function d(e){let{set:n,start:r,end:o,count:a}=e;if(n==="radix")return $.map((t,s)=>({step:s+1,at:t}));if(n==="tailwind"){let t=new Set([r,o,500]);for(let s=Math.ceil((r+1)/100)*100;s<o;s+=100)t.add(s);return[...t].sort((s,u)=>s-u).map(s=>({step:s,at:s}))}let i=a-1,f=Math.round(i*(500-r)/(o-r)),c=Math.max(1,Math.min(i-1,f)),p=i-c,b=[];for(let t=0;t<=c;t++)b.push(r+(500-r)*t/c);for(let t=1;t<=p;t++)b.push(500+(o-500)*t/p);for(let t of[10,5,1]){let s=b.map(u=>Math.round(u/t)*t);if(new Set(s).size===s.length)return b.map((u,l)=>({step:s[l],at:u}))}return b.map(t=>({step:t,at:t}))}function _(e){return d(e).map(n=>n.step)}var z=_(y);function K(e){return e.set==="radix"?N:d(e).findIndex(n=>n.at===500)}var W=[[50,1],[100,.86],[200,.68],[300,.46],[400,.22],[500,0]],F=[[500,0],[600,.2],[700,.4],[800,.6],[900,.8],[950,1]];function w(e,n){for(let r=1;r<e.length;r++){let[o,a]=e[r-1],[i,f]=e[r];if(n<=i)return a+(f-a)*(n-o)/(i-o)}return e[e.length-1][1]}var H=.995,U=.35,j=5e-4;function Y(e,n=y){let r=P(n);if(r)throw E(r,"Try: Tailwind, from 50 to 950.");let{L:o,C:a,h:i}=T(S(e)),f=a<j,c=Math.max(.975,o),p=o<.16?.42*o:Math.max(.16,.42*o);return d(n).map(({step:b,at:t})=>{if(t===500)return{step:b,at:t,rgb:{...e},hex:h(e),reference:!0};let s,u;if(t>=50&&t<500){let m=w(W,t);s=o+(c-o)*m,u=a*(1-.88*m)}else if(t<50){let m=(50-t)/50;s=c+(Math.max(H,c)-c)*m,u=a*.12*(1-m)}else if(t<=950){let m=w(F,t);s=o-(o-p)*m,u=a*(1-.45*m)}else{let m=(t-950)/50;s=p*(1-U*m),u=a*.55*(1-.4*m)}for(f&&(u=0);u>0&&!R(g({L:s,C:u,h:i}));)u-=.002;let l=A(g({L:s,C:Math.max(0,u),h:i}));return{step:b,at:t,rgb:l,hex:h(l),reference:!1}})}var x=e=>{let n=e/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4},M=({r:e,g:n,b:r})=>.2126*x(e)+.7152*x(n)+.0722*x(r);function L(e,n){let[r,o]=[M(e),M(n)].sort((a,i)=>i-a);return(r+.05)/(o+.05)}function J(e){return e>=7?"AAA":e>=4.5?"AA":e>=3?"large":"fails"}var k={r:255,g:255,b:255},B={r:0,g:0,b:0},C=e=>Math.floor(e*10)/10;function Q(e){return{white:C(L(e,k)),black:C(L(e,B))}}export{y as a,O as b,v as c,D as d,I as e,d as f,_ as g,K as h,Y as i,L as j,J as k,Q as l};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{O as a,P as u,Q as l}from"./chunk-
|
|
3
|
+
import{O as a,P as u,Q as l}from"./chunk-3UEQ2OX6.js";import{spawn as x}from"node:child_process";import{existsSync as c,realpathSync as b}from"node:fs";import{dirname as h,join as E,win32 as d}from"node:path";function f(n,t=process.platform,e=c){if(n===void 0)return!1;if(t==="win32"){let r=/^(.*)[\\/]node_modules[\\/]forge-terminal[\\/]/.exec(n)?.[1];return r!==void 0&&e(d.join(r,"forge.cmd"))}return/\/lib\/node_modules\/forge-terminal\//.test(n)&&!n.includes("/_npx/")}function m(n){if(n!==void 0)try{return b(n)}catch{return n}}function P(n,t=c){let e=E(h(n),"npm");return t(e)?e:"npm"}function R(n,t=c){let e=d.join(d.dirname(n),"node_modules","npm","bin","npm-cli.js");return t(e)?e:void 0}var g=(n,t,e)=>new Promise(r=>{let o="",s=x(n,t,{stdio:["ignore","pipe","pipe"],...e?{signal:e}:{}});s.stdout.setEncoding("utf8").on("data",i=>{o+=i}),s.stderr.setEncoding("utf8").on("data",i=>{o+=i}),s.on("error",i=>r({code:null,output:`${o}
|
|
4
4
|
${i.message}`})),s.on("close",i=>r({code:i,output:o}))});function w(n){return n.split(`
|
|
5
|
-
`).map(e=>e.replace(/^npm (error|ERR!)\s*/,"").trim()).filter(e=>e!==""&&!/^(code|errno|syscall|path|dest|A complete log)/.test(e)).at(-1)??"npm exited without saying why"}async function _(n,t={}){let e=t.platform??process.platform;if(e==="win32")return S(n,t);let r=t.script??m(process.argv[1]);if(!f(r,e))throw a(n);let o=t.npm??P(process.execPath),s=t.run??g,{code:i,output:p}=await s(o,["install","--global",`forge-terminal@${n}`],t.signal);if(i!==0)throw/EACCES|EPERM|permission denied/i.test(p)?u(n,e):l(n,w(p))}async function S(n,t){let e=t.script??m(process.argv[1]);if(!f(e,"win32",t.exists))throw a(n);let r=R(process.execPath,t.exists);if(r===void 0)throw l(n,"npm was not found beside Node");let o=t.run??g,{code:s,output:i}=await o(process.execPath,[r,"install","--global",`forge-terminal@${n}`],t.signal);if(s!==0)throw/EACCES|EPERM|EBUSY|permission denied/i.test(i)?u(n,"win32"):l(n,w(i))}export{f as a,m as b,P as c,R as d,_ as
|
|
5
|
+
`).map(e=>e.replace(/^npm (error|ERR!)\s*/,"").trim()).filter(e=>e!==""&&!/^(code|errno|syscall|path|dest|A complete log)/.test(e)).at(-1)??"npm exited without saying why"}async function _(n,t={}){let e=t.platform??process.platform;if(e==="win32")return S(n,t);let r=t.script??m(process.argv[1]);if(!f(r,e))throw a(n);let o=t.npm??P(process.execPath),s=t.run??g,{code:i,output:p}=await s(o,["install","--global",`forge-terminal@${n}`],t.signal);if(i!==0)throw/EACCES|EPERM|permission denied/i.test(p)?u(n,e):l(n,w(p))}async function S(n,t){let e=t.script??m(process.argv[1]);if(!f(e,"win32",t.exists))throw a(n);let r=R(process.execPath,t.exists);if(r===void 0)throw l(n,"npm was not found beside Node");let o=t.run??g,{code:s,output:i}=await o(process.execPath,[r,"install","--global",`forge-terminal@${n}`],t.signal);if(s!==0)throw/EACCES|EPERM|EBUSY|permission denied/i.test(i)?u(n,"win32"):l(n,w(i))}export{f as a,m as b,P as c,R as d,w as e,_ as f};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as h}from"./chunk-
|
|
3
|
+
import{c as h}from"./chunk-YWKMG5WO.js";import{i as P}from"./chunk-6L6C3GJU.js";import{d as y,ga as s}from"./chunk-3UEQ2OX6.js";import{mkdtemp as F,rm as x}from"node:fs/promises";import{tmpdir as z}from"node:os";import{join as v}from"node:path";var f={background:"#ffffff",keepMetadata:!1};function w(e,r,o){switch(e.kind){case"cut":return{op:"convert",sources:[r],outputs:[o],target:"png",options:{...f,...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}};case"cutout":return{op:"remove-background",sources:[r],outputs:[o],target:"png",options:f};case"boost":return{op:"boost",sources:[r],outputs:[o],scale:e.scale,target:"png",options:f};case"encode":return{op:"convert",sources:[r],outputs:[o],target:e.target,options:{...f,...e.background?{background:e.background}:{},...e.quality!==void 0?{quality:e.quality}:{},...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}}}}async function C(e,r,o,n){let E=n.probe??P,l=await F(v(z(),"forge-preset-")),I={force:n.force,...n.signal?{signal:n.signal}:{},...n.onEvent?{onEvent:n.onEvent}:{}};try{let i=e;for(let[d,t]of r.entries()){let u=d===r.length-1,g=u?o:v(l,`${d}.png`),a=await h([w(t,i,g)],{...I,...u?{}:{force:!0},...u&&t.kind==="encode"&&t.maxBytes?{targetBytes:t.maxBytes}:{}});if(a.cancelled)return{kind:"cancelled"};let m=a.refusals[0];if(m)return{kind:"refused",error:m.error};let p=a.unreachable[0];if(p)return{kind:"unreachable",entry:p};let b=a.failures[0];if(b)return{kind:"failed",pass:t,error:b.error};let c=a.results[0];if(!c)return{kind:"failed",pass:t,error:s(e.path,"no result")};if(u){let j=c.job.op==="convert"?{...c.job,sources:[e]}:c.job;return{kind:"done",result:{...c,job:j}}}let k=await E(g);if(k.kind!=="image")return{kind:"failed",pass:t,error:s(e.path,"not an image")};i=k}return{kind:"failed",pass:{kind:"encode",target:e.format},error:s(e.path,"nothing to run")}}catch(i){return{kind:"failed",pass:r[r.length-1]??{kind:"encode",target:e.format},error:y(i)?i:s(e.path,i)}}finally{await x(l,{recursive:!0,force:!0})}}export{C as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as gt,b as q,d as yt}from"./chunk-SMBK6BTC.js";import{$ as pt,C as ct,F as B,K as ft,X as dt,ba as ut,c as k,ca as mt,d as C,da as lt,e as et,ea as wt,f as rt,g as W,ga as U,h as it,i as nt,j as ot,k as at,l as st,o as I,u as ht,v as j}from"./chunk-3UEQ2OX6.js";import{a as w}from"./chunk-M66BUNYO.js";import{constants as Jt}from"node:fs";import{access as Vt,readFile as Bt,rm as Xt,stat as Zt,writeFile as Gt}from"node:fs/promises";import{dirname as Kt}from"node:path";var Ft=[{w:1,h:1,label:"1:1"},{w:4,h:5,label:"4:5"},{w:16,h:9,label:"16:9"},{w:9,h:16,label:"9:16"}],ue=20,me=10,E=t=>Math.max(1,Math.round(t)),N=(t,e,r)=>Math.min(Math.max(t,e),r);function A(t,e){let r=E(t.width*e.h/e.w),[i,n]=r<=t.height?[t.width,r]:[Math.min(t.width,E(t.height*e.w/e.h)),t.height];return{left:Math.floor((t.width-i)/2),top:Math.floor((t.height-n)/2),width:i,height:n}}var zt=(t,e)=>e.width===t.width&&e.height===t.height;function le(t){return Ft.filter(e=>!zt(t,A(t,e)))}function we(t,e,r,i){let n=A(t,e),o,a;return e.w>=e.h?(o=E(n.width*i/100),a=Math.min(t.height,E(o*e.h/e.w))):(a=E(n.height*i/100),o=Math.min(t.width,E(a*e.w/e.h))),{left:N(Math.round(r.x-o/2),0,t.width-o),top:N(Math.round(r.y-a/2),0,t.height-a),width:o,height:a}}function ge(t,e,r,i){return{...e,left:N(e.left+r,0,t.width-e.width),top:N(e.top+i,0,t.height-e.height)}}function ye(t,e){return{x:e.width<t.width,y:e.height<t.height}}function xe(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}function be(t,e){return Math.round(e.width*e.height*100/(t.width*t.height))}var J=t=>`${t.w}:${t.h}`,Se=t=>`cropped-${t.w}x${t.h}`;function Ie(t){let e=/^(\d{1,3}):(\d{1,3})$/.exec(t.trim()),r=Number(e?.[1]),i=Number(e?.[2]);if(!e||r<1||r>100||i<1||i>100)throw B(`"${t}" is not a shape; it takes two whole numbers from 1 to 100, as W:H.`,"Try --crop 1:1 or --crop 16:9.");return{w:r,h:i}}function Me(t,e,r){let i=r*2,n=new Uint8Array(e*i*3),o=t.alpha?new Uint8Array(e*i):void 0,a=t.width/e,d=t.height/i;for(let s=0;s<i;s++){let h=s*d,l=h+d;for(let p=0;p<e;p++){let f=p*a,u=f+a,x=0,m=0,g=0,c=0,y=0;for(let b=Math.floor(h);b<Math.min(Math.ceil(l),t.height);b++){let L=Math.min(b+1,l)-Math.max(b,h);for(let O=Math.floor(f);O<Math.min(Math.ceil(u),t.width);O++){let Y=b*t.width+O,tt=(Math.min(O+1,u)-Math.max(O,f))*L,R=tt*(t.alpha?(t.alpha[Y]??0)/255:1),H=Y*3;x+=(t.rgb[H]??0)*R,m+=(t.rgb[H+1]??0)*R,g+=(t.rgb[H+2]??0)*R,c+=R,y+=tt}}let z=s*e+p;c>0&&n.set([x/c,m/c,g/c].map(Math.round),z*3),o&&y>0&&(o[z]=Math.round(c*255/y))}}return{cols:e,dotRows:i,rgb:n,...o?{alpha:o}:{}}}function Oe(t){if(w[t].hasAlpha)return;let e=Object.keys(w).filter(r=>w[r].hasAlpha&&r!=="heic").join(", ");return B(`${w[t].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${e}.`)}var xt="1.1.0";function Rt(t,e){let r=t.split(".").map(n=>Number.parseInt(n,10)||0),i=e.split(".").map(n=>Number.parseInt(n,10)||0);for(let n=0;n<Math.max(r.length,i.length);n++){let o=(r[n]??0)-(i[n]??0);if(o!==0)return o>0}return!0}function V(t){return t!==void 0&&Rt(t,xt)?[2,3,4]:[2,4]}function Be(t,e,r){if(t===1||V(e).some(n=>n===t))return;if(r!==void 0&&V(r).some(n=>n===t))return ft("boost",`boost ${t}\xD7`,e,xt);let i=V(e).map(n=>`--boost ${n}`);return B(`No released boost makes ${t}\xD7 yet.`,`Try ${i.slice(0,-1).join(", ")} or ${i.at(-1)}.`)}var kt=16384,Ct=1e8;function bt(t,e,r){let i=Math.max(t,e)*r;if(i>kt)return{side:i};let n=t*r*e*r;if(n>Ct)return{megapixels:Math.round(n/1e6)}}var v=t=>Math.max(1,Math.round(t));function X(t,e){return"percent"in e?{width:v(t.width*e.percent/100),height:v(t.height*e.percent/100)}:"width"in e?{width:v(e.width),height:v(t.height*e.width/t.width)}:{width:v(t.width*e.height/t.height),height:v(e.height)}}function St(t){return bt(t.width,t.height,1)}import{execFile as Nt}from"node:child_process";import{randomBytes as Dt}from"node:crypto";import{mkdtemp as _t,open as It,readFile as $t,rm as Z}from"node:fs/promises";import{tmpdir as Mt}from"node:os";import{join as _}from"node:path";import{promisify as Lt}from"node:util";function S(t){let e;return()=>(e??=t(),e)}var M=S(async()=>(await import("sharp")).default),ze=S(()=>import("./es-T2U7NBLD.js")),Re=S(()=>import("@hyzyla/pdfium")),ke=S(async()=>(await import("./lib-TPEJ5CJJ.js")).default),Ce=S(async()=>(await import("./word-OGQ2KZAJ.js")).default),Ue=S(async()=>(await import("./adm-zip-SQKLKBDP.js")).default),Ne=S(async()=>(await import("./cfb-V6M2PYOD.js")).default);async function Ut(){let t=Object.getOwnPropertyDescriptor(globalThis,"localStorage");if(!t?.configurable)return import("./dist-J2V6ITHG.js");Object.defineProperty(globalThis,"localStorage",{value:void 0,configurable:!0,enumerable:t.enumerable??!1,writable:!0});try{return await import("./dist-J2V6ITHG.js")}finally{Object.defineProperty(globalThis,"localStorage",t)}}var De=S(Ut);var G=Lt(Nt),Et=async()=>({...await import("./paths-5XI5L4KW.js"),...await import("./run-6BK4REXK.js")}),T;async function P(t=process.platform){if(t==="win32")return await(await Et()).installed("heic")!==void 0;if(T!==void 0)return T;try{await G("/usr/bin/sips",["--help"],{timeout:5e3}),T=!0}catch{T=!1}return T}async function $(t,e=process.platform){if(e==="win32")return Ht(t);let r=_(Mt(),`forge-heic-${Dt(8).toString("hex")}.png`),i=async()=>{await Z(r,{force:!0}).catch(()=>{})};try{return await G("/usr/bin/sips",["-s","format","png",t,"--out",r],{timeout:12e4}),{path:r,cleanup:i}}catch(n){throw await i(),n}}async function At(t){let{installed:e,runExtension:r}=await Et(),i=await e("heic");if(i===void 0)throw I(t,"win32");return{ext:i,runExtension:r}}async function Ht(t){let e=await _t(_(Mt(),"forge-heic-")),r=async()=>{await Z(e,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:i,runExtension:n}=await At(t),o=_(e,"decoded.rgba"),a=_(e,"decoded.png"),{width:d,height:s}=await n(i,["--in",t,"--out",o],{subject:t});return await(await M())(await $t(o),{raw:{width:d,height:s,channels:4}}).png().toFile(a),await Z(o,{force:!0}),{path:a,cleanup:r}}catch(i){throw await r(),i}}var Wt=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),jt=new Set(["avif","avis"]);async function vt(t){let e;try{e=await It(t,"r")}catch{return!1}try{let r=Buffer.alloc(64),{bytesRead:i}=await e.read(r,0,64,0);if(i<12||r.toString("latin1",4,8)!=="ftyp")return!1;let n=Math.min(r.readUInt32BE(0),i),o=[];for(let a=8;a+4<=n;a+=4)o.push(r.toString("latin1",a,a+4));return o.some(a=>jt.has(a))?!1:o.some(a=>Wt.has(a))}catch{return!1}finally{await e.close().catch(()=>{})}}async function Ot(t,e=process.platform){if(e==="win32"){let{ext:a,runExtension:d}=await At(t),s=await d(a,["--info","--in",t],{subject:t});return{width:s.width,height:s.height,hasAlpha:s.hasAlpha??!0}}let{stdout:r}=await G("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",t],{timeout:3e4}),i=Number(/pixelWidth:\s*(\d+)/.exec(r)?.[1]??0),n=Number(/pixelHeight:\s*(\d+)/.exec(r)?.[1]??0),o=await qt(t);return{width:o?n:i,height:o?i:n,hasAlpha:/hasAlpha:\s*yes/i.test(r)}}function*D(t,e,r){let i=e;for(;i+8<=r;){let n=t.readUInt32BE(i),o=8;if(n===1&&i+16<=r?(n=Number(t.readBigUInt64BE(i+8)),o=16):n===0&&(n=r-i),n<o)return;yield{type:t.toString("latin1",i+4,i+8),start:i+o,end:Math.min(i+n,r)},i+=n}}async function qt(t){let e=await It(t,"r");try{let r=Buffer.alloc(262144),{bytesRead:i}=await e.read(r,0,r.length,0),n=[...D(r,0,i)].find(c=>c.type==="meta");if(!n)return!1;let o=[...D(r,n.start+4,n.end)],a=o.find(c=>c.type==="pitm"),d=o.find(c=>c.type==="iprp");if(!a||!d)return!1;let s=r.readUInt8(a.start)===0?r.readUInt16BE(a.start+4):r.readUInt32BE(a.start+4),h=[...D(r,d.start,d.end)],l=h.find(c=>c.type==="ipco"),p=h.find(c=>c.type==="ipma");if(!l||!p)return!1;let f=new Map;if([...D(r,l.start,l.end)].forEach((c,y)=>{c.type==="irot"&&f.set(y+1,r.readUInt8(c.start)&3)}),f.size===0)return!1;let u=r.readUInt8(p.start),x=(r.readUInt8(p.start+3)&1)===1,m=p.start+4,g=r.readUInt32BE(m);m+=4;for(let c=0;c<g&&m<p.end;c++){let y=u<1?r.readUInt16BE(m):r.readUInt32BE(m);m+=u<1?2:4;let z=r.readUInt8(m);m+=1;for(let b=0;b<z;b++){let L=x?r.readUInt16BE(m)&32767:r.readUInt8(m)&127;if(m+=x?2:1,y===s&&(f.get(L)??0)%2===1)return!0}}return!1}catch{return!1}finally{await e.close().catch(()=>{})}}var Qt=new Set(["jpeg","png","webp","avif","heic","gif","tiff"]),Yt=new Set(["jpeg","png","webp","avif","gif","tiff"]),te={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function ee(t,e){if(e.format==="heif")return e.compression==="av1"?"avif":"heic";let r=te[e.format??""];if(!r)throw st(t,e.format??"an unknown format");return r}async function re(t){let e;try{e=await Zt(t)}catch(n){let o=n.code;throw o==="ENOENT"?et(t):o==="EACCES"||o==="EPERM"?W(t):o==="ENOTDIR"?it(t):o==="ELOOP"?nt(t):o==="ENAMETOOLONG"?ot(t):at(t,n)}if(!e.isFile())throw rt(t);try{await Vt(t,Jt.R_OK)}catch{throw W(t)}if(await vt(t)){if(!await P())throw I(t);let n;try{n=await Ot(t)}catch(o){throw j(t,"heic",o)}if(n.width===0||n.height===0)throw j(t,"heic",void 0);return{kind:"image",path:t,format:"heic",width:n.width,height:n.height,bytes:e.size,hasAlpha:n.hasAlpha,frames:1}}let r=await M(),i;try{i=await r(t).metadata()}catch(n){throw ht(t,n)}return{kind:"image",path:t,format:ee(t,i),width:i.autoOrient?.width??i.width??0,height:i.autoOrient?.height??i.height??0,bytes:e.size,hasAlpha:i.hasAlpha??!1,frames:i.pages??1}}function K(t,e,r,i){let n=r??w[e].defaultQuality;if(i&&w[e].quantisable)return ie(t,e,r,i);switch(e){case"jpeg":return t.jpeg({quality:n,mozjpeg:!0});case"webp":return t.webp({quality:n});case"avif":return t.avif({quality:n});case"png":return t.png({compressionLevel:9});case"gif":return t.gif();case"tiff":return t.tiff({compression:"deflate"});case"heic":throw new Error("heic is not writable; the capability graph should have prevented this");case"pdf":throw new Error("pdf is not an image target; the capability graph should have prevented this");case"docx":throw new Error("docx is not an image target; the capability graph should have prevented this");case"doc":throw new Error("doc is not an image target; the capability graph should have prevented this");default:throw new Error(`${e} is not an image target; the capability graph should have prevented this`)}}function ie(t,e,r,{dither:i}){let n=r??100,o=i?1:0;return e==="gif"?t.gif({interFrameMaxError:Math.round(32*(100-n)/100),dither:o}):t.png({palette:!0,quality:n,dither:o,compressionLevel:9,effort:10})}var Q=(t,e)=>t.kind==="image"&&t.frames>1&&w[e].animatable;async function ne(t,e){let r=Kt(e);await q(e);let i=gt(e);try{return await Gt(i,t),await yt(i,e),t.length}catch(n){throw await Xt(i,{force:!0}).catch(()=>{}),ct(e,n)}}async function F(t,e,r,i,n,o){if(t.kind!=="image")throw new Error("pipelineFor received a non-image source");if(n===void 0&&t.format==="heic"&&!await P())throw I(t.path);let a=n===void 0&&t.format==="heic"?await $(t.path):void 0,d=async()=>{await a?.cleanup()},h=(await M())(n??a?.path??t.path,i?{animated:!0}:{});if(h=h.rotate(),r.trim&&(h=h.trim()),r.crop){if(!r.crop.box)throw new Error("pipelineFor needs the crop placed (run does it)");h=h.extract(r.crop.box)}if(r.resize){if(!o&&(r.trim||r.crop))throw new Error("pipelineFor needs the resolved size to resize a cut image");let l=o??X(t,r.resize);h=h.resize(l.width,l.height,{fit:"fill"})}return t.hasAlpha&&!w[e].hasAlpha&&(h=h.flatten({background:r.background})),h=r.keepMetadata?h.keepMetadata():h.keepIccProfile(),{pipeline:h,cleanup:d}}async function ar(t,e){let r={background:"#ffffff",keepMetadata:!1},{pipeline:i,cleanup:n}=await F(t,"png",r,!1);try{await i.png({compressionLevel:1}).toFile(e)}finally{await n()}}async function sr(t,e,r){let{pipeline:i,cleanup:n}=await F(t,e,r,Q(t,e));try{return await K(i,e,r.quality,r.compress).toBuffer()}finally{await n()}}async function oe(t){let e={width:t.width,height:t.height};if(t.frames>1)return{upright:e,trimmed:"animated"};if(t.format==="heic"&&!await P())throw I(t.path);let r=t.format==="heic"?await $(t.path):void 0;try{let i=await M(),{info:n}=await i(r?.path??t.path).rotate().trim().jpeg({quality:1}).toBuffer({resolveWithObject:!0});return n.width===e.width&&n.height===e.height?{upright:e,trimmed:"nothing"}:{upright:e,trimmed:{width:n.width,height:n.height}}}catch(i){throw C(i)?i:U(t.path,i)}finally{await r?.cleanup()}}var Tt=1024;async function ae(t){let e={background:"#ffffff",keepMetadata:!1},{pipeline:r,cleanup:i}=await F(t,"png",e,!1);try{let{data:n,info:o}=await r.resize(Tt,Tt,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0}),a=o.width*o.height,d=o.channels,s=new Uint8Array(a*3),h=new Uint8Array(a),l=!1;for(let p=0;p<a;p++){for(let f=0;f<3;f++)s[p*3+f]=n[p*d+(d>=4?f:0)]??0;h[p]=n[p*d+d-1]??255,h[p]!==255&&(l=!0)}return{size:{width:t.width,height:t.height},thumb:{width:o.width,height:o.height,rgb:s,...l?{alpha:h}:{}}}}catch(n){throw C(n)?n:U(t.path,n)}finally{await i()}}var Pt=128;async function se(t,e){let{thumb:r,size:i}=t,n=A(r,e),o=await M(),{info:a}=await o(he(r),{raw:{width:r.width,height:r.height,channels:3}}).resize(n.width,n.height,{fit:"cover",position:o.strategy.attention}).raw().toBuffer({resolveWithObject:!0}),d=A(i,e),s=Math.round(-(a.cropOffsetLeft??0)*i.width/r.width),h=Math.round(-(a.cropOffsetTop??0)*i.height/r.height);return{...d,left:Math.min(Math.max(s,0),i.width-d.width),top:Math.min(Math.max(h,0),i.height-d.height)}}function he(t){let{alpha:e}=t;if(!e)return t.rgb;let r=new Uint8Array(t.rgb.length);for(let i=0;i<r.length;i++){let n=(e[Math.floor(i/3)]??255)/255;r[i]=Math.round(Pt+((t.rgb[i]??0)-Pt)*n)}return r}async function ce(t,e){if(t.op!=="convert")throw new Error(`image engine cannot ${t.op}`);let r=t.sources[0],i=t.outputs[0];if(r.kind!=="image")throw new Error("the image engine cannot convert a document source");let n=w[t.target],o=[];e({phase:"reading"});let a=r.frames>1,d=Q(r,t.target);a&&!n.animatable&&o.push({code:"animation-flattened",message:`${k(r.path)} has ${r.frames} frames, and ${n.label} cannot animate. Only the first frame was converted.`});let s=t.options,h;if(s.trim||s.crop||s.resize){let f={width:r.width,height:r.height};if(s.trim&&s.crop)throw new Error("a job cannot both trim and crop");if(s.crop){if(a)throw wt(r.path);let{aspect:u}=s.crop,x=c=>c.width===r.width&&c.height===r.height,m=A(f,u),g=s.crop.box??(x(m)?m:await se(await ae(r),u));if(x(g)){if(!s.resize)throw lt(r.path,J(u));o.push({code:"nothing-cropped",message:`${k(r.path)} is already ${J(u)}; resized only.`});let{crop:c,...y}=s;s=y}else s={...s,crop:{aspect:u,box:g}},f={width:g.width,height:g.height}}if(s.trim){if(a)throw mt(r.path);let{trimmed:u}=await oe(r);if(u==="nothing"){if(!s.resize)throw ut(r.path);o.push({code:"nothing-trimmed",message:`${k(r.path)} has no empty edges; resized only.`})}else u!=="animated"&&(f=u)}if(s.resize&&(h=X(f,s.resize),St(h)))throw dt(r.path,h)}e({phase:"decoding"});let{pipeline:l,cleanup:p}=await F(r,t.target,s,d,void 0,h);try{await q(i),e({phase:"encoding"});let f=await K(l,t.target,s.quality,s.compress).toBuffer();if(s.compress&&f.length>=r.bytes)throw pt(r.path,r.bytes,f.length);e({phase:"writing"});let u=await ne(f,i);return{job:t,outputBytes:u,warnings:o}}catch(f){throw C(f)?f:U(r.path,f)}finally{await p()}}async function fe(t){if(t.format!=="heic")return Bt(t.path);if(!await P())throw I(t.path);let e=await $(t.path);try{return await Bt(e.path)}finally{await e.cleanup()}}async function de(t){if(t.op!=="convert")return;let e=w[t.target];if(!e.lossy&&!(e.quantisable&&t.options.compress))return;let r=t.sources[0];if(r.kind!=="image")return;let i=await fe(r);return{ladder:[{}],measure:async n=>{let{pipeline:o}=await F(r,t.target,n,Q(r,t.target),i);return(await K(o,t.target,n.quality,n.compress).toBuffer()).length}}}var hr={id:"image",reads:Qt,writes:Yt,ops:new Set(["convert"]),probe:re,run:ce,measurer:de};export{Ft as a,ue as b,me as c,A as d,le as e,we as f,ge as g,ye as h,xe as i,be as j,Se as k,Ie as l,Me as m,Oe as n,V as o,Be as p,kt as q,bt as r,X as s,St as t,S as u,M as v,ze as w,Re as x,ke as y,Ce as z,Ue as A,Ne as B,De as C,P as D,$ as E,vt as F,K as G,ne as H,ar as I,sr as J,oe as K,ae as L,se as M,hr as N};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{execFile as O,spawn as B}from"node:child_process";import{access as I,constants as T}from"node:fs/promises";import{join as A}from"node:path";import{promisify as K}from"node:util";function E(e){let[n,r]=(e??"").split("/").map(Number);return!n||!r?0:Math.round(n/r*100)/100}function R(e){let n=e.side_data_list?.find(t=>typeof t.rotation=="number")?.rotation,r=n!==void 0?-n:Number(e.tags?.rotate??0);return(Math.round(r/90)*90%360+360)%360}function S(e){let n=e,r=n.streams??[],t=r.find(o=>o.codec_type==="video"&&o.disposition?.attached_pic!==1),i=r.find(o=>o.codec_type==="audio"),a={duration:Number(n.format?.duration)||Math.max(0,...r.map(o=>Number(o.duration)||0))};if(t){let o=R(t),f=o===90||o===270,s=t.width??0,u=t.height??0;a.video={codec:t.codec_name??"",width:f?u:s,height:f?s:u,fps:E(t.avg_frame_rate)||E(t.r_frame_rate),rotation:o,hdr:t.color_transfer==="arib-std-b67"||t.color_transfer==="smpte2084"}}return i&&(a.audio={codec:i.codec_name??"",channels:i.channels??0,sampleRate:Number(i.sample_rate)||0}),a}var _=K(O);function $(e,n){let r=n.PATH??n.Path??"",t=e==="win32"?";":":",i=r.split(t).filter(Boolean);return e==="darwin"&&i.push("/opt/homebrew/bin","/usr/local/bin"),[...new Set(i)]}var L=e=>process.platform==="win32"?`${e}.exe`:e;async function N(e){try{return await I(e,T.X_OK),!0}catch{return!1}}function D(e){let n=new Set;for(let r of e.split(`
|
|
4
|
+
`)){let t=r.match(/^\s*[A-Z.|]{3,6}\s+(\S+)\s/);t?.[1]&&t[1]!=="="&&n.add(t[1])}return n}async function G(){try{let{installed:e}=await import("./paths-5XI5L4KW.js");return(await e("video"))?.dir}catch{return}}async function J(){let e=await G(),n=[...$(process.platform,process.env),...e?[e]:[]];for(let r of n){let t=A(r,L("ffmpeg")),i=A(r,L("ffprobe"));if(!await N(t)||!await N(i))continue;try{await _(t,["-hide_banner","-version"],{timeout:5e3})}catch{continue}let[m,a]=await Promise.all(["-encoders","-filters"].map(f=>_(t,["-hide_banner",f],{timeout:5e3,maxBuffer:4<<20}).then(({stdout:s})=>D(s)).catch(()=>{}))),o=m&&a?new Set([...m,...a]):void 0;return{ffmpeg:t,ffprobe:i,...o?{has:o}:{}}}}var h,y=null;function v(){return y?Promise.resolve(y.value):(h=(h??J()).then(n=>(n||(h=void 0),n)),h)}function U(e){y=e===null?null:{value:e},h=void 0}async function W(e,n){let r=n??await v();if(!r)throw new Error("ffmpeg is not installed");let{stdout:t}=await _(r.ffprobe,["-v","error","-print_format","json","-show_format","-show_streams",e],{timeout:3e4,maxBuffer:16*1024*1024});return S(JSON.parse(t))}async function Y(e,n,r){let t=r??await v();if(!t)return;let i=Math.max(0,n-15),{stdout:m}=await _(t.ffprobe,["-v","error","-select_streams","v:0","-skip_frame","nokey","-show_entries","frame=pts_time","-of","csv=p=0","-read_intervals",`${i}%${n+.01}`,e],{timeout:3e4,maxBuffer:4*1024*1024}),a=m.split(`
|
|
5
|
+
`).map(o=>Number.parseFloat(o)).filter(o=>Number.isFinite(o)&&o<=n+.001);return a.length?Math.max(...a):void 0}var k=4e3;async function ee(e,n,r,t={}){let i=t.tools??await v();if(!i)return null;let m=Math.max(1,Math.round(n*k)),a=Math.max(1,Math.ceil(m/r)),o=new Array(r).fill(0),f=0,s=Buffer.alloc(0);if(!await new Promise((p,d)=>{let c=B(i.ffmpeg,["-hide_banner","-nostdin","-loglevel","error","-i",e,"-map","0:a:0","-ac","1","-ar",String(k),"-f","s16le","-"],{stdio:["ignore","pipe","pipe"]}),b=()=>c.kill("SIGKILL");t.signal?.addEventListener("abort",b,{once:!0}),c.stdout.on("data",l=>{let w=s.length?Buffer.concat([s,l]):l,F=w.length-w.length%2;for(let x=0;x<F;x+=2){let P=Math.abs(w.readInt16LE(x)),M=Math.min(r-1,Math.floor(f/a));P>(o[M]??0)&&(o[M]=P),f++}s=w.subarray(F)}),c.stderr.resume(),c.on("error",d),c.on("close",l=>{t.signal?.removeEventListener("abort",b),t.signal?.aborted?d(t.signal.reason??new Error("aborted")):p(l===0&&f>0)})}))return null;let g=Math.max(1,...o);return o.map(p=>Math.sqrt(p/g))}async function te(e,n,r,t){await C(["-ss",String(Math.max(0,n)),"-i",e,"-frames:v","1","-y",r],{tools:t})}function j(e){let n;for(let r of e.matchAll(/out_time_us=(\d+)/g))n=Number(r[1])/1e6;return n}var q=4e3;async function C(e,n={}){let{signal:r,onTime:t}=n;if(r?.aborted)throw r.reason??new Error("aborted");let i=n.tools??await v();if(!i)throw new Error("ffmpeg is not installed");let a=["-hide_banner","-nostdin","-loglevel",n.report?"info":"error","-progress","pipe:1","-nostats",...e];return new Promise((o,f)=>{let s=B(i.ffmpeg,a,{stdio:["ignore","pipe","pipe"]}),u="",g=()=>s.kill("SIGKILL");r?.addEventListener("abort",g,{once:!0}),s.stdout.setEncoding("utf8");let p="";s.stdout.on("data",d=>{let c=p+d,b=c.lastIndexOf(`
|
|
6
|
+
`);p=c.slice(b+1);let l=j(c.slice(0,b+1));l!==void 0&&t?.(l)}),s.stderr.setEncoding("utf8"),s.stderr.on("data",d=>{u=(u+d).slice(-q)}),s.on("error",d=>{r?.removeEventListener("abort",g),f(d)}),s.on("close",d=>{r?.removeEventListener("abort",g),r?.aborted?f(r.reason??new Error("aborted")):d===0?o(u):f(new Error(u.trim()||`ffmpeg exited with ${d}`))})})}export{$ as a,D as b,v as c,U as d,W as e,Y as f,ee as g,te as h,j as i,C as j};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as A}from"./chunk-BZXDNDPG.js";import{b as w,e as m,l as R}from"./chunk-QR6QHTC3.js";import{a as P,b as l}from"./chunk-6L6C3GJU.js";import{d as k,k as O,s as M}from"./chunk-KAHWYWNT.js";import{c as x,d as I,e as c,i as z,m as F}from"./chunk-EXLXSKRH.js";import{F as S}from"./chunk-3UEQ2OX6.js";import{b as u,e as g}from"./chunk-AAXBN572.js";import{a as f,b as y}from"./chunk-M66BUNYO.js";import{dirname as J,join as E}from"node:path";var C="Same location",j="New subfolder";function L(e,t){return e===t?C:e===u("Desktop")?"Desktop":e===u("Downloads")?"Downloads":t!==void 0&&e===E(t,"converted")?j:A(e)||e}function T(e,t,n={}){return _(J(e.path),t,n)}function _(e,t,{subfolder:n=!1}={}){let i=g(t.defaultOutput),o=t.lastOutput?g(t.lastOutput):void 0,r=p=>({label:L(p,e),path:p}),s=[r(i),...o?[r(o)]:[],r(u("Desktop")),...e===void 0?[]:[{label:C,path:e}],r(u("Downloads")),...n&&e!==void 0?[{label:j,path:E(e,"converted")}]:[]],a=new Set,d=s.filter(p=>a.has(p.path)?!1:(a.add(p.path),!0));return{kind:"path",id:"destination",label:"Save to",default:i,presets:d,...o&&o!==i?{last:o}:{}}}var b=e=>typeof e=="string"&&e!==""?e:void 0;var B=-16;function dt(e){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[e]??e}var D=e=>e.length===1&&e[0]?.kind==="media"?e[0]:void 0,U=e=>e==="cut"||e==="mute"||e==="resize"||e==="crop"||e==="loudness";function Q(e,t){let n=t.media??{},i=e.facts?.video,o=[];return n.cut&&o.push("trimmed"),n.mute&&o.push("muted"),n.loudness!==void 0&&o.push("levelled"),n.speed!==void 0&&o.push(`${n.speed}x`),n.fps!==void 0&&o.push(`${n.fps}fps`),n.bitrate!==void 0&&o.push(`${n.bitrate}k`),t.crop&&o.push(O(t.crop.aspect)),t.resize&&o.push(i?R(M(i,t.resize)):"resized"),o.length===1?o[0]:"edited"}function W(e,t){return e.map(n=>{let i=t.target??n.format,o={background:"#ffffff",keepMetadata:!1};t.media&&Object.keys(t.media).length&&(o.media=t.media),t.resize&&(o.resize=t.resize);let r=n.facts?.video;t.crop&&r&&(o.crop={aspect:t.crop.aspect,box:t.crop.box??k(r,t.crop.aspect)});let s=t.roots?.get(n.path),a=c({sourcePath:n.path,target:i,suffix:Q(n,t),...t.output===void 0?{}:{output:t.output},...s===void 0?{}:{sourceRoot:s}});return{op:"convert",sources:[n],outputs:[F(a,b(t.destination),b(t.name))],target:i,options:o}})}function h(e){let t={},n=e.cut;return n&&typeof n.start=="number"&&(t.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),e.mute===!0&&(t.mute=!0),typeof e.speed=="number"&&(t.speed=e.speed),typeof e.fps=="number"&&(t.fps=e.fps),typeof e.bitrate=="number"&&(t.bitrate=e.bitrate),typeof e.loudness=="number"&&(t.loudness=e.loudness),Object.keys(t).length?t:void 0}var pt={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, resize, crop",appliesTo:e=>D(e)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(e,t){let n=D(e);if(!n||!U(t.tool))return[];let i=t.tool,o={...typeof t.output=="string"?{output:t.output}:{},destination:t.destination,name:t.name};if(i==="cut"){let r=h(t)?.cut;if(!r)return[];o.media={cut:r}}if(i==="mute"&&(o.media={mute:!0}),i==="loudness"&&(o.media={loudness:typeof t.loudness=="number"?t.loudness:B}),i==="resize"){if(typeof t.resize!="object"||t.resize===null)return[];o.resize=t.resize}if(i==="crop"){let r=t.crop;if(!r?.aspect||!n.facts?.video)return[];o.crop=r}return W([n],o)}};function G(e){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${e.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function H(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function K(e,t){return Array.isArray(t)?l(t):t==="first"?[0]:typeof t=="string"&&t!=="all"&&t!==""?l(P(t,e.pages)):Array.from({length:e.pages},(n,i)=>i)}function V(e,t){let n=f[e.format].lossy,i=f[t].lossy;if(n&&!i)return{hint:"likely bigger",tone:"warn"};if(!n&&i)return{hint:"likely smaller",tone:"ok"}}function X(e){let t=w(e).filter(i=>i.id!==e.format),n=t[0];return{kind:"select",id:"target",label:`Convert ${f[e.format].label} to`,choices:t.map(i=>{let o=V(e,i.id);return{value:i.id,label:i.label,hint:o?.hint??i.hint,...o===void 0?{}:{tone:o.tone}}}),default:n?n.id:""}}function Y(e){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:e==="opus"?96:128}}var Z=e=>typeof e=="object"&&e!==null&&("percent"in e||"width"in e||"height"in e);function v(e){let t=e.target,n=typeof t=="string"?y(t):void 0;if(!n)throw S(`convertAction.plan() requires a valid target format, got ${JSON.stringify(t)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var yt={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:e=>e.length>=1,options(e,t,n){let i=e[0];if(!i)return[];let o=[X(i)],r=t.target;if(typeof r!="string")return o;i.kind==="document"&&m(r)&&o.push(G(i),H());let s=f[r];return i.kind==="media"?s?.media==="sound"&&s.lossy&&o.push(Y(r)):s?.lossy&&s.media===void 0&&o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),o.push(T(i,n,{subfolder:!0})),o},plan(e,t){let n=e[0];if(!n)return[];let i=v(t),o=i.id,r={background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0};if(i.lossy&&typeof t.quality=="number"&&(r.quality=t.quality),n.kind==="media"){let d=h(t);d&&(r.media=d),Z(t.resize)&&(r.resize=t.resize)}let s=typeof t.destination=="string"?t.destination:void 0;if(n.kind==="document"&&m(o)){let d=Number(t.dpi);r.dpi=Number.isFinite(d)&&d>0?d:150;let p=K(n,t.pages);r.pages=p;let N=typeof t.sourceRoot=="string"?t.sourceRoot:void 0,$=z(n.path,p,o,s,N);return[{op:"convert",sources:[n],outputs:$,target:o,options:r}]}let a=I({sourcePath:n.path,target:o,...s===void 0?{}:{output:`${s}/`}});return x(a,n.path)&&(a=c({sourcePath:n.path,target:o,suffix:o,...s===void 0?{}:{output:`${s}/`}})),[{op:"convert",sources:[n],outputs:[a],target:o,options:r}]}};export{j as a,T as b,_ as c,b as d,dt as e,W as f,h as g,pt as h,yt as i};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
var a={jpeg:{id:"jpeg",label:"JPEG",extensions:[".jpg",".jpeg"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"universal",defaultQuality:82},png:{id:"png",label:"PNG",extensions:[".png"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"lossless",quantisable:!0},webp:{id:"webp",label:"WebP",extensions:[".webp"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smaller, modern",defaultQuality:80},avif:{id:"avif",label:"AVIF",extensions:[".avif"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smallest",defaultQuality:50},heic:{id:"heic",label:"HEIC",extensions:[".heic",".heif"],hasAlpha:!0,animatable:!1,lossy:!0,hint:"Apple photos"},mp4:{id:"mp4",label:"MP4",extensions:[".mp4",".m4v"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"H.264 \xB7 AAC",media:"video"},mov:{id:"mov",label:"MOV",extensions:[".mov",".qt"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"QuickTime",media:"video",keepsOnly:!0},hevc:{id:"hevc",label:"HEVC",extensions:[".mp4"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"H.265 \xB7 AAC",media:"video"},webm:{id:"webm",label:"WebM",extensions:[".webm"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"VP9 \xB7 Opus",media:"video"},gif:{id:"gif",label:"GIF",extensions:[".gif"],hasAlpha:!0,animatable:!0,lossy:!1,hint:"animation",quantisable:!0,media:"video"},tiff:{id:"tiff",label:"TIFF",extensions:[".tif",".tiff"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"archival"},pdf:{id:"pdf",label:"PDF",extensions:[".pdf"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"document"},docx:{id:"docx",label:"DOCX",extensions:[".docx"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"Word document"},doc:{id:"doc",label:"DOC",extensions:[".doc"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"legacy Word"},mkv:{id:"mkv",label:"MKV",extensions:[".mkv"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"Matroska",media:"video",keepsOnly:!0},avi:{id:"avi",label:"AVI",extensions:[".avi"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"legacy video",media:"video",keepsOnly:!0},mp3:{id:"mp3",label:"MP3",extensions:[".mp3"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"plays anywhere",media:"sound"},m4a:{id:"m4a",label:"M4A",extensions:[".m4a",".m4b"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"AAC",media:"sound"},opus:{id:"opus",label:"Opus",extensions:[".opus"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"smallest",media:"sound"},flac:{id:"flac",label:"FLAC",extensions:[".flac"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"lossless",media:"sound"},aiff:{id:"aiff",label:"AIFF",extensions:[".aiff",".aif",".aifc"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"uncompressed",media:"sound"},wav:{id:"wav",label:"WAV",extensions:[".wav"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"uncompressed",media:"sound"},ogg:{id:"ogg",label:"OGG",extensions:[".ogg",".oga"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"Vorbis",media:"sound",keepsOnly:!0}},l=Object.keys(a);function i(e){return a[e.toLowerCase()]}function t(e){let s=a[e].extensions[0];if(!s)throw new Error(`format ${e} declares no extensions`);return s}export{a,i as b,t as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
var v="0.4.
|
|
4
|
-
\u25BC`,dotFilled:"\u25CF",dotEmpty:"\u25CB"},f={name:"dark",fg:"#e7e7e7",dim:"#b0b0b0",accent:"#e5a23c",ok:"#6fcf7f",warn:"#e5c07b",fail:"#e8796d",failTint:"#2e2020",failTintDim:"#b0b0b0",larger:"#f2994a",shedHatch:"#47774f",grownFill:"#403225",tag:"#63c1d8",label:"#a68ce0",modeConvert:"#55c7d9",modeConvertBg:"#122c33",modeCompress:"#79c98b",modeCompressBg:"#182c1e",modePdf:"#ff6b4a",modePdfBg:"#361c16",modeColour:"#f27ba8",modeColourBg:"#3a1e2b",modeEdit:"#b39ae8",modeEditBg:"#2a2238",modeTranscribe:"#e63946",modeTranscribeBg:"#3a1a1d",border:"#808080",selectionBg:"#2c2c2c",band:"#2c2c2c",canvas:"#1e1e1e",textSelectionBg:"#3f5c86",brand:"#e5a23c",keycapBg:"#333333",violet:"#a68ce0",faint:"#4d4d4d",listBand:"#323232",shelf:"#242424",tabChip:"#262626",panelBand:"#404040",ink:"#0c1d22",track:"#2e2e2e",trackFill:"#515151",thumb:"#e7e7e7",folderChip:"#414141",pill:"#e7e7e7",fieldBand:"#3d3d3d",defaultTagBg:"#33261a",defaultTag:"#c98a4b",newTagBg:"#2a3448",newTag:"#4f77c5"},o={name:"light",fg:"#262626",dim:"#4f4f4f",accent:"#915a01",ok:"#0e702c",warn:"#8a6100",fail:"#a43c32",failTint:"#f9e3df",failTintDim:"#4a4a4a",larger:"#8b4d01",shedHatch:"#87b896",grownFill:"#ece3d6",tag:"#0a6b86",label:"#5e4b99",modeConvert:"#036b7b",modeConvertBg:"#e6f7fa",modeCompress:"#24733a",modeCompressBg:"#eaf5ec",modePdf:"#b82a06",modePdfBg:"#fceee9",modeColour:"#b0306a",modeColourBg:"#f7e3ec",modeEdit:"#64569f",modeEditBg:"#f0ebfa",modeTranscribe:"#c0102c",modeTranscribeBg:"#fef0ef",border:"#767676",selectionBg:"#e4e4e4",band:"#e4e4e4",canvas:"#ffffff",textSelectionBg:"#b9cfe8",brand:"#915a01",keycapBg:"#e1e1e1",violet:"#5e4b99",faint:"#b2b2b2",listBand:"#dcdcdc",shelf:"#f3f3f3",tabChip:"#f0f0f0",panelBand:"#d5d5d5",ink:"#ffffff",track:"#e4e4e4",trackFill:"#afafaf",thumb:"#262626",folderChip:"#d0d0d0",pill:"#262626",fieldBand:"#d7d7d7",defaultTagBg:"#f5e2cc",defaultTag:"#8f5000",newTagBg:"#e1e7f4",newTag:"#3358a3"},i={name:"neutral",fg:"",dim:"gray",accent:"yellow",ok:"green",warn:"yellow",fail:"red",failTint:"",failTintDim:"gray",larger:"yellow",shedHatch:"green",grownFill:"",tag:"cyan",label:"magenta",modeConvert:"cyan",modeConvertBg:"",modeCompress:"green",modeCompressBg:"",modePdf:"red",modePdfBg:"",modeColour:"magenta",modeColourBg:"",modeEdit:"magenta",modeEditBg:"",modeTranscribe:"redBright",modeTranscribeBg:"",border:"gray",selectionBg:"",band:"",canvas:"",textSelectionBg:"",brand:"yellow",keycapBg:"",violet:"magenta",faint:"gray",listBand:"",shelf:"",tabChip:"",panelBand:"",ink:"",track:"",trackFill:"",thumb:"",folderChip:"",pill:"",fieldBand:"",defaultTagBg:"",defaultTag:"",newTagBg:"",newTag:""},d=["convert","compress","pdf","edit","
|
|
3
|
+
var v="0.4.2",x={ok:"\u2713",fail:"\u2715",warn:"\u26A0",cursor:"\u276F",strip:"\u258C",star:"\u2605",arrow:"\u2192",tip:"\u2727",longArrow:"\u2500\u2500\u2192",longArrowDown:`\u2502
|
|
4
|
+
\u25BC`,dotFilled:"\u25CF",dotEmpty:"\u25CB"},f={name:"dark",fg:"#e7e7e7",dim:"#b0b0b0",accent:"#e5a23c",ok:"#6fcf7f",warn:"#e5c07b",fail:"#e8796d",failTint:"#2e2020",failTintDim:"#b0b0b0",larger:"#f2994a",shedHatch:"#47774f",grownFill:"#403225",tag:"#63c1d8",label:"#a68ce0",modeConvert:"#55c7d9",modeConvertBg:"#122c33",modeCompress:"#79c98b",modeCompressBg:"#182c1e",modePdf:"#ff6b4a",modePdfBg:"#361c16",modeColour:"#f27ba8",modeColourBg:"#3a1e2b",modeEdit:"#b39ae8",modeEditBg:"#2a2238",modeTranscribe:"#e63946",modeTranscribeBg:"#3a1a1d",border:"#808080",selectionBg:"#2c2c2c",band:"#2c2c2c",canvas:"#1e1e1e",textSelectionBg:"#3f5c86",brand:"#e5a23c",keycapBg:"#333333",violet:"#a68ce0",faint:"#4d4d4d",listBand:"#323232",shelf:"#242424",tabChip:"#262626",panelBand:"#404040",ink:"#0c1d22",track:"#2e2e2e",trackFill:"#515151",thumb:"#e7e7e7",folderChip:"#414141",pill:"#e7e7e7",fieldBand:"#3d3d3d",defaultTagBg:"#33261a",defaultTag:"#c98a4b",newTagBg:"#2a3448",newTag:"#4f77c5"},o={name:"light",fg:"#262626",dim:"#4f4f4f",accent:"#915a01",ok:"#0e702c",warn:"#8a6100",fail:"#a43c32",failTint:"#f9e3df",failTintDim:"#4a4a4a",larger:"#8b4d01",shedHatch:"#87b896",grownFill:"#ece3d6",tag:"#0a6b86",label:"#5e4b99",modeConvert:"#036b7b",modeConvertBg:"#e6f7fa",modeCompress:"#24733a",modeCompressBg:"#eaf5ec",modePdf:"#b82a06",modePdfBg:"#fceee9",modeColour:"#b0306a",modeColourBg:"#f7e3ec",modeEdit:"#64569f",modeEditBg:"#f0ebfa",modeTranscribe:"#c0102c",modeTranscribeBg:"#fef0ef",border:"#767676",selectionBg:"#e4e4e4",band:"#e4e4e4",canvas:"#ffffff",textSelectionBg:"#b9cfe8",brand:"#915a01",keycapBg:"#e1e1e1",violet:"#5e4b99",faint:"#b2b2b2",listBand:"#dcdcdc",shelf:"#f3f3f3",tabChip:"#f0f0f0",panelBand:"#d5d5d5",ink:"#ffffff",track:"#e4e4e4",trackFill:"#afafaf",thumb:"#262626",folderChip:"#d0d0d0",pill:"#262626",fieldBand:"#d7d7d7",defaultTagBg:"#f5e2cc",defaultTag:"#8f5000",newTagBg:"#e1e7f4",newTag:"#3358a3"},i={name:"neutral",fg:"",dim:"gray",accent:"yellow",ok:"green",warn:"yellow",fail:"red",failTint:"",failTintDim:"gray",larger:"yellow",shedHatch:"green",grownFill:"",tag:"cyan",label:"magenta",modeConvert:"cyan",modeConvertBg:"",modeCompress:"green",modeCompressBg:"",modePdf:"red",modePdfBg:"",modeColour:"magenta",modeColourBg:"",modeEdit:"magenta",modeEditBg:"",modeTranscribe:"redBright",modeTranscribeBg:"",border:"gray",selectionBg:"",band:"",canvas:"",textSelectionBg:"",brand:"yellow",keycapBg:"",violet:"magenta",faint:"gray",listBand:"",shelf:"",tabChip:"",panelBand:"",ink:"",track:"",trackFill:"",thumb:"",folderChip:"",pill:"",fieldBand:"",defaultTagBg:"",defaultTag:"",newTagBg:"",newTag:""},d=["convert","compress","pdf","edit","transcribe","colour"],k=`1\u2013${d.length}`;function E(e,t){let r=d,n=e==="menu"?r.length:r.indexOf(e),a=Math.max(0,Math.min(r.length-1,n+t));return r[a]}function P(e){return/^[1-9]$/.test(e)?d[Number(e)-1]:void 0}var S={convert:"\u2194",compress:"\u2193",pdf:"\u25A3",colour:"\u25D0",edit:"\u2726",transcribe:"\xB6"},c="#7d6ad0",l="#cc8ae2";function s(e,t){return t==="compress"?{fg:e.modeCompress,bg:e.modeCompressBg}:t==="pdf"?{fg:e.modePdf,bg:e.modePdfBg}:t==="colour"?{fg:e.modeColour,bg:e.modeColourBg}:t==="edit"?{fg:e.modeEdit,bg:e.modeEditBg}:t==="transcribe"?{fg:e.modeTranscribe,bg:e.modeTranscribeBg}:{fg:e.modeConvert,bg:e.modeConvertBg}}var g=["#f26e69","#e5a23c","#ace02c","#55c7d9","#6579fd","#ad95e9"],b=["#e5a23c","#f2cf6b"],m={convert:["#1e96a7","#1e94b3","#1e92c0","#1d8ed2","#1b86ef","#4a7df8","#6974f8","#816af8","#995cf8"],compress:["#24b459","#22ab6d","#21a479","#209f81","#1f9c89","#1f9a91","#1e9998","#1e97a0","#1e96a7"],pdf:["#eb4319","#e3541a","#de601b","#db6a1c","#d9731d","#d87c1e","#d8841f","#d98c20","#d99522"],edit:["#9b5af8","#985cf8","#965ef8","#945ff8","#9161f8","#8f62f8","#8d64f8","#8a65f8","#8867f8"],transcribe:["#f3233e","#f12259","#ee2270","#ea2186","#e6219b","#e121b0","#da22c6","#d122dc","#c723f2"],colour:["#f42335","#e05b1a","#d87d1e","#da9b23","#d2b427","#b4c027","#5bbf23","#20a27c","#1e989b","#1e94b6","#1c8cd9","#577af8","#7371f8","#8568f8","#965df8"]},u=["#d99522","#da9822","#da9b23","#da9f24","#d9a224","#d9a525","#d8a825","#d7ab26","#d6ad26"],B={convert:["#d6f7fd","#ddf5fe","#e1f4fe","#e4f2fe","#e7f1fe","#eaf0fe","#eceffe","#efeefe","#f1edfe"],compress:["#e0f7e4","#def8e7","#dcf8ea","#daf8ed","#d8f8f1","#d7f8f4","#d6f8f7","#d6f8fa","#d6f7fd"],pdf:["#feece7","#feece6","#feece5","#feece3","#feece2","#feede0","#feedde","#feeddc","#feeed9"],edit:["#f2edfe","#f1edfe","#f1edfe","#f1eefe","#f0eefe","#f0eefe","#f0eefe","#f0eefe","#efeefe"],transcribe:["#feebea","#feebec","#feebee","#feeaf0","#feeaf2","#feeaf5","#fee9f9","#fde9fd","#f9eafe"],colour:["#feebe9","#feece5","#feede0","#feeed7","#f7f1d6","#eff3d9","#e5f6df","#dbf8eb","#d6f8f8","#def5fe","#e5f2fe","#ebf0fe","#edeffe","#efeefe","#f1edfe"]},p=["#feeed9","#feeed8","#feeed7","#fdeed6","#fcefd6","#fbefd6","#fbefd6","#faefd6","#f9f0d6"],T={convert:["#138291","#8467bd"],compress:["#2b8748","#138291"],pdf:["#d54322","#a06c10"],edit:["#8567bc","#7b67cd"],transcribe:["#df3140","#9c5cb1"],colour:["#cb4b49","#a06c10","#618110","#138291","#5869ec","#8268bd"]};function C(e,t){return e.name==="light"?t==="menu"?u:m[t]:t==="menu"?e.name==="dark"?b:[e.brand]:t==="compress"?[e.modeCompress,e.modeConvert]:t==="pdf"?[e.modePdf,e.brand]:t==="colour"?e.name==="dark"?g:[e.modeColour,e.violet]:t==="edit"?[e.modeEdit,e.name==="dark"?c:e.violet]:t==="transcribe"?[e.modeTranscribe,e.name==="dark"?l:e.violet]:[e.modeConvert,e.violet]}function y(e,t){if(e.name==="light")return t==="menu"?p:B[t]}function w(e,t){return e.name==="light"?T[t]:C(e,t)}function M(e){return{...e,accent:e.brand,tag:e.brand,label:e.brand}}function R(e,t){let{fg:r,bg:n}=s(e,t);return{...e,accent:r,tag:r,label:r,band:n===""?e.band:n}}function H(e){return e.canvas!==""}function O(e){return e==="dark"?f:e==="light"?o:i}function D(e){return e===""?void 0:e}var _={filled:"\u2501",empty:"\u2501",knob:"\u25CF"};function h(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""?!1:process.stdout.isTTY===!0}function F(){h()||(process.env.FORCE_COLOR="0")}export{v as a,x as b,f as c,o as d,i as e,d as f,k as g,E as h,P as i,S as j,s as k,C as l,y as m,w as n,M as o,R as p,H as q,O as r,D as s,_ as t,h as u,F as v};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{b as P,d as R,e as B}from"./chunk-Y2A3HTKQ.js";import{a as w,b as I,c as k,d as $,e as O,f as m}from"./chunk-TMQDQLY7.js";import{e as h}from"./chunk-EHARO6IS.js";import{i as x}from"./chunk-6L6C3GJU.js";import{Y as y,Z as C,_ as v,b as p}from"./chunk-3UEQ2OX6.js";import{a as f}from"./chunk-J7FLFHQJ.js";import{a as l}from"./chunk-MV7H3QQY.js";import{a as c}from"./chunk-M66BUNYO.js";import{dirname as S,join as q}from"node:path";async function T(t){if(t.fallback!==void 0)return t.fallback;let{loadPreferences:r,expandTilde:e}=await import("./preferences-4VETUGMN.js");return e((await r()).prefs.defaultOutput)}function F(t){if(t.pasteboard)return t.pasteboard;if(!w())throw C();return I()}function E(t,r,e,o){let a=q(r.outDir,`Copied image${c[o].extensions[0]}`),s={inputs:[r.source],output:a,force:!1,recursive:!1,debug:t.debug},n={background:"#ffffff",keepMetadata:!1,...t.quality===void 0?{}:{quality:t.quality}};return o===e?{kind:"compress",...s,options:n,...t.quality===void 0?{}:{quality:t.quality},...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}:{kind:"convert",...s,target:o,options:n,...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}}async function J(t,r={}){let e=r.clip??{},o=F(e),a=await k(o,e.root);if(!a)throw y((await o.peek()).text?"text":"nothing");let s=await x(a.source),n=t.target??s.format,b=E(t,a,s.format,n),i=await R(b,r),g=i.results[0];if(!g||i.failures.length>0)return{report:i,status:"failed"};let u=g.job.outputs[0],d={report:i,output:u,source:{format:s.format,bytes:s.bytes},target:n};if(await $(o,a,u,n)==="changed")return{...d,status:"changed",saved:await m(u,await T(e))};if(t.save===void 0)return{...d,status:"placed"};let j=t.save===!0?await T(e):t.save,{expandTilde:D}=await import("./preferences-4VETUGMN.js");return{...d,status:"placed",saved:await m(u,D(j))}}function N(t){let r=t.target===t.source.format?"":` as ${c[t.target].label}`,e=` ${f(t.source.bytes)} \u2192 ${f(t.report.outputBytes)} \xB7 ${P(t.source.bytes,t.report.outputBytes)}`;if(t.status==="changed"){let a=t.target===t.source.format?"compressed":"converted";return[`\u2713 Copied image \u2192 ${p(t.saved)}${r}`,e,"","\u26A0 Clipboard changed"," The file you uploaded is no longer in the clipboard.",` The ${a} image is saved to ${p(S(t.saved))}.`]}let o=t.saved===void 0?"":` + ${p(t.saved)}`;return[`\u2713 Copied image \u2192 clipboard${r}${o}`,e]}async function U(t){if(!await O(F(t),t.root))throw v()}async function Z(t,r){if(t.undo)return await U(r.clip??{}),{exitCode:0,stdout:r.json?[JSON.stringify({forge:l,ok:!0,clipboard:"restored"})]:["\u2713 The original is back on the clipboard"],stderr:[]};let e=await J(t,r);if(e.status==="failed")return B(e.report,r);if(r.json){let o={...h(l,e.report),clipboard:e.status,...e.saved===void 0?{}:{saved:e.saved}};return{exitCode:0,stdout:[JSON.stringify(o)],stderr:[]}}return{exitCode:0,stdout:N(e),stderr:[]}}export{J as a,N as b,U as c,Z as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{f as m,g as i}from"./chunk-6L6C3GJU.js";import{F as f}from"./chunk-3UEQ2OX6.js";import{a as r}from"./chunk-M66BUNYO.js";function a(t){let e=Object.keys(r);return[...t].sort((o,n)=>e.indexOf(o)-e.indexOf(n))}function s(t){let e=new Set;for(let o of i)if(o.reads.has(t.format))for(let n of o.writesFor?.(t)??o.writes)r[n].keepsOnly&&n!==t.format||e.add(n);return a([...e])}function u(t){return s(t).map(e=>({id:e,label:r[e].label,hint:r[e].hint,lossy:r[e].lossy}))}function d(){let t=new Set;for(let e of i)for(let o of e.reads)t.add(o);return a([...t])}function p(){let t=new Set;for(let e of i)for(let o of e.writes)t.add(o);return a([...t])}function F(t){return m.writes.has(t)}function g(){let t=new Set(d()),e=new Set(p());return a([...new Set([...t,...e])]).map(o=>({id:o,label:r[o].label,extensions:[...r[o].extensions],read:t.has(o),write:e.has(o),lossy:r[o].lossy}))}var z=5,R=200,O=5;function $(t){return t.format==="heic"?"jpeg":s(t).includes(t.format)?t.format:"png"}function j(t,e){let o=i.find(n=>n.id==="image")?.writes;if(!o?.has(t))return f(`Cannot ${e} into ${r[t].label}; only an image format can take the edit.`,`Choose one of: ${[...o??[]].join(", ")}.`)}var T=t=>`${t.width}x${t.height}`,C=t=>"percent"in t?`${t.percent}pct`:"width"in t?`${t.width}w`:`${t.height}h`;export{s as a,u as b,d as c,p as d,F as e,g as f,z as g,R as h,O as i,$ as j,j as k,T as l,C as m};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as f}from"./chunk-EXLXSKRH.js";import{B as c,C as a,D as m}from"./chunk-3UEQ2OX6.js";import{randomBytes as p}from"node:crypto";import{constants as u}from"node:fs";import{access as S,mkdir as h,rename as w,rm as y,writeFile as P}from"node:fs/promises";import{basename as g,dirname as E,extname as x,join as A}from"node:path";function N(r,e=p(6).toString("hex")){let t=x(r);return A(E(r),f(`.forge-${e}-${g(r,t)}`,t))}async function T(r){let e=E(r);try{await h(e,{recursive:!0})}catch(t){let i=a(r,t);throw i===t?m(r,t):i}try{await S(e,u.W_OK)}catch(t){throw c(r,t)}}var W=new Set(["EPERM","EBUSY","EACCES"]),l=5,B=9;async function _(r,e,t=process.platform,i=o=>new Promise(n=>setTimeout(n,o)),d=l){if(t!=="win32"){await w(r,e);return}for(let o=1;;o++)try{await w(r,e);return}catch(n){let s=n.code;if(o>=d||!s||!W.has(s))throw n;await i(Math.min(50*2**(o-1),1e3))}}async function I(r,e){await T(r);let t=N(r);try{return await P(t,e),await _(t,r),e.byteLength}catch(i){throw await y(t,{force:!0}).catch(()=>{}),a(r,i)}}export{N as a,T as b,B as c,_ as d,I as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as E,c as w}from"./chunk-YWKMG5WO.js";import{a as M,b as j,e as S,i as P}from"./chunk-DOWMSJ6R.js";import{watch as k}from"node:fs";import{readdir as I,stat as W}from"node:fs/promises";import{join as z,resolve as x}from"node:path";function A(e,s,n){let r=x(e),c=n.settleMs??1e3,d=n.pollMs??500,i=new Set([...s].map(m=>x(m))),l=new Map,t=!1,a=!1,g=!1,p=async()=>{if(!t){if(a){g=!0;return}a=!0;try{let m=await I(r,{withFileTypes:!0}).catch(()=>[]),h=new Set;for(let o of m){if(!o.isFile()||M(o.name))continue;let f=z(r,o.name);if(h.add(f),i.has(f)||n.ignore?.(f))continue;let y=await W(f).catch(()=>{});if(!y||t)continue;let F=Date.now(),b=l.get(f);if(!b||b.size!==y.size||b.mtimeMs!==y.mtimeMs){l.set(f,{size:y.size,mtimeMs:y.mtimeMs,since:F});continue}F-b.since<c||(l.delete(f),i.add(f),n.onFile(f))}for(let o of[...i,...l.keys()])h.has(o)||(i.delete(o),l.delete(o))}finally{a=!1,g&&!t&&(g=!1,p())}}},v=setInterval(()=>{p()},d),u;try{u=k(r,{persistent:!1},()=>{p()}),u.on("error",()=>{})}catch{}return p(),{close(){t=!0,clearInterval(v),u?.close()}}}function K(e,s,n,r){let c=[],d=[];for(let i of e){let l=s[j(i)];if(!l){d.push({path:i.path,reason:R(s)});continue}let t=P(i,l,n,r);"job"in t?c.push(t.job):d.push({path:i.path,reason:t.left})}return{jobs:c,left:d}}async function G(e,s,n={}){let r=new Set,{jobs:c,left:d}=K(e.sources,s,r,n.destination);return{outcome:await w(c,{force:!1,...n.concurrency===void 0?{}:{concurrency:n.concurrency},...n.onEvent?{onEvent:n.onEvent}:{},...n.signal?{signal:n.signal}:{}}),left:d,claimed:r,jobs:c}}var O={images:"an image",pdfs:"a PDF",documents:"a document",videos:"a video",audio:"audio",other:"a file Forge reads"};function R(e){let s=Object.keys(e).filter(r=>e[r]);if(s.length===0)return"not supported";let n=s.map(r=>O[r]);return`not ${n.length===1?n[0]:`${n.slice(0,-1).join(", ")} or ${n.at(-1)}`}`}var J=(e,s)=>e==="other"?s==="text"?"a text file":"not supported":"not yet supported";function H(e){let s=E(e.concurrency),n=[],r=new Set,c=!1,d=async t=>{e.onEvent({type:"arrived",path:t}),e.onEvent({type:"phase",path:t,phase:"reading"});let a=await S(t);if(a.kind==="failed"){e.onEvent({type:"failed",path:t,error:a.failure.error});return}if(a.kind!=="source"){e.onEvent({type:"left",path:t,reason:J(a.kind,a.sniffed)});return}let{jobs:g,left:p}=K([a.source],e.answers,e.claimed,e.destination),[v]=p;if(v){e.onEvent({type:"left",path:t,reason:v.reason});return}let u=await w(g,{force:!1,concurrency:1,onEvent:o=>{o.type==="job:phase"&&"phase"in o.progress&&o.progress.phase!=="page"&&o.progress.phase!=="time"&&e.onEvent({type:"phase",path:t,phase:o.progress.phase,job:o.job})}}),[m]=u.results,h=[...u.refusals,...u.failures][0];m?e.onEvent({type:"converted",path:t,result:m}):h&&e.onEvent({type:"failed",path:t,error:h.error})},i=()=>{for(;!c&&r.size<s&&n.length>0;){let t=n.shift(),a=d(t).catch(()=>{}).finally(()=>{r.delete(a),i()});r.add(a)}},l=A(e.dir,e.known,{...e.settleMs===void 0?{}:{settleMs:e.settleMs},...e.pollMs===void 0?{}:{pollMs:e.pollMs},ignore:t=>e.claimed.has(t),onFile:t=>{n.push(t),i()}});return{async stop(){c=!0,l.close(),n.length=0,await Promise.all([...r])}}}export{K as a,G as b,H as c};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{d as l,e as f}from"./chunk-SMBK6BTC.js";import{f as g}from"./chunk-EXLXSKRH.js";import{execFile as S}from"node:child_process";import{mkdir as v,rename as N,rm as O}from"node:fs/promises";import{join as d}from"node:path";import{promisify as k}from"node:util";var F=k(S),j=async(e,r)=>{let{stdout:t}=await F("osascript",["-l","JavaScript","-e",e,...r],{timeout:5e3});return t.trim()},b=[{uti:"public.png",ext:"png"},{uti:"public.jpeg",ext:"jpg"},{uti:"org.webmproject.webp",ext:"webp"},{uti:"public.heic",ext:"heic"},{uti:"public.avif",ext:"avif"},{uti:"com.compuserve.gif",ext:"gif"},{uti:"public.tiff",ext:"tiff"}];function I(e){let r=e.includes("public.file-url");return b.find(t=>e.includes(t.uti)&&!(r&&t.uti==="public.tiff"))?.uti??null}function X(e=process.platform,r=process.env){return e==="darwin"&&!r.SSH_CONNECTION&&!r.SSH_TTY}var T={png:"public.png",jpeg:"public.jpeg",webp:"org.webmproject.webp",heic:"public.heic",avif:"public.avif",gif:"com.compuserve.gif",tiff:"public.tiff"};function $(e){return T[e]??"public.data"}var A=`ObjC.import('AppKit')
|
|
4
|
+
const pb = $.NSPasteboard.generalPasteboard
|
|
5
|
+
JSON.stringify({ types: ObjC.deepUnwrap(pb.types) || [], count: Number(pb.changeCount) })`,E=`function run(argv) {
|
|
6
|
+
ObjC.import('AppKit')
|
|
7
|
+
const pb = $.NSPasteboard.generalPasteboard
|
|
8
|
+
const data = pb.dataForType(argv[0])
|
|
9
|
+
if (data.isNil()) return JSON.stringify({ ok: false })
|
|
10
|
+
const ok = data.writeToFileAtomically(argv[1], true)
|
|
11
|
+
return JSON.stringify({ ok: ok, count: Number(pb.changeCount) })
|
|
12
|
+
}`,J=`function run(argv) {
|
|
13
|
+
ObjC.import('AppKit')
|
|
14
|
+
const pb = $.NSPasteboard.generalPasteboard
|
|
15
|
+
const item = $.NSPasteboardItem.alloc.init
|
|
16
|
+
item.setDataForType($.NSData.dataWithContentsOfFile(argv[0]), argv[1])
|
|
17
|
+
item.setStringForType($.NSURL.fileURLWithPath(argv[0]).absoluteString, 'public.file-url')
|
|
18
|
+
pb.clearContents
|
|
19
|
+
pb.writeObjects($.NSArray.arrayWithObject(item))
|
|
20
|
+
return JSON.stringify({ count: Number(pb.changeCount) })
|
|
21
|
+
}`;function z(e=j){let r=async()=>{try{let{types:t,count:n}=JSON.parse(await e(A,[]));return{changeCount:n,image:I(t),text:t.includes("public.utf8-plain-text")}}catch{return{changeCount:-1,image:null,text:!1}}};return{peek:r,async read(t){let{image:n}=await r(),a=b.find(C=>C.uti===n);if(!a)return null;await v(t,{recursive:!0});let i=d(t,`Copied image.${a.ext}`),s=JSON.parse(await e(E,[a.uti,i]));if(!s.ok||s.count===void 0)return null;if(a.uti!=="public.tiff")return{path:i,changeCount:s.count};let{default:x}=await import("sharp"),c=d(t,"Copied image.png");return await x(i).keepIccProfile().png().toFile(`${c}.part`),await N(`${c}.part`,c),await O(i,{force:!0}),{path:c,changeCount:s.count}},async write(t,n){let{count:a}=JSON.parse(await e(J,[t,$(n)]));return a}}}import{randomBytes as h}from"node:crypto";import{copyFile as R,mkdir as y,readdir as P,readFile as D,rename as _,rm as p,stat as K}from"node:fs/promises";import{tmpdir as U}from"node:os";import{extname as u,join as o}from"node:path";function m(){return o(U(),"forge-clip")}var W=5,w={".png":"png",".jpg":"jpeg",".jpeg":"jpeg",".webp":"webp",".heic":"heic",".avif":"avif",".gif":"gif",".tiff":"tiff"};async function at(e,r=m()){let t=`${Date.now().toString(36)}-${h(3).toString("hex")}`,n=o(r,t),a=await e.read(o(n,"in"));if(!a)return await p(n,{recursive:!0,force:!0}),null;let i=o(n,"out");await y(i,{recursive:!0}),await L(r,a.path);let s=o(n,"in","Copied image");return await _(a.path,s),await B(r,t),{source:s,outDir:i,changeCount:a.changeCount}}async function L(e,r){let t=o(e,"last"),n=`Copied image${u(r)}`,a=o(e,`.last-${h(4).toString("hex")}`);await y(a,{recursive:!0}),await R(r,o(a,n)),await p(t,{recursive:!0,force:!0}),await l(a,t)}async function B(e,r){let t=await P(e,{withFileTypes:!0}).catch(()=>[]),a=(await Promise.all(t.filter(i=>i.isDirectory()&&i.name!=="last"&&!i.name.startsWith(".")).map(async i=>({name:i.name,at:(await K(o(e,i.name)).catch(()=>null))?.mtimeMs??0})))).filter(i=>i.name!==r).sort((i,s)=>s.at-i.at).slice(W-1);await Promise.all(a.map(i=>p(o(e,i.name),{recursive:!0,force:!0})))}async function M(e=m()){let r=o(e,"last"),t=(await P(r).catch(()=>[])).find(n=>w[u(n).toLowerCase()]!==void 0);return t===void 0?null:{path:o(r,t),format:w[u(t).toLowerCase()]}}async function nt(e,r,t,n){let{changeCount:a}=await e.peek();return a!==r.changeCount?"changed":(await e.write(t,n),"placed")}async function ot(e,r=m()){let t=await M(r);return t?(await e.write(t.path,t.format),!0):!1}async function st(e,r){let t=g(o(r,`Copied image${u(e)}`));return await f(t,await D(e)),t}export{X as a,z as b,at as c,nt as d,ot as e,st as f};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as ie,b as ue,c as pe,d as N,e as de,k as fe,l as le,m as me,o as ge,p as he}from"./chunk-I63TO22X.js";import{a as y}from"./chunk-DERIWZAT.js";import{c as I}from"./chunk-YWKMG5WO.js";import{f as ce,i as j}from"./chunk-LNB5D67B.js";import{e as te,f as re,g as oe,h as se,i as ne,j as ae}from"./chunk-EHARO6IS.js";import{a as F,c as X,d as Z,e as C,f as _,k as ee}from"./chunk-QR6QHTC3.js";import{e as Q}from"./chunk-6L6C3GJU.js";import{d as $}from"./chunk-EEQSUBBL.js";import{n as H,p as L}from"./chunk-KAHWYWNT.js";import{a as U,c as Y,d as E,e as K}from"./chunk-EXLXSKRH.js";import{F as M,G as q,J as G,b as P,c as w,d as v,na as V,p as z,r as k,t as D,w as J}from"./chunk-3UEQ2OX6.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{a as m}from"./chunk-MV7H3QQY.js";import{a as R}from"./chunk-M66BUNYO.js";import{readFile as Je}from"node:fs/promises";import{dirname as Fe,resolve as Me}from"node:path";async function ye(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=F(o);if(!s.includes(e.target)){t.push({path:o.path,error:D(o,e.target,s)});continue}let n={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},a=E(n);Y(a,o.path)&&e.target!==o.format&&(a=K({...n,suffix:e.target})),r.push({op:"convert",sources:[o],outputs:[a],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Ce}from"node:path";function je(e,r=new Set){let t={path:Ce(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:F(e).filter(n=>!o||C(n)),actions:ge([e],r).filter(n=>!o||n.id===j.id).map(n=>n.id)};if(e.kind==="image")return{...t,width:e.width,height:e.height,...s};if(e.kind==="media"){let n=e.facts;return{...t,...n?{duration:n.duration}:{},...n?.video?{width:n.video.width,height:n.video.height,fps:n.video.fps}:{},...s}}return{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function be(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-GYIHVSRX.js"),o=await t();return{probes:r.sources.map(s=>je(s,o)),failures:r.failures}}import{dirname as Be}from"node:path";var B=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function we(e,r){let t=P(Be(e),B(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function Ie(e,r){let{pct:t,direction:o}=W(e,r);return o==="same"?"same size":`${t}% ${o}`}function xe(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${we(s[0],r)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let i of t.warnings)a.push("",`\u26A0 ${i.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${P(s[0],B(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${Ie(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function Pe(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${Ie(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${P(n,B(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function ve(e,r={}){let t=e.results.flatMap(u=>u.job.outputs),o=t.map(u=>w(u)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":we(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)a.push("",`\u26A0 ${u.message}`);return a}function O(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...V(o.error,{debug:r.debug}),"");return t}function ke(){let e=new Set(X()),r=new Set(Z()),t=["Formats",""];for(let s of e){let n=R[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function $e(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&t.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&t.push(`${e.fps} fps`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,B(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Re}from"node:readline";import{PassThrough as Oe}from"node:stream";function Se(e){return new Promise(r=>{let t=Re({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function Ee(e){if(e.stdin)return Se(process.stdin);if(!process.stdin.isTTY)return;let r=new Oe,t=Re({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
|
|
4
|
+
`),t.close()}}function T(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function Ne(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw M("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:fe(o)};if(s.mode==="every-n")return{cuts:le(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Te(e,r){let t;return()=>r?(t??=Ee({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Ae(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Q(await Je(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let n;try{n=j.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!v(i))throw i;return{failure:{path:e.path,error:i}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function S(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}if(!r&&t.type==="job:phase"&&t.progress.phase==="time"){let o=t.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of 2 \xB7 ${s}`:s);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function We(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=me.find(a=>a.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let a=he(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,a)}])}let s;try{s=t.plan(r.sources,Ne(e,r.sources))}catch(a){if(!v(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function ze(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of t.sources){if(!N.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!U(e.output)?Me(e.output):void 0,g=e.output===void 0||u!==void 0?Fe(i.path):Fe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:t.roots.get(i.path)})),[d]=N.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:g});d?.op==="convert"&&(u!==void 0&&(d.outputs=[u]),e.dpi!==void 0&&(d.options.dpi=e.dpi),o.push(d))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function De(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-5XI5L4KW.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:c,catalogEntry:p}=await import("./catalog-YSMT3PXT.js"),f=p("boost"),x=f&&c(f)?.version,A=L(e.scale,n.version,x);if(A)return b(t,[{path:"",error:A}])}let a=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?ue:pe,u=[],g=[];for(let c of a.sources){if(!i.appliesTo([c])){g.push({path:c.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let p=ie(c,e.target);if(p){g.push({path:c.path,error:p});continue}u.push(...i.plan([c],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let d=u.length>1;d&&r.onProgress?.({completed:0,total:u.length});let l=await I(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:S(r,d)});return{kind:t,results:l.results,failures:[...a.failures,...g,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function qe(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:ee(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[],i=[];for(let p of s.sources)p.kind==="image"&&e.media===void 0?n.push(p):p.kind==="media"&&!e.trim?a.push(p):p.kind==="image"?i.push({path:p.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ce(a,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),d=[...de(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],l=d.length>1;l&&r.onProgress?.({completed:0,total:d.length});let c=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(r,l)});return{kind:e.kind,results:c.results,failures:[...s.failures,...i,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function Ge(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=f=>f.kind==="document"&&f.format==="pdf",s=C(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(f=>!o(f)):t.sources,i=[],u=[],g=Te(e.passwordStdin??!1,r.interactive??!0);for(let f of n){let x=await Ae(f,e,g,t.roots.get(f.path));"failure"in x?u.push(x.failure):i.push(x.job)}let d=await ye({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),l=[...d.jobs,...i],c=l.length>1;c&&r.onProgress?.({completed:0,total:l.length});let p=await I(l,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,c)});return{kind:"convert",results:p.results,failures:[...t.failures,...u,...d.failures,...p.refusals,...p.unreachable.map(f=>({path:f.job.sources[0].path,error:f.error})),...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ve(e,r={}){try{if(e.kind==="pageop")return await We(e);if(e.kind==="extension-op")return await De(e,r);if(e.kind==="edit")return await qe(e,r);if(e.kind==="preset"){let{runPresetCommand:t}=await import("./preset-command-HORY7KZQ.js");return await t(e)}return e.kind==="compress"?await ze(e,r):await Ge(e,r)}catch(t){if(!v(t))throw t;return b(e.kind,[{path:"",error:t}])}}function He(e,r){let t=T(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(te(m,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?ve(e):e.results.length===1?xe(e):Pe(e);return{exitCode:t,stdout:o,stderr:O(e.failures,{debug:r.debug})}}function Le(e,r){let t=[{path:"",error:e}],o=T(t);return r.json?{exitCode:o,stdout:[JSON.stringify(re(m,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:O(t,{debug:r.debug})}}async function Ue(e,r){let{runConfig:t}=await import("./config-command-TYNYVUMP.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(ne(m,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function Tt(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ue(e,t);if(e.kind==="clip"){let{runClipCommand:s}=await import("./clip-command-LAVVAHHV.js");return await s(e,{...r,json:t,debug:o})}if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-GMBG7BK6.js"),n=await s(m,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:m,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:s}=await import("./entry-UWADO4ND.js"),n=[];return{exitCode:await s(m,i=>n.push(i)),stdout:n,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-73UGWB6L.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(ae(m,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(oe(m,_()))],stderr:[]}:{exitCode:0,stdout:ke(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await be(e.inputs),a=T(n);return t?{exitCode:a,stdout:[JSON.stringify(se(m,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((i,u)=>[...u>0?[""]:[],...$e(i)]),stderr:O(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-AJW2JR3S.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}if(e.kind==="transcribe"){let{runTranscribeCommand:s}=await import("./transcribe-command-YUSBCQEQ.js"),n=[],a=[];return{exitCode:await s(e,{out:u=>n.push(u),err:u=>a.push(u)}),stdout:n,stderr:a}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw M("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");return He(await Ve(e,r),{json:t,debug:o})}catch(s){if(!v(s))throw s;return Le(s,{json:t,debug:o})}}export{be as a,Ie as b,T as c,Ve as d,He as e,Tt as f};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{h as k}from"./chunk-6L6C3GJU.js";import{c as C}from"./chunk-EXLXSKRH.js";import{$ as I,A as T,aa as B,d as E,ga as v,p as P,s as x,x as w,y as M,z as A}from"./chunk-3UEQ2OX6.js";function N(e=1,t=100){let o=Math.max(1,t-e+1);return 1+Math.max(0,Math.ceil(Math.log2(o)))}async function U(e){let t=e.min??1,o=e.max??100,f=N(t,o),i=0,n=async s=>(i+=1,e.onAttempt?.(i,f),e.encode(s)),l=()=>e.signal?.aborted===!0,u=await n(o);if(l())return{quality:o,bytes:u,missed:!1,cancelled:!0};if(u<=e.targetBytes)return{quality:o,bytes:u,missed:!1};let a=t,y=o,b;for(;a<=y;){let s=Math.floor((a+y)/2),c=await n(s);if(l())return{quality:s,bytes:c,missed:!1,cancelled:!0};c<=e.targetBytes?(b={quality:s,bytes:c,missed:!1},a=s+1):y=s-1}if(b)return b;let h=await e.encode(t);return{quality:t,bytes:h,missed:!0}}import{cpus as _}from"node:os";function D(){return Math.max(1,Math.min(_().length,4))}function J(e){let t=e!==void 0&&Number.isFinite(e)?e:void 0;return Math.max(1,t??D())}async function S(e,t,o){let f=0,i=async()=>{for(;f<e.length;){let l=f++;await o(e[l],l)}},n=Math.min(J(t),e.length);await Promise.all(Array.from({length:n},i))}async function q(e,t){let o=t.onEvent??(()=>{}),f=t.engineFor??k,i=J(t.concurrency),n=e.length,l=[],u=[],a=0;await S(e,i,async(s,c)=>{o({type:"job:start",job:s,index:c,total:n});let F=f(s);if(!F){a++;let m=s.sources[0].path,r={path:m,error:v(m,new Error(`no engine runs ${s.op}`))};u[c]=r,o({type:"job:error",job:s,failure:r,completed:a,total:n});return}try{let m=await F.run(s,r=>o({type:"job:phase",job:s,progress:r}),t.signal);l[c]=m,a++,o({type:"job:done",job:s,result:m,completed:a,total:n})}catch(m){a++;let r=s.sources[0].path,d=E(m)?m:v(r,m),p={path:r,error:d};u[c]=p,o({type:"job:error",job:s,failure:p,completed:a,total:n})}});let y=l.filter(s=>s!==void 0),b=u.filter(s=>s!==void 0),h={results:y,failures:b,inputBytes:y.reduce((s,c)=>s+c.job.sources[0].bytes,0),outputBytes:y.reduce((s,c)=>s+c.outputBytes,0)};return o({type:"batch:done",summary:h}),h}import{existsSync as L}from"node:fs";import{resolve as R}from"node:path";function W(e){let t=e.sources[0]?.path??e.outputs[0]??"",o=new Set;for(let f of e.outputs){let i=R(f);if(o.has(i))return{output:f,error:A(t,f)};o.add(i)}}function z(e,t,o){let f=W(e);if(f)return f;let i=e.sources[0]?.path??e.outputs[0]??"";for(let n of e.outputs){let l=R(n);if(e.sources.some(a=>C(a.path,l))&&!o)return{output:n,error:T(n,e.op)};let u=t.get(l);if(u){let a=u.sources[0]?.path??u.outputs[0]??"";return{output:n,error:M([a,i],n)}}if(L(l)&&!o)return{output:n,error:w(n,e.op)}}}function O(e,t){let o=[],f=[],i=new Map;for(let n of e){let l=z(n,i,t.force);if(l){let u=n.sources[0]?.path??l.output;f.push({path:u,error:l.error});continue}for(let u of n.outputs)i.set(R(u),n);o.push(n)}return{jobs:o,failures:f}}async function X(e,t,o,f,i){let n=e.sources[0].path,l=r=>({kind:"failed",failure:{path:n,error:E(r)?r:v(n,r)}}),u=o(e);if(u?.sizeTo){let r=e.sources[0],d=e.options.compress!==void 0;if(d&&r.bytes<=t)return{kind:"failed",failure:{path:n,error:B(n,r.bytes,t)}};let p=t,g=u.sizeTo(e,p);return g&&d&&g.floor>=r.bytes?{kind:"failed",failure:{path:n,error:I(n,r.bytes,g.floor,!0)}}:g?{kind:"unreachable",entry:{job:e,smallest:g.floor,settings:{quality:1,media:{...e.options.media,targetBytes:g.floor}},error:x(r,t,g.floor)}}:(e.options={...e.options,media:{...e.options.media,targetBytes:p}},{kind:"ready"})}let a;try{a=await o(e)?.measurer?.(e)}catch(r){return l(r)}if(!a||a.ladder.length===0)return{kind:"refused",failure:{path:n,error:P(e.sources[0],e.target)}};let y=a,b=e.sources[0],h=e.options.compress!==void 0&&b.bytes<=t,s=h?b.bytes-1:t;if(i?.aborted)return{kind:"cancelled"};let c=Number.POSITIVE_INFINITY,F;try{for(let r of y.ladder){let d=await U({encode:p=>y.measure({...e.options,...r,quality:p}),targetBytes:s,onAttempt:(p,g)=>f({type:"search:attempt",job:e,attempt:p,of:g,rung:r}),...i===void 0?{}:{signal:i}});if(d.cancelled)return{kind:"cancelled"};if(d.bytes<c&&(c=d.bytes,F={...r,quality:d.quality}),!d.missed)return e.options={...e.options,...r,quality:d.quality},{kind:"ready"}}}catch(r){return l(r)}return h?{kind:"failed",failure:{path:n,error:I(n,b.bytes,c,!0)}}:{kind:"unreachable",entry:{job:e,smallest:c,settings:F??{quality:1},error:x(e.sources[0],t,c)}}}async function ue(e,t){let o=t.onEvent??(()=>{}),f=t.engineFor??k,i=t.targetBytes,n=O(e,{force:t.force}),l=i===void 0?0:n.jobs.filter(r=>r.op==="convert").length,u=[],a=0;await S(n.jobs,J(t.concurrency),async(r,d)=>{if(i===void 0||r.op!=="convert"){u[d]={kind:"ready"};return}if(t.signal?.aborted){u[d]={kind:"cancelled"};return}let p=await X(r,i,f,o,t.signal);u[d]=p,p.kind!=="cancelled"&&(a+=1,o({type:"search:settled",job:r,completed:a,total:l}))});let y=[...n.failures],b=[],h=[],s=[],c=!1;for(let[r,d]of n.jobs.entries()){let p=u[r]??{kind:"ready"};p.kind==="ready"?s.push(d):p.kind==="refused"?y.push(p.failure):p.kind==="failed"?h.push(p.failure):p.kind==="unreachable"?b.push(p.entry):c=!0}if(c)return{results:[],refusals:y,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let F=new Set,m=await q(s,{...t.concurrency===void 0?{}:{concurrency:t.concurrency},...t.engineFor===void 0?{}:{engineFor:t.engineFor},...t.signal===void 0?{}:{signal:t.signal},onEvent:r=>{r.type==="job:error"&&!t.signal?.aborted&&F.add(r.failure),o(r)}});if(t.signal?.aborted&&m.failures.length>0){let r=m.failures.filter(d=>F.has(d));return{...m,refusals:y,unreachable:b,failures:[...h,...r],cancelled:!0}}return{results:m.results,refusals:y,unreachable:b,failures:[...h,...m.failures],inputBytes:m.inputBytes,outputBytes:m.outputBytes}}export{J as a,O as b,ue as c};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{F as n}from"./chunk-
|
|
3
|
+
import{F as n}from"./chunk-3UEQ2OX6.js";import{d as i,f as s,g as o}from"./chunk-AAXBN572.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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d}from"./chunk-P6NXFZZP.js";import"./chunk-Y2A3HTKQ.js";import"./chunk-TMQDQLY7.js";import"./chunk-I63TO22X.js";import"./chunk-DERIWZAT.js";import"./chunk-YWKMG5WO.js";import"./chunk-LNB5D67B.js";import"./chunk-BZXDNDPG.js";import"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-MV7H3QQY.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{b as clipLines,a as runClip,d as runClipCommand,c as runUndo};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{h as y,i as O,m as C}from"./chunk-FH3R2YYD.js";import{i as $,k as u,l as S}from"./chunk-IWFVEMDN.js";import{c as k,d as w,f as I}from"./chunk-PBIS2ONZ.js";import{a as h,b as g}from"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import{b as m,c as d,h as f,i as p}from"./chunk-QVACE4IE.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import{c as b,n as x}from"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import{a as l}from"./chunk-MV7H3QQY.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";import{resolve as R}from"node:path";var P=({r:t,g:n,b:o},s)=>s?`\x1B[38;2;${t};${n};${o}m\u2588\u2588\x1B[39m `:"";function N(t,n){let o=d(n),s,e=Number.POSITIVE_INFINITY;for(let r of t){let a=(r.centre.L-o.L)**2+(r.centre.a-o.a)**2+(r.centre.b-o.b)**2;a<e&&(e=a,s=r)}return s}async function D(t,n){let{pixels:o}=await C(t.input),s=k(o);if(s.length===0)throw x(t.input);let e=t.inside?N(s,t.inside):void 0,r=e?w(o,e):s;if(t.svg)return{exitCode:0,stdout:[y(b(t.input),r,"light",e?.hex)],stderr:[]};if(n.json){let i=h(l,{source:R(t.input),...e?{inside:e.hex}:{},colours:r.map(c=>({hex:c.hex,rgb:f(c.rgb),oklch:p(c.rgb),share:c.share}))});return{exitCode:0,stdout:[JSON.stringify(i)],stderr:[]}}let a=I(r.map(i=>i.share));return{exitCode:0,stdout:r.map((i,c)=>`${P(i.rgb,n.colour)}${i.hex} ${String(a[c]).padStart(3)}%`),stderr:[]}}async function H(t,n){let o=$(t.colour);if(t.svg)return{exitCode:0,stdout:[O(t.colour,o)],stderr:[]};let s=o.map(e=>({...e,...S(e.rgb)}));if(n.json){let e=g(l,{reference:m(t.colour),steps:s.map(r=>({step:r.step,hex:r.hex,oklch:p(r.rgb),white:r.white,black:r.black}))});return{exitCode:0,stdout:[JSON.stringify(e)],stderr:[]}}return{exitCode:0,stdout:s.map(e=>`${String(e.step).padStart(4)} ${P(e.rgb,n.colour)}${e.hex} white ${e.white.toFixed(1)} ${u(e.white)} \xB7 black ${e.black.toFixed(1)} ${u(e.black)}`),stderr:[]}}export{D as runPalette,H as runScale};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{F as t}from"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";var a=["open","convert","compress","sharpen","open-pdf"];function c(n){let[e,o,...r]=n;if(e==="install"||e==="remove")return{kind:e};if(e==="run"||e==="open"){if(!a.includes(o))throw t(`No menu action called "${o??""}".`);return{kind:e,action:o,paths:r}}throw t(`No menu command called "${e??""}".`)}function s(n,e){switch(n){case"convert":return{paths:e,mode:"convert",advance:!0};case"compress":return{paths:e,mode:"compress",advance:!0};case"open-pdf":return{paths:e,mode:"pdf",advance:!1};default:return{paths:[],mode:"convert",advance:!1}}}export{s as openedFor,c as parseMenuArgs};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b}from"./chunk-YYB3TTGT.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{a as CONFIG_KEYS,b as runConfig};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as N,b as $,c as k,d as h,f,g as p,h as _}from"./chunk-6FUVEO3A.js";import{c as E}from"./chunk-QXTXBMTM.js";import{a as D,b as T,c as A,d as F,e as R}from"./chunk-JFJ3ZJQL.js";import{c as x}from"./chunk-EX7KZBI6.js";import{f as P}from"./chunk-EXLXSKRH.js";import{d as b}from"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import{a as w}from"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";import{spawn as X}from"node:child_process";import{homedir as ge}from"node:os";import{join as M}from"node:path";import{appendFileSync as V,mkdirSync as O,readFileSync as K,renameSync as Y,rmSync as y,statSync as G}from"node:fs";import{join as C}from"node:path";var Z={quiet:500,cap:3e3,poll:50},ee=15e3,I=e=>new Promise(t=>setTimeout(t,e));async function j(e,t,n,r=Z){O(e,{recursive:!0});let i=C(e,`${t}.spool`),o=C(e,`${t}.lock`),s=m=>{try{return K(m,"utf8").split(`
|
|
4
|
+
`).filter(Boolean)}catch{return[]}},u=()=>{try{return G(i).size}catch{return 0}};for(V(i,`${n}
|
|
5
|
+
`);;){try{O(o)}catch{try{Date.now()-G(o).mtimeMs>ee&&y(o,{recursive:!0,force:!0})}catch{}if(await I(r.poll),!s(i).includes(n))return null;continue}try{let m=Date.now(),c=u(),l=Date.now();for(;Date.now()-l<r.quiet&&Date.now()-m<r.cap;){await I(r.poll);let S=u();S!==c&&(c=S,l=Date.now())}let a=`${i}.${process.pid}.${Date.now()}`;try{Y(i,a)}catch{return[n]}let g=[...new Set(s(a))];return y(a,{force:!0}),g}finally{y(o,{recursive:!0,force:!0})}}}import{realpathSync as ne}from"node:fs";import{delimiter as te,join as re}from"node:path";function q(e,t,n=process.platform){let r=s=>{try{return ne(s)}catch{return}},i=r(e)??e,o=n==="win32"?"node.exe":"node";for(let s of(t??"").split(te)){if(s==="")continue;let u=re(s,o);if(u!==e&&r(u)===i)return u}return e}import{basename as v,dirname as ie,extname as oe,join as se}from"node:path";function ae(e,t,n){if(n==="win32")return e==="wt"?["wt.exe",["-w","new",...t]]:["conhost.exe",t];if(e==="ghostty")return["/usr/bin/open",["-na","Ghostty","--args","-e",...t]];let r=`exec ${t.map(N).join(" ")}`;return["/usr/bin/osascript",[...["on run argv",...e==="iTerm.app"?['tell application "iTerm"',"create window with default profile","tell current session of current window to write text (item 1 of argv)","activate","end tell"]:['if application "Terminal" is running then','tell application "Terminal" to do script (item 1 of argv)',"else",'tell application "Terminal" to do script (item 1 of argv) in window 1',"end if",'tell application "Terminal" to activate'],"end run"].flatMap(o=>["-e",o]),r]]}function H(e){let t=v(e,oe(e));return P(se(ie(e),`${t}-sharp.png`))}function ue(e){let t=e.flatMap(o=>"output"in o?[o.output]:[]),n=e.flatMap(o=>"error"in o?[o]:[]),[r]=n;if(r===void 0)return{title:t.length===1?v(t[0]):`${t.length} files`,body:"Sharpened"};let i=r.input?v(r.input):"file";return e.length===1?{title:`${i} not sharpened`,body:r.error}:{title:`${t.length} of ${e.length} files sharpened`,body:`${i}: ${r.error}`}}async function U(e,t,n){if(e==="sharpen"){let s=[];for(let a of t){let g=await n.sharpen(a);s.push("error"in g?{input:a,...g}:g)}let{title:u,body:m}=ue(s);await n.notify(u,m);let l=s.flatMap(a=>"output"in a?[a.output]:[]).at(-1);l!==void 0&&await n.reveal(l);return}let r=e==="open"?[]:t,[i,o]=ae(n.terminal,[...n.self,"menu","open",e,...r],n.platform);await n.launch(i,o)}import{mkdirSync as le,readFileSync as ce,writeFileSync as me}from"node:fs";import{join as pe}from"node:path";async function B(e,t){if(!t.global||e.platform!=="darwin"&&e.platform!=="win32")return;let n=h(e);if(t.enabled===!1){n!==void 0&&await p(e);return}if(!(n!==void 0&&k(n,e))&&(await f(e),n===void 0))return e.platform==="darwin"?"Added Forge to Finder\u2019s Quick Actions":"Added Forge to the right-click menu"}async function J(e){let t=h(e);if(t===void 0)return;let{xdgConfigHome:n,...r}=e;await f({...r,...t})}var L=e=>pe(e.menuDir,"terminal"),fe=new Set(["Apple_Terminal","iTerm.app","ghostty"]);function z(e,t){let n=e.platform==="win32"?t.WT_SESSION?"wt":"console":fe.has(t.TERM_PROGRAM??"")?t.TERM_PROGRAM:void 0;if(n)try{le(e.menuDir,{recursive:!0}),me(L(e),n)}catch{}}function Q(e){try{return ce(L(e),"utf8").trim()||void 0}catch{return}}import{rmSync as de}from"node:fs";async function W(e,t){await p(e),t.out("\u2713 Removed Forge from the right-click menu");let{code:n,output:r}=await t.npm(["uninstall","--global","forge-terminal"]);return n!==0?(t.out(`\u2715 npm could not uninstall forge-terminal: ${R(r)}`),1):(t.out("\u2713 Uninstalled forge-terminal"),de(t.forgeDir,{recursive:!0,force:!0}),t.out("\u2713 Deleted Forge\u2019s settings"),0)}var we=()=>M(w(),"forge","menu");async function d(e){return{platform:process.platform,home:ge(),menuDir:we(),node:q(process.execPath,process.env.PATH),execArgv:process.execArgv,forge:T(process.argv[1])??"",...process.env.XDG_CONFIG_HOME?{xdgConfigHome:process.env.XDG_CONFIG_HOME}:{},version:e,sharpen:await x("boost")!==void 0,run:_}}async function Ye(e){if(process.env.FORGE_NO_MENU)return;let t=await d(e);z(t,process.env);let{loadPreferences:n}=await import("./preferences-4VETUGMN.js"),{prefs:r}=await n();return B(t,{global:D(t.forge,t.platform),enabled:r.rightClickMenu!==!1})}async function Ze(){let{isInstalled:e}=await import("./install-2A5BGKQU.js");return e(await d(""))}async function en(e){let{VERSION:t}=await import("./theme-USWAYNEH.js"),{savePreferences:n}=await import("./preferences-4VETUGMN.js"),r=await d(t);e?await f(r):await p(r),await n({rightClickMenu:e})}async function nn(){if(!process.env.FORGE_NO_MENU)try{await J(await d(""))}catch{}}async function he(e){let{parseArgs:t}=await import("./args-ZMSJ3NBZ.js"),{runIntent:n}=await import("./execute-MUM63CAA.js"),r=t([e,"--sharpen","--output",H(e)]),i=await n(r),o=i.results[0]?.job.outputs[0];if(o!==void 0)return{output:o};let s=i.failures[0]?.error;return{error:b(s)?s.detail:"It could not be sharpened."}}var ye=(e,t)=>new Promise(n=>{let r=X(e,t,{detached:!0,stdio:"ignore"});r.on("error",()=>n()),r.unref(),n()});async function tn(e,t){let n=await d(t);if(e.kind==="install")return await f(n),0;if(e.kind==="remove")return await p(n),0;if(e.kind!=="run")return 2;let r=e.paths;if(n.platform==="win32"&&r.length===1){let i=await j(M(n.menuDir,"spool"),e.action,r[0]);if(i===null)return 0;r=i}return await U(e.action,r,{platform:n.platform,self:[n.node,...n.execArgv,n.forge],terminal:Q(n),launch:ye,sharpen:he,notify:(i,o)=>$(i,o,n.platform),reveal:async i=>{await E(i,n.platform)}}),0}async function rn(e,t){let n=await d(e),r=i=>new Promise(o=>{let s=n.platform==="win32"?F(n.node):void 0,[u,m]=s!==void 0?[n.node,[s,...i]]:[A(n.node),i],c="",l=X(u,m,{stdio:["ignore","pipe","pipe"]});l.stdout.setEncoding("utf8").on("data",a=>{c+=a}),l.stderr.setEncoding("utf8").on("data",a=>{c+=a}),l.on("error",a=>o({code:null,output:`${c}
|
|
6
|
+
${a.message}`})),l.on("close",a=>o({code:a,output:c}))});return W(n,{forgeDir:M(w(),"forge"),npm:r,out:t})}export{Ye as menuAtStart,Ze as menuIsOn,d as realMenuEnv,nn as resyncMenu,tn as runMenuCommand,rn as runUninstall,en as switchMenu};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as a,d as b,e as c,f as d}from"./chunk-Y2A3HTKQ.js";import"./chunk-I63TO22X.js";import"./chunk-DERIWZAT.js";import"./chunk-YWKMG5WO.js";import"./chunk-LNB5D67B.js";import"./chunk-BZXDNDPG.js";import"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-MV7H3QQY.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{d as execute,a as exitCodeFor,c as renderRun,b as runIntent};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{jb as a,kb as b,lb as c,mb as d,nb as e}from"./chunk-BCNMRALN.js";import"./chunk-IWFVEMDN.js";import"./chunk-PBIS2ONZ.js";import"./chunk-BZXDNDPG.js";import"./chunk-IBPGC4N2.js";import"./chunk-QVACE4IE.js";import"./chunk-EEQSUBBL.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-MV7H3QQY.js";import"./chunk-M66BUNYO.js";import"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";export{e as ExtensionsFlow,c as byteCount,b as extensionCredits,d as extensionsChip,a as realManager};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as c}from"./chunk-J7FLFHQJ.js";import{c as d}from"./chunk-
|
|
3
|
+
import{a as c}from"./chunk-J7FLFHQJ.js";import{c as d}from"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";function f(e){let t=Object.entries(e.assets).find(([n])=>n.startsWith(`${process.platform}-`));return d(e)?.version??t?.[1]?.version??""}function y(e){return{id:e.entry.id,title:e.entry.title,summary:e.entry.summary,version:f(e.entry),licence:e.entry.licence,installed:e.installed??null,updateAvailable:e.updateAvailable,supported:e.supported,...e.reason!==void 0?{reason:e.reason}:{},...e.downloadBytes!==void 0?{downloadBytes:e.downloadBytes}:{}}}function x(e){return e.supported?e.installed===void 0?`not installed${e.downloadBytes?`, ${c(e.downloadBytes)} download`:""}`:e.updateAvailable?`installed ${e.installed}, update to ${d(e.entry)?.version} available`:`installed ${e.installed}`:`not available: ${e.reason??"unsupported here"}`}function E(e){let t=Math.max(...e.map(n=>n.entry.id.length));return e.flatMap((n,a)=>[...a>0?[""]:[],`${n.entry.id.padEnd(t)} ${n.entry.summary}`,`${" ".repeat(t)} ${x(n)}`,`${" ".repeat(t)} ${n.entry.licence}`])}async function g(e,t={}){let{installExtension:n,listExtensions:a,removeExtension:p}=await import("./manager-743RM57Z.js"),i,s;if(e.action==="add"&&e.id!==void 0){let o=(await a()).find(m=>m.entry.id===e.id),l=o?.installed!==void 0&&!o.updateAvailable,u=await n(e.id,{onProgress:t.onDownload});i={id:e.id,action:l?"unchanged":"added"},s=l?`${e.id} ${u.version} is already installed`:`Installed ${e.id} ${u.version}`}else if(e.action==="remove"&&e.id!==void 0){let o=await p(e.id);i={id:e.id,action:o?"removed":"unchanged"},s=o?`Removed ${e.id}`:`${e.id} was not installed`}let r=await a();return{stdout:s===void 0?E(r):[s],data:{extensions:r.map(y),...i?{changed:i}:{}}}}export{g as runExtensions,y as toExtensionJson};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-LDKF7KIZ.js";import"./chunk-TMUK2DD3.js";export{a as ffmpegCandidates,c as findFfmpeg,d as forceFfmpegForTests,h as frameAt,f as keyframeAtOrBefore,e as probeMedia,b as readNames,i as readProgress,j as runFfmpeg,g as soundLevels};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{G as a,H as b,I as c,J as d,K as e,L as f,M as g,N as h}from"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{c as decodeToPng,a as encode,d as encodeToBuffer,g as guessCrop,h as imageEngine,f as loadCropView,e as measureImage,b as writeAtomic};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f}from"./chunk-6FUVEO3A.js";import"./chunk-TMUK2DD3.js";export{d as installMenu,c as isInstalled,b as readState,e as removeMenu,f as runProgram,a as stateMatches};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f}from"./chunk-JFJ3ZJQL.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{f as installUpdate,a as installedGlobally,e as lastWords,c as npmBeside,d as npmCliBeside,b as runningScript};
|