forge-terminal 0.5.5 → 0.5.7
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 +28 -10
- package/dist/chunks/{about-credits-VRRE6342.js → about-credits-4DHA4HMT.js} +1 -1
- package/dist/chunks/args-5CQKOHYO.js +3 -0
- package/dist/chunks/{boot-MX7UP2M2.js → boot-XX2TLD3Q.js} +1 -1
- package/dist/chunks/{chunk-7I2OSTBX.js → chunk-4KGC5ZBZ.js} +1 -1
- package/dist/chunks/{chunk-J6AZTW62.js → chunk-4MJEEEFA.js} +1 -1
- package/dist/chunks/{chunk-YK26E3OX.js → chunk-4RNVZQRC.js} +1 -1
- package/dist/chunks/{chunk-HYMPLIHW.js → chunk-4YK4XWYS.js} +1 -1
- package/dist/chunks/{chunk-UGATQHEE.js → chunk-6FXF6ALB.js} +1 -1
- package/dist/chunks/{chunk-D4R7UACU.js → chunk-6HQKTDGG.js} +1 -1
- package/dist/chunks/{chunk-TRJXZLR6.js → chunk-6RCS3KBP.js} +1 -1
- package/dist/chunks/{chunk-OUXPGAQL.js → chunk-7MC3LDNP.js} +1 -1
- package/dist/chunks/chunk-7XFLG32B.js +3 -0
- package/dist/chunks/{chunk-R7BEV6PR.js → chunk-AET63NOB.js} +1 -1
- package/dist/chunks/{chunk-HACM3MAD.js → chunk-FAUL5L2W.js} +1 -1
- package/dist/chunks/{chunk-7IWX5VSI.js → chunk-GBA5DFEO.js} +1 -1
- package/dist/chunks/chunk-GYERZAZU.js +4 -0
- package/dist/chunks/{chunk-HWCXNKIN.js → chunk-HTA25PO2.js} +1 -1
- package/dist/chunks/{chunk-BROTSQXG.js → chunk-ILQDMVJR.js} +1 -1
- package/dist/chunks/{chunk-MMLROWBQ.js → chunk-JMIKUWLY.js} +2 -2
- package/dist/chunks/{chunk-KDBKDURW.js → chunk-L57UZTYE.js} +2 -2
- package/dist/chunks/{chunk-BONMSCKD.js → chunk-MPSLPE4C.js} +1 -1
- package/dist/chunks/chunk-N32JL4UI.js +3 -0
- package/dist/chunks/{chunk-Q7ERPAG3.js → chunk-NMECUMJD.js} +1 -1
- package/dist/chunks/{chunk-ZBETH6BR.js → chunk-NRMLO5TP.js} +33 -24
- package/dist/chunks/{chunk-BU4YYGUJ.js → chunk-OXDRJO4V.js} +1 -1
- package/dist/chunks/{chunk-HVMQTKP6.js → chunk-P6JX5ZQT.js} +1 -1
- package/dist/chunks/chunk-POM7FXIV.js +3 -0
- package/dist/chunks/chunk-PUGNBNSV.js +3 -0
- package/dist/chunks/chunk-RM3XA72H.js +3 -0
- package/dist/chunks/{chunk-MES4FVLR.js → chunk-RRVD63NF.js} +1 -1
- package/dist/chunks/chunk-SM735FG7.js +81 -0
- package/dist/chunks/{chunk-JJV2YXZQ.js → chunk-SUB2JM7G.js} +1 -1
- package/dist/chunks/chunk-TFGK7IRZ.js +19 -0
- package/dist/chunks/{chunk-OGYSMKRM.js → chunk-TLHUFIXD.js} +1 -1
- package/dist/chunks/{chunk-SZCSV3PX.js → chunk-U3D3EU33.js} +1 -1
- package/dist/chunks/{chunk-L5JBHB4G.js → chunk-UGYBXR4V.js} +1 -1
- package/dist/chunks/{chunk-RLOJSZ6W.js → chunk-V6GWPR2A.js} +1 -1
- package/dist/chunks/{chunk-BI2E72HM.js → chunk-VDQMK2B2.js} +1 -1
- package/dist/chunks/{chunk-HGJXGAGJ.js → chunk-W53XNVNH.js} +1 -1
- package/dist/chunks/{chunk-7KYO62XK.js → chunk-WBW6G4N6.js} +1 -1
- package/dist/chunks/{chunk-2ZZXIDYX.js → chunk-WMK3IKW6.js} +1 -1
- package/dist/chunks/{chunk-WCOFUMZU.js → chunk-X6PZIFFX.js} +1 -1
- package/dist/chunks/chunk-YJ6XLDRA.js +3 -0
- package/dist/chunks/chunk-ZBMJTIYR.js +3 -0
- package/dist/chunks/clip-command-3CMQ6A5D.js +3 -0
- package/dist/chunks/{clipboard-3VFHDKYE.js → clipboard-IZJTBTSW.js} +1 -1
- package/dist/chunks/colour-VBHJAKAX.js +3 -0
- package/dist/chunks/{command-BKAPI4A5.js → command-GAGAD65W.js} +1 -1
- package/dist/chunks/{config-command-6GXRV627.js → config-command-CKPJXJEE.js} +1 -1
- package/dist/chunks/{continue-editing-4W3XWWCE.js → continue-editing-M6WESEVB.js} +1 -1
- package/dist/chunks/{decoded-SMEHAVCH.js → decoded-XWKU23RG.js} +1 -1
- package/dist/chunks/{entry-7GW4RIK2.js → entry-SOHEQPXT.js} +2 -2
- package/dist/chunks/execute-KTLXJTU2.js +3 -0
- package/dist/chunks/extensions-YF2KGD66.js +3 -0
- package/dist/chunks/{extensions-command-VXZL55KR.js → extensions-command-VT4M2JQW.js} +1 -1
- package/dist/chunks/{ffmpeg-Z7JQT53Y.js → ffmpeg-Q2WJH2OP.js} +1 -1
- package/dist/chunks/{image-FYCF2AVH.js → image-R5C3AWHT.js} +1 -1
- package/dist/chunks/{install-5YXQ6YV3.js → install-KGFOAQCU.js} +1 -1
- package/dist/chunks/{install-C6XNONFF.js → install-MFYGS5TG.js} +1 -1
- package/dist/chunks/{launch-U63VZQXC.js → launch-SOQTCV2D.js} +5 -5
- package/dist/chunks/{lock-AFVXUDOM.js → lock-BG3CLOHA.js} +1 -1
- package/dist/chunks/manager-HBAXHJL4.js +4 -0
- package/dist/chunks/{needed-X5D4E5X5.js → needed-GMZEKBH4.js} +1 -1
- package/dist/chunks/{own-5JN35AUV.js → own-IICGHC4K.js} +1 -1
- package/dist/chunks/{pdfium-GKF4ES7K.js → pdfium-77L526HZ.js} +1 -1
- package/dist/chunks/{preset-command-H6G22SZD.js → preset-command-4OVFEH7Y.js} +1 -1
- package/dist/chunks/{registry-LLAHKI4G.js → registry-TO6HJQJ4.js} +1 -1
- package/dist/chunks/{run-WSETTQXP.js → run-GUFPETHF.js} +1 -1
- package/dist/chunks/{server-CIGFNW7X.js → server-6275TY3O.js} +19 -19
- package/dist/chunks/{theme-HAB66OAL.js → theme-ISNQEBTS.js} +1 -1
- package/dist/chunks/{transcribe-FVCOCTGA.js → transcribe-QC2E7ETQ.js} +1 -1
- package/dist/chunks/{transcribe-command-XCBGAQMI.js → transcribe-command-GAKYFBWQ.js} +1 -1
- package/dist/chunks/{update-command-DJLYU6AB.js → update-command-DWEBUFT5.js} +1 -1
- package/dist/chunks/{update-note-47IPWQKY.js → update-note-T4LVCD25.js} +1 -1
- package/dist/chunks/{watch-command-VL6LOERU.js → watch-command-EYEZKROF.js} +1 -1
- package/dist/index.js +6 -6
- package/package.json +5 -5
- package/dist/chunks/args-5BPKCNTL.js +0 -3
- package/dist/chunks/chunk-2NSUAERD.js +0 -3
- package/dist/chunks/chunk-3YWAVKDZ.js +0 -19
- package/dist/chunks/chunk-45BFQHJB.js +0 -80
- package/dist/chunks/chunk-57M4J2BR.js +0 -3
- package/dist/chunks/chunk-CVNYUROW.js +0 -3
- package/dist/chunks/chunk-HFQOGB4T.js +0 -4
- package/dist/chunks/chunk-PBIS2ONZ.js +0 -3
- package/dist/chunks/chunk-QVACE4IE.js +0 -3
- package/dist/chunks/chunk-U5TEGDGH.js +0 -3
- package/dist/chunks/chunk-VTA6Z45X.js +0 -3
- package/dist/chunks/clip-command-WJ5P4DTN.js +0 -3
- package/dist/chunks/colour-5YBDFXXX.js +0 -3
- package/dist/chunks/execute-LBGFY5TG.js +0 -3
- package/dist/chunks/extensions-HTBACHMC.js +0 -3
- package/dist/chunks/manager-QUTR3RYR.js +0 -4
|
@@ -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 b,c as G}from"./chunk-Q6KQWJ4J.js";import{d as W,f as y,g as K}from"./chunk-D4R7UACU.js";import{a as Q,b as X,e as w}from"./chunk-SZCSV3PX.js";import{a as H,b as P}from"./chunk-MES4FVLR.js";import{a as h,d as R}from"./chunk-N6RCLJE6.js";import{i as F,j as U,k as g}from"./chunk-OGYSMKRM.js";import{d as I,l as z}from"./chunk-J6AZTW62.js";import{b as B,c as J,d as L,e as u,i as _,m as O}from"./chunk-RLOJSZ6W.js";import{E as k,s as N}from"./chunk-CVNYUROW.js";import{a as s,b as D,c as $}from"./chunk-H3DIRJFE.js";var M=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function Gt(t,e){let n=Q(t);return n.includes(e)?void 0:N(t,e,n)}function V(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var Y=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:s.png.hint}]}),dt=t=>t===1?"sharp":`${t}x`,ut=t=>t===1||t===3||t===4?t:2,Ht={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7, 3\xD7 or 4\xD7",requires:"boost",appliesTo:t=>M(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"3",label:"3\xD7",hint:"three times the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},Y()],plan(t,e){let n=M(t);if(!n)return[];let o=V(e),i=ut(Number(e.scale??2));return n.map(r=>({op:"boost",sources:[r],outputs:[u({sourcePath:r.path,target:o.target,suffix:dt(i),...o.output===void 0?{}:{output:o.output},...o.roots?.get(r.path)===void 0?{}:{sourceRoot:o.roots.get(r.path)}})],scale:i,target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}},Wt={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>M(t)!==void 0,unavailable:()=>"images only",options:()=>[Y()],plan(t,e){let n=M(t);if(!n)return[];let o=V(e);return n.map(i=>({op:"remove-background",sources:[i],outputs:[u({sourcePath:i.path,target:o.target,suffix:"cutout",...o.output===void 0?{}:{output:o.output},...o.roots?.get(i.path)===void 0?{}:{sourceRoot:o.roots.get(i.path)}})],target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}};var ft=[{degrees:90,label:"90\xB0 right",suffix:"rotated-right"},{degrees:180,label:"180\xB0",suffix:"rotated-180"},{degrees:270,label:"90\xB0 left",suffix:"rotated-left"}],S=t=>t===90||t===180||t===270,Vt=(t,e)=>e===180?{...t}:{width:t.height,height:t.width},T=t=>ft.find(e=>e.degrees===t).suffix;import{dirname as ct,join as Z}from"node:path";var q="Same location",v="New subfolder";function mt(t,e,n){return t===e?q:t===h("Desktop")?"Desktop":t===h("Downloads")?"Downloads":e!==void 0&&n!==void 0&&t===Z(e,n)?v:b(t)||t}function A(t,e,n={}){return lt(ct(t.path),e,n)}function lt(t,e,{subfolder:n}={}){let o=R(e.defaultOutput),i=e.lastOutput?R(e.lastOutput):void 0,r=f=>({label:mt(f,t,n),path:f}),a=[r(o),...i?[r(i)]:[],r(h("Desktop")),...t===void 0?[]:[{label:q,path:t}],r(h("Downloads")),...n!==void 0&&t!==void 0?[{label:v,path:Z(t,n)}]:[]],p=new Set,d=a.filter(f=>p.has(f.path)?!1:(p.add(f.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:d,...i&&i!==o?{last:i}:{}}}var c=t=>typeof t=="string"&&t!==""?t:void 0;var pe=[2,1.5,1.25,.75,.5],gt=.25,ht=4,tt=-16;function nt(t){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[t]??t}var et=t=>t.length===1&&t[0]?.kind==="media"?t[0]:void 0,bt=t=>t==="cut"||t==="mute"||t==="speed"||t==="resize"||t==="crop"||t==="rotate"||t==="loudness"||t==="extract"||t==="cleanup";function yt(t,e){let n=e.media??{},o=t.facts?.video,i=[];return e.extract&&i.push("audio"),n.cut&&i.push("trimmed"),n.mute&&i.push("muted"),n.cleanup?i.push("cleaned"):n.loudness!==void 0&&i.push("levelled"),n.speed!==void 0&&i.push(`${n.speed}x`),n.fps!==void 0&&i.push(`${n.fps}fps`),n.bitrate!==void 0&&i.push(`${n.bitrate}k`),e.crop&&i.push(z(e.crop.aspect)),e.resize&&i.push(o?y(g(o,e.resize)):"resized"),e.rotate&&i.push(T(e.rotate)),i.length===1?i[0]:"edited"}function St(t,e){return t.map(n=>{let o=e.target??n.format,i={background:"#ffffff",keepMetadata:!1};e.media&&Object.keys(e.media).length&&(i.media=e.media),e.resize&&(i.resize=e.resize),e.rotate&&(i.rotate=e.rotate);let r=n.facts?.video;e.crop&&r&&(i.crop={aspect:e.crop.aspect,box:e.crop.box??I(r,e.crop.aspect)});let a=e.roots?.get(n.path),p=u({sourcePath:n.path,target:o,suffix:yt(n,e),...e.output===void 0?{}:{output:e.output},...a===void 0?{}:{sourceRoot:a}});return{op:"convert",sources:[n],outputs:[O(p,c(e.destination),c(e.name))],target:o,options:i}})}function x(t){let e={},n=t.cut;return n&&typeof n.start=="number"&&(e.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),t.mute===!0&&(e.mute=!0),typeof t.speed=="number"&&(e.speed=t.speed),typeof t.fps=="number"&&(e.fps=t.fps),typeof t.bitrate=="number"&&(e.bitrate=t.bitrate),typeof t.loudness=="number"&&(e.loudness=t.loudness),t.cleanup===!0&&(e.cleanup=!0),Object.keys(e).length?e:void 0}var de={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, speed, resize, rotate, crop",appliesTo:t=>et(t)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(t,e){let n=et(t);if(!n||!bt(e.tool))return[];let o=e.tool,i={...typeof e.output=="string"?{output:e.output}:{},destination:e.destination,name:e.name};if(o==="cut"){let r=x(e)?.cut;if(!r)return[];i.media={cut:r}}if(o==="mute"&&(i.media={mute:!0}),o==="speed"){let r=e.speed;if(typeof r!="number"||r===1||r<gt||r>ht)return[];i.media={speed:r}}if(o==="loudness"&&(i.media={loudness:typeof e.loudness=="number"?e.loudness:tt}),o==="cleanup"){if(!n.facts?.audio)return[];i.media={cleanup:!0,loudness:tt}}if(o==="extract"){let r=n.facts?.audio;if(!r||!n.facts?.video)return[];i.extract=!0,i.target=G(r.codec)}if(o==="resize"){if(typeof e.resize!="object"||e.resize===null)return[];i.resize=e.resize}if(o==="rotate"){if(!n.facts?.video||!S(e.turn))return[];i.rotate=e.turn}if(o==="crop"){let r=e.crop;if(!r?.aspect||!n.facts?.video)return[];i.crop=r}return St([n],i)}};import{dirname as xt,join as kt}from"node:path";var It=t=>s[t.format].media==="video",zt=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,Ot=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,Mt="-small",m={min:30,max:100,step:35},Tt=t=>{let e=Math.ceil((t-m.min)/m.step);return Math.min(m.max,m.min+Math.max(0,e)*m.step)},ye={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{if(t.length===1&&t[0]?.kind==="media")return!0;let e=zt(t);if(e!==void 0){let o=s[e.format];return o.lossy||o.quantisable===!0}return(Ot(t)?.images?.compressible??0)>0},options(t,e,n){let o=t[0];if(!o)return[];let i=[{kind:"select",id:"mode",label:`Compress ${b(o.path)??"this file"}`,choices:[o.kind==="media"?{value:"quality",label:"By quality"}:{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality"&&o.kind==="media"&&!It(o))i.push({kind:"slider",id:"bitrate",label:"Quality",min:32,max:320,step:32,default:96});else if(e.mode==="quality"){let r=o.kind==="image"&&s[o.format].quantisable===!0;i.push(r?{kind:"slider",id:"quality",label:"Quality",...m,default:Tt(n.quality),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality})}else if(e.mode==="size")i.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return i;return i.push(A(o,n)),i},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw k(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let o=t[0];if(!o)return[];let i=(b(o.path)??"file").replace(/\.[^.]+$/,""),r=typeof e.destination=="string"?e.destination:xt(o.path),a=o.kind==="media"?nt(o.format):o.format,p=kt(r,B(i,`${Mt}${$(a)}`)),d=o.kind==="media"?x(e):void 0;return[{op:"convert",sources:[o],target:a,outputs:[p],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0},...d?{media:d}:{}}}]}};function At(t){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${t.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function Ft(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function Rt(t,e){return Array.isArray(e)?P(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?P(H(e,t.pages)):Array.from({length:t.pages},(n,o)=>o)}function wt(t,e){let n=s[t.format].lossy,o=s[e].lossy;if(n&&!o)return{hint:"likely bigger",tone:"warn"};if(!n&&o)return{hint:"likely smaller",tone:"ok"}}function Pt(t){let e=X(t).filter(o=>o.id!==t.format),n=e[0];return{kind:"select",id:"target",label:`Convert ${s[t.format].label} to`,choices:e.map(o=>{let i=wt(t,o.id);return{value:o.id,label:o.label,hint:i?.hint??o.hint,...i===void 0?{}:{tone:i.tone}}}),default:n?n.id:""}}function Et(t){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:t==="opus"?96:128}}var Ct=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t);function jt(t){let e=t.target,n=typeof e=="string"?D(e):void 0;if(!n)throw k(`convertAction.plan() requires a valid target format, got ${JSON.stringify(e)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var Ae={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let o=t[0];if(!o)return[];let i=[Pt(o)],r=e.target;if(typeof r!="string")return i;o.kind==="document"&&w(r)&&i.push(At(o),Ft());let a=s[r];return o.kind==="media"?a?.media==="sound"&&a.lossy&&i.push(Et(r)):a?.lossy&&a.media===void 0&&i.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),i.push(A(o,n)),i},plan(t,e){let n=t[0];if(!n)return[];let o=jt(e),i=o.id,r={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};if(o.lossy&&typeof e.quality=="number"&&(r.quality=e.quality),n.kind==="media"){let d=x(e);d&&(r.media=d),Ct(e.resize)&&(r.resize=e.resize)}let a=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&w(i)){let d=Number(e.dpi);r.dpi=Number.isFinite(d)&&d>0?d:150;let f=Rt(n,e.pages);r.pages=f;let st=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,pt=_(n.path,f,i,a,st);return[{op:"convert",sources:[n],outputs:pt,target:i,options:r}]}let p=L({sourcePath:n.path,target:i,...a===void 0?{}:{output:`${a}/`}});return J(p,n.path)&&(p=u({sourcePath:n.path,target:i,suffix:i,...a===void 0?{}:{output:`${a}/`}})),[{op:"convert",sources:[n],outputs:[p],target:i,options:r}]}};var Dt=[16,4,2],E=t=>typeof t=="number"&&Dt.includes(t),ot=t=>`dithered-${t}`,we=t=>`${t} colours`,it=t=>s[t.format].quantisable?t.format:"png",C=t=>!(t.frames>1)||t.format==="gif";function $t(t,e){if(e.dither)return ot(e.dither);if(e.deband)return U(e.deband);if(!e.rotate)return rt(t,e);let n=T(e.rotate);return e.trim||e.crop||e.resize?`${rt(t,e)}-${n}`:n}function rt(t,e){if(e.crop){let n=z(e.crop.aspect);if(!e.resize)return n;let o=e.crop.box??I(t,e.crop.aspect);return`${n}-${y(g(o,e.resize))}`}return e.trim&&e.resize?`trimmed-${K(e.resize)}`:e.resize?y(g(t,e.resize)):"trimmed"}function Nt(t,e){if(e.trim&&e.crop)throw new Error("planEdit cannot trim and crop the same image");return t.map(n=>{let o=e.target??(e.dither?it(n):W(n)),i={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{},...e.crop?{crop:e.crop}:{},...e.rotate?{rotate:e.rotate}:{},...e.dither?{dither:e.dither}:{},...e.deband?{deband:e.deband}:{},...e.deband&&e.quality===void 0&&s[o].lossy?{quality:95}:{}},r=e.roots?.get(n.path),a=u({sourcePath:n.path,target:o,suffix:$t(n,e),...e.output===void 0?{}:{output:e.output},...r===void 0?{}:{sourceRoot:r}});return{op:"convert",sources:[n],outputs:[O(a,c(e.destination),c(e.name))],target:o,options:i}})}var j=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,Bt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),at=t=>typeof t=="object"&&t!==null&&"aspect"in t&&typeof t.aspect=="object"&&t.aspect!==null&&"w"in t.aspect&&"h"in t.aspect;function l(t,e,n,o){return{id:t,label:e,verb:n,hint:o,appliesTo:i=>j(i)?.every(r=>t==="resize"?!0:t==="dither"?C(r):r.frames<=1)===!0,unavailable:i=>j(i)?"animated":"images only",options:()=>[],plan(i,r){let a=j(i);return a?t==="crop"&&!at(r.crop)?[]:t==="turn"&&!S(r.turn)?[]:t==="deband"&&(!F(r.deband)||a.some(p=>p.frames>1))?[]:t==="dither"&&(!E(r.dither)||!a.every(C))?[]:Nt(a,{trim:t==="trim"||r.trim===!0,...S(r.turn)?{rotate:r.turn}:{},...t==="dither"&&E(r.dither)?{dither:r.dither}:{},...t==="deband"&&F(r.deband)?{deband:r.deband}:{},...Bt(r.resize)?{resize:r.resize}:{},...at(r.crop)?{crop:r.crop}:{},...typeof r.target=="string"?{target:r.target}:{},...typeof r.output=="string"?{output:r.output}:{},...r.roots instanceof Map?{roots:r.roots}:{},destination:r.destination,name:r.name,background:typeof r.background=="string"?r.background:"#ffffff",keepMetadata:r.keepMetadata===!0,...typeof r.quality=="number"?{quality:r.quality}:{}}):[]}}}var Le=l("trim","Trim edges","Trimming edges","cut empty borders"),_e=l("resize","Resize","Resizing","smaller or larger"),Ue=l("crop","Crop to shape","Cropping","change the shape"),Qe=l("turn","Rotate","Rotating","turn it"),Xe=l("dither","Dither","Dithering","fewer colours, scattered"),Ge=l("deband","Remove banding","Removing banding","smooth out stripes");export{Gt as a,Ht as b,Wt as c,v as d,A as e,lt as f,c as g,ft as h,Vt as i,pe as j,St as k,de as l,ye as m,Ae as n,Dt as o,we as p,it as q,C as r,Nt as s,Le as t,_e as u,Ue as v,Qe as w,Xe as x,Ge as y};
|
|
3
|
+
import{a as b,c as G}from"./chunk-Q6KQWJ4J.js";import{d as W,f as y,g as K}from"./chunk-6HQKTDGG.js";import{a as Q,b as X,e as w}from"./chunk-U3D3EU33.js";import{a as H,b as P}from"./chunk-RRVD63NF.js";import{a as h,d as R}from"./chunk-N6RCLJE6.js";import{i as F,j as U,k as g}from"./chunk-TLHUFIXD.js";import{d as I,l as z}from"./chunk-4MJEEEFA.js";import{b as B,c as J,d as L,e as u,i as _,m as O}from"./chunk-V6GWPR2A.js";import{G as k,u as N}from"./chunk-ZBMJTIYR.js";import{a as s,b as D,c as $}from"./chunk-H3DIRJFE.js";var M=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function Gt(t,e){let n=Q(t);return n.includes(e)?void 0:N(t,e,n)}function V(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var Y=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:s.png.hint}]}),dt=t=>t===1?"sharp":`${t}x`,ut=t=>t===1||t===3||t===4?t:2,Ht={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7, 3\xD7 or 4\xD7",requires:"boost",appliesTo:t=>M(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"3",label:"3\xD7",hint:"three times the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},Y()],plan(t,e){let n=M(t);if(!n)return[];let o=V(e),i=ut(Number(e.scale??2));return n.map(r=>({op:"boost",sources:[r],outputs:[u({sourcePath:r.path,target:o.target,suffix:dt(i),...o.output===void 0?{}:{output:o.output},...o.roots?.get(r.path)===void 0?{}:{sourceRoot:o.roots.get(r.path)}})],scale:i,target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}},Wt={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>M(t)!==void 0,unavailable:()=>"images only",options:()=>[Y()],plan(t,e){let n=M(t);if(!n)return[];let o=V(e);return n.map(i=>({op:"remove-background",sources:[i],outputs:[u({sourcePath:i.path,target:o.target,suffix:"cutout",...o.output===void 0?{}:{output:o.output},...o.roots?.get(i.path)===void 0?{}:{sourceRoot:o.roots.get(i.path)}})],target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}};var ft=[{degrees:90,label:"90\xB0 right",suffix:"rotated-right"},{degrees:180,label:"180\xB0",suffix:"rotated-180"},{degrees:270,label:"90\xB0 left",suffix:"rotated-left"}],S=t=>t===90||t===180||t===270,Vt=(t,e)=>e===180?{...t}:{width:t.height,height:t.width},T=t=>ft.find(e=>e.degrees===t).suffix;import{dirname as ct,join as Z}from"node:path";var q="Same location",v="New subfolder";function mt(t,e,n){return t===e?q:t===h("Desktop")?"Desktop":t===h("Downloads")?"Downloads":e!==void 0&&n!==void 0&&t===Z(e,n)?v:b(t)||t}function A(t,e,n={}){return lt(ct(t.path),e,n)}function lt(t,e,{subfolder:n}={}){let o=R(e.defaultOutput),i=e.lastOutput?R(e.lastOutput):void 0,r=f=>({label:mt(f,t,n),path:f}),a=[r(o),...i?[r(i)]:[],r(h("Desktop")),...t===void 0?[]:[{label:q,path:t}],r(h("Downloads")),...n!==void 0&&t!==void 0?[{label:v,path:Z(t,n)}]:[]],p=new Set,d=a.filter(f=>p.has(f.path)?!1:(p.add(f.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:d,...i&&i!==o?{last:i}:{}}}var c=t=>typeof t=="string"&&t!==""?t:void 0;var pe=[2,1.5,1.25,.75,.5],gt=.25,ht=4,tt=-16;function nt(t){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[t]??t}var et=t=>t.length===1&&t[0]?.kind==="media"?t[0]:void 0,bt=t=>t==="cut"||t==="mute"||t==="speed"||t==="resize"||t==="crop"||t==="rotate"||t==="loudness"||t==="extract"||t==="cleanup";function yt(t,e){let n=e.media??{},o=t.facts?.video,i=[];return e.extract&&i.push("audio"),n.cut&&i.push("trimmed"),n.mute&&i.push("muted"),n.cleanup?i.push("cleaned"):n.loudness!==void 0&&i.push("levelled"),n.speed!==void 0&&i.push(`${n.speed}x`),n.fps!==void 0&&i.push(`${n.fps}fps`),n.bitrate!==void 0&&i.push(`${n.bitrate}k`),e.crop&&i.push(z(e.crop.aspect)),e.resize&&i.push(o?y(g(o,e.resize)):"resized"),e.rotate&&i.push(T(e.rotate)),i.length===1?i[0]:"edited"}function St(t,e){return t.map(n=>{let o=e.target??n.format,i={background:"#ffffff",keepMetadata:!1};e.media&&Object.keys(e.media).length&&(i.media=e.media),e.resize&&(i.resize=e.resize),e.rotate&&(i.rotate=e.rotate);let r=n.facts?.video;e.crop&&r&&(i.crop={aspect:e.crop.aspect,box:e.crop.box??I(r,e.crop.aspect)});let a=e.roots?.get(n.path),p=u({sourcePath:n.path,target:o,suffix:yt(n,e),...e.output===void 0?{}:{output:e.output},...a===void 0?{}:{sourceRoot:a}});return{op:"convert",sources:[n],outputs:[O(p,c(e.destination),c(e.name))],target:o,options:i}})}function x(t){let e={},n=t.cut;return n&&typeof n.start=="number"&&(e.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),t.mute===!0&&(e.mute=!0),typeof t.speed=="number"&&(e.speed=t.speed),typeof t.fps=="number"&&(e.fps=t.fps),typeof t.bitrate=="number"&&(e.bitrate=t.bitrate),typeof t.loudness=="number"&&(e.loudness=t.loudness),t.cleanup===!0&&(e.cleanup=!0),Object.keys(e).length?e:void 0}var de={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, speed, resize, rotate, crop",appliesTo:t=>et(t)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(t,e){let n=et(t);if(!n||!bt(e.tool))return[];let o=e.tool,i={...typeof e.output=="string"?{output:e.output}:{},destination:e.destination,name:e.name};if(o==="cut"){let r=x(e)?.cut;if(!r)return[];i.media={cut:r}}if(o==="mute"&&(i.media={mute:!0}),o==="speed"){let r=e.speed;if(typeof r!="number"||r===1||r<gt||r>ht)return[];i.media={speed:r}}if(o==="loudness"&&(i.media={loudness:typeof e.loudness=="number"?e.loudness:tt}),o==="cleanup"){if(!n.facts?.audio)return[];i.media={cleanup:!0,loudness:tt}}if(o==="extract"){let r=n.facts?.audio;if(!r||!n.facts?.video)return[];i.extract=!0,i.target=G(r.codec)}if(o==="resize"){if(typeof e.resize!="object"||e.resize===null)return[];i.resize=e.resize}if(o==="rotate"){if(!n.facts?.video||!S(e.turn))return[];i.rotate=e.turn}if(o==="crop"){let r=e.crop;if(!r?.aspect||!n.facts?.video)return[];i.crop=r}return St([n],i)}};import{dirname as xt,join as kt}from"node:path";var It=t=>s[t.format].media==="video",zt=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,Ot=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,Mt="-small",m={min:30,max:100,step:35},Tt=t=>{let e=Math.ceil((t-m.min)/m.step);return Math.min(m.max,m.min+Math.max(0,e)*m.step)},ye={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{if(t.length===1&&t[0]?.kind==="media")return!0;let e=zt(t);if(e!==void 0){let o=s[e.format];return o.lossy||o.quantisable===!0}return(Ot(t)?.images?.compressible??0)>0},options(t,e,n){let o=t[0];if(!o)return[];let i=[{kind:"select",id:"mode",label:`Compress ${b(o.path)??"this file"}`,choices:[o.kind==="media"?{value:"quality",label:"By quality"}:{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality"&&o.kind==="media"&&!It(o))i.push({kind:"slider",id:"bitrate",label:"Quality",min:32,max:320,step:32,default:96});else if(e.mode==="quality"){let r=o.kind==="image"&&s[o.format].quantisable===!0;i.push(r?{kind:"slider",id:"quality",label:"Quality",...m,default:Tt(n.quality),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality})}else if(e.mode==="size")i.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return i;return i.push(A(o,n)),i},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw k(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let o=t[0];if(!o)return[];let i=(b(o.path)??"file").replace(/\.[^.]+$/,""),r=typeof e.destination=="string"?e.destination:xt(o.path),a=o.kind==="media"?nt(o.format):o.format,p=kt(r,B(i,`${Mt}${$(a)}`)),d=o.kind==="media"?x(e):void 0;return[{op:"convert",sources:[o],target:a,outputs:[p],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0},...d?{media:d}:{}}}]}};function At(t){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${t.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function Ft(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function Rt(t,e){return Array.isArray(e)?P(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?P(H(e,t.pages)):Array.from({length:t.pages},(n,o)=>o)}function wt(t,e){let n=s[t.format].lossy,o=s[e].lossy;if(n&&!o)return{hint:"likely bigger",tone:"warn"};if(!n&&o)return{hint:"likely smaller",tone:"ok"}}function Pt(t){let e=X(t).filter(o=>o.id!==t.format),n=e[0];return{kind:"select",id:"target",label:`Convert ${s[t.format].label} to`,choices:e.map(o=>{let i=wt(t,o.id);return{value:o.id,label:o.label,hint:i?.hint??o.hint,...i===void 0?{}:{tone:i.tone}}}),default:n?n.id:""}}function Et(t){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:t==="opus"?96:128}}var Ct=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t);function jt(t){let e=t.target,n=typeof e=="string"?D(e):void 0;if(!n)throw k(`convertAction.plan() requires a valid target format, got ${JSON.stringify(e)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var Ae={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let o=t[0];if(!o)return[];let i=[Pt(o)],r=e.target;if(typeof r!="string")return i;o.kind==="document"&&w(r)&&i.push(At(o),Ft());let a=s[r];return o.kind==="media"?a?.media==="sound"&&a.lossy&&i.push(Et(r)):a?.lossy&&a.media===void 0&&i.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),i.push(A(o,n)),i},plan(t,e){let n=t[0];if(!n)return[];let o=jt(e),i=o.id,r={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};if(o.lossy&&typeof e.quality=="number"&&(r.quality=e.quality),n.kind==="media"){let d=x(e);d&&(r.media=d),Ct(e.resize)&&(r.resize=e.resize)}let a=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&w(i)){let d=Number(e.dpi);r.dpi=Number.isFinite(d)&&d>0?d:150;let f=Rt(n,e.pages);r.pages=f;let st=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,pt=_(n.path,f,i,a,st);return[{op:"convert",sources:[n],outputs:pt,target:i,options:r}]}let p=L({sourcePath:n.path,target:i,...a===void 0?{}:{output:`${a}/`}});return J(p,n.path)&&(p=u({sourcePath:n.path,target:i,suffix:i,...a===void 0?{}:{output:`${a}/`}})),[{op:"convert",sources:[n],outputs:[p],target:i,options:r}]}};var Dt=[16,4,2],E=t=>typeof t=="number"&&Dt.includes(t),ot=t=>`dithered-${t}`,we=t=>`${t} colours`,it=t=>s[t.format].quantisable?t.format:"png",C=t=>!(t.frames>1)||t.format==="gif";function $t(t,e){if(e.dither)return ot(e.dither);if(e.deband)return U(e.deband);if(!e.rotate)return rt(t,e);let n=T(e.rotate);return e.trim||e.crop||e.resize?`${rt(t,e)}-${n}`:n}function rt(t,e){if(e.crop){let n=z(e.crop.aspect);if(!e.resize)return n;let o=e.crop.box??I(t,e.crop.aspect);return`${n}-${y(g(o,e.resize))}`}return e.trim&&e.resize?`trimmed-${K(e.resize)}`:e.resize?y(g(t,e.resize)):"trimmed"}function Nt(t,e){if(e.trim&&e.crop)throw new Error("planEdit cannot trim and crop the same image");return t.map(n=>{let o=e.target??(e.dither?it(n):W(n)),i={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{},...e.crop?{crop:e.crop}:{},...e.rotate?{rotate:e.rotate}:{},...e.dither?{dither:e.dither}:{},...e.deband?{deband:e.deband}:{},...e.deband&&e.quality===void 0&&s[o].lossy?{quality:95}:{}},r=e.roots?.get(n.path),a=u({sourcePath:n.path,target:o,suffix:$t(n,e),...e.output===void 0?{}:{output:e.output},...r===void 0?{}:{sourceRoot:r}});return{op:"convert",sources:[n],outputs:[O(a,c(e.destination),c(e.name))],target:o,options:i}})}var j=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,Bt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),at=t=>typeof t=="object"&&t!==null&&"aspect"in t&&typeof t.aspect=="object"&&t.aspect!==null&&"w"in t.aspect&&"h"in t.aspect;function l(t,e,n,o){return{id:t,label:e,verb:n,hint:o,appliesTo:i=>j(i)?.every(r=>t==="resize"?!0:t==="dither"?C(r):r.frames<=1)===!0,unavailable:i=>j(i)?"animated":"images only",options:()=>[],plan(i,r){let a=j(i);return a?t==="crop"&&!at(r.crop)?[]:t==="turn"&&!S(r.turn)?[]:t==="deband"&&(!F(r.deband)||a.some(p=>p.frames>1))?[]:t==="dither"&&(!E(r.dither)||!a.every(C))?[]:Nt(a,{trim:t==="trim"||r.trim===!0,...S(r.turn)?{rotate:r.turn}:{},...t==="dither"&&E(r.dither)?{dither:r.dither}:{},...t==="deband"&&F(r.deband)?{deband:r.deband}:{},...Bt(r.resize)?{resize:r.resize}:{},...at(r.crop)?{crop:r.crop}:{},...typeof r.target=="string"?{target:r.target}:{},...typeof r.output=="string"?{output:r.output}:{},...r.roots instanceof Map?{roots:r.roots}:{},destination:r.destination,name:r.name,background:typeof r.background=="string"?r.background:"#ffffff",keepMetadata:r.keepMetadata===!0,...typeof r.quality=="number"?{quality:r.quality}:{}}):[]}}}var Le=l("trim","Trim edges","Trimming edges","cut empty borders"),_e=l("resize","Resize","Resizing","smaller or larger"),Ue=l("crop","Crop to shape","Cropping","change the shape"),Qe=l("turn","Rotate","Rotating","turn it"),Xe=l("dither","Dither","Dithering","fewer colours, scattered"),Ge=l("deband","Remove banding","Removing banding","smooth out stripes");export{Gt as a,Ht as b,Wt as c,v as d,A as e,lt as f,c as g,ft as h,Vt as i,pe as j,St as k,de as l,ye as m,Ae as n,Dt as o,we as p,it as q,C as r,Nt as s,Le as t,_e as u,Ue as v,Qe as w,Xe as x,Ge as y};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{f as p,q as g,r as f}from"./chunk-
|
|
3
|
+
import{f as p,q as g,r as f}from"./chunk-V6GWPR2A.js";import{randomBytes as l}from"node:crypto";import{copyFile as P,mkdir as w,readdir as h,readFile as y,rename as C,rm as u,stat as k}from"node:fs/promises";import{tmpdir as x}from"node:os";import{extname as c,join as o}from"node:path";function m(){return o(x(),"forge-clip")}var v=5,d={".png":"png",".jpg":"jpeg",".jpeg":"jpeg",".webp":"webp",".heic":"heic",".avif":"avif",".gif":"gif",".tiff":"tiff"};async function O(e,a=m()){let t=`${Date.now().toString(36)}-${l(3).toString("hex")}`,i=o(a,t),r=await e.read(o(i,"in"));if(!r)return await u(i,{recursive:!0,force:!0}),null;let n=o(i,"out");await w(n,{recursive:!0}),await F(a,r.path);let s=o(i,"in","Copied image");return await C(r.path,s),await T(a,t),{source:s,outDir:n,changeCount:r.changeCount}}async function F(e,a){let t=o(e,"last"),i=`Copied image${c(a)}`,r=o(e,`.last-${l(4).toString("hex")}`);await w(r,{recursive:!0}),await P(a,o(r,i)),await u(t,{recursive:!0,force:!0}),await g(r,t)}async function T(e,a){let t=await h(e,{withFileTypes:!0}).catch(()=>[]),r=(await Promise.all(t.filter(n=>n.isDirectory()&&n.name!=="last"&&!n.name.startsWith(".")).map(async n=>({name:n.name,at:(await k(o(e,n.name)).catch(()=>null))?.mtimeMs??0})))).filter(n=>n.name!==a).sort((n,s)=>s.at-n.at).slice(v-1);await Promise.all(r.map(n=>u(o(e,n.name),{recursive:!0,force:!0})))}async function b(e=m()){let a=o(e,"last"),t=(await h(a).catch(()=>[])).find(i=>d[c(i).toLowerCase()]!==void 0);return t===void 0?null:{path:o(a,t),format:d[c(t).toLowerCase()]}}async function S(e,a,t,i){let{changeCount:r}=await e.peek();return r!==a.changeCount?"changed":(await e.write(t,i),"placed")}async function A(e,a,t,i){let{changeCount:r}=await e.peek();return r!==a.changeCount?"changed":(await e.writeText(t,i),"placed")}async function E(e,a=m()){let t=await b(a);return t?(await e.write(t.path,t.format),!0):!1}async function _(e,a){let t=p(o(a,`Copied image${c(e)}`));return await f(t,await y(e)),t}export{O as a,S as b,A as c,E as d,_ as e};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{l as S,m as U}from"./chunk-CVNYUROW.js";import{b as P}from"./chunk-KXKQDFHX.js";import{readFile as ve,stat as Ne}from"node:fs/promises";import{execFile as ie}from"node:child_process";import{randomBytes as oe}from"node:crypto";import{mkdtemp as ae,open as H,readFile as se,rm as D}from"node:fs/promises";import{tmpdir as J}from"node:os";import{join as B}from"node:path";import{promisify as ce}from"node:util";var v=ce(ie),z=async()=>({...await import("./paths-6OENILJ4.js"),...await import("./run-WSETTQXP.js")}),E,N=e=>e!=="darwin";async function _(e=process.platform){return N(e)?await(await z()).installed("heic")!==void 0:k()}async function k(){if(E!==void 0)return E;try{await v("/usr/bin/sips",["--help"],{timeout:5e3}),E=!0}catch{E=!1}return E}async function O(e,n=process.platform){if(N(n))return fe(e,n);let t=B(J(),`forge-heic-${oe(8).toString("hex")}.png`),i=async()=>{await D(t,{force:!0}).catch(()=>{})};try{return await v("/usr/bin/sips",["-s","format","png",e,"--out",t],{timeout:12e4}),{path:t,cleanup:i}}catch(r){throw await i(),r}}async function L(e,n){let{installed:t,runExtension:i}=await z(),r=await t("heic");if(r===void 0)throw S(e,n);return{ext:r,runExtension:i}}async function fe(e,n){let t=await ae(B(J(),"forge-heic-")),i=async()=>{await D(t,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:r,runExtension:o}=await L(e,n),a=B(t,"decoded.rgba"),f=B(t,"decoded.png"),{width:m,height:y}=await o(r,["--in",e,"--out",a],{subject:e});return await(await P())(await se(a),{raw:{width:m,height:y,channels:4}}).png().toFile(f),await D(a,{force:!0}),{path:f,cleanup:i}}catch(r){throw await i(),r}}var ue=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),de=new Set(["avif","avis"]);async function $e(e){let n;try{n=await H(e,"r")}catch{return!1}try{let t=Buffer.alloc(64),{bytesRead:i}=await n.read(t,0,64,0);if(i<12||t.toString("latin1",4,8)!=="ftyp")return!1;let r=Math.min(t.readUInt32BE(0),i),o=[];for(let a=8;a+4<=r;a+=4)o.push(t.toString("latin1",a,a+4));return o.some(a=>de.has(a))?!1:o.some(a=>ue.has(a))}catch{return!1}finally{await n.close().catch(()=>{})}}async function qe(e,n=process.platform){if(N(n)){let{ext:a,runExtension:f}=await L(e,n),m=await f(a,["--info","--in",e],{subject:e});return{width:m.width,height:m.height,hasAlpha:m.hasAlpha??!0}}let{stdout:t}=await v("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",e],{timeout:3e4}),i=Number(/pixelWidth:\s*(\d+)/.exec(t)?.[1]??0),r=Number(/pixelHeight:\s*(\d+)/.exec(t)?.[1]??0),o=await me(e);return{width:o?r:i,height:o?i:r,hasAlpha:/hasAlpha:\s*yes/i.test(t)}}function*x(e,n,t){let i=n;for(;i+8<=t;){let r=e.readUInt32BE(i),o=8;if(r===1&&i+16<=t?(r=Number(e.readBigUInt64BE(i+8)),o=16):r===0&&(r=t-i),r<o)return;yield{type:e.toString("latin1",i+4,i+8),start:i+o,end:Math.min(i+r,t)},i+=r}}async function me(e){let n=await H(e,"r");try{let t=Buffer.alloc(262144),{bytesRead:i}=await n.read(t,0,t.length,0),r=[...x(t,0,i)].find(l=>l.type==="meta");if(!r)return!1;let o=[...x(t,r.start+4,r.end)],a=o.find(l=>l.type==="pitm"),f=o.find(l=>l.type==="iprp");if(!a||!f)return!1;let m=t.readUInt8(a.start)===0?t.readUInt16BE(a.start+4):t.readUInt32BE(a.start+4),y=[...x(t,f.start,f.end)],s=y.find(l=>l.type==="ipco"),c=y.find(l=>l.type==="ipma");if(!s||!c)return!1;let u=new Map;if([...x(t,s.start,s.end)].forEach((l,b)=>{l.type==="irot"&&u.set(b+1,t.readUInt8(l.start)&3)}),u.size===0)return!1;let h=t.readUInt8(c.start),w=(t.readUInt8(c.start+3)&1)===1,d=c.start+4,p=t.readUInt32BE(d);d+=4;for(let l=0;l<p&&d<c.end;l++){let b=h<1?t.readUInt16BE(d):t.readUInt32BE(d);d+=h<1?2:4;let ne=t.readUInt8(d);d+=1;for(let C=0;C<ne;C++){let re=w?t.readUInt16BE(d)&32767:t.readUInt8(d)&127;if(d+=w?2:1,b===m&&(u.get(re)??0)%2===1)return!0}}return!1}catch{return!1}finally{await n.close().catch(()=>{})}}import{execFile as le}from"node:child_process";import{randomBytes as he}from"node:crypto";import{copyFile as we,mkdtemp as W,open as pe,readFile as ye,rm as R}from"node:fs/promises";import{tmpdir as A}from"node:os";import{extname as K,join as I}from"node:path";import{promisify as ge}from"node:util";var $=ge(le),q=async()=>({...await import("./paths-6OENILJ4.js"),...await import("./run-WSETTQXP.js")}),F=e=>e!=="darwin",xe={".nef":[".nef",".nrw"],".arw":[".arw",".srf",".sr2"],".rw2":[".rw2",".rwl"],".3fr":[".3fr",".fff"],".dcr":[".dcr",".kdc"]},be=[["nikon",".nef"],["sony",".arw"],["pentax",".pef"],["ricoh",".pef"],["samsung",".srw"],["hasselblad",".3fr"],["seiko epson",".erf"],["epson",".erf"],["kodak",".dcr"],["eastman kodak",".dcr"],["leaf",".mos"]],Ie=new Set([32803,34892]),Ee=new Set([32767,32769,32770,34316,34713,65e3,65535]),Se="85c0b687820f11e08111f4ce462b6a48";function j(e,n){let t=(s,c)=>n?s.readUInt16LE(c):s.readUInt16BE(c),i=(s,c)=>n?s.readUInt32LE(c):s.readUInt32BE(c),r={1:1,2:1,3:2,4:4,7:1,13:4};async function o(s){if(s<=0)return;let c=await e(s,2);if(c.length<2)return;let u=t(c,0);if(u===0||u>1e3)return;let h=await e(s+2,u*12+4);if(h.length<u*12+4)return;let w=new Map;for(let d=0;d<u;d++){let p=d*12;w.set(t(h,p),{type:t(h,p+2),count:i(h,p+4),inline:h.subarray(p+8,p+12),offset:i(h,p+8)})}return{entries:w,next:i(h,u*12)}}async function a(s,c=16){if(!s)return[];let u=r[s.type]===2?2:4,h=Math.min(s.count,c),w=h*u<=4?s.inline:await e(s.offset,h*u),d=[];for(let p=0;p<h&&(p+1)*u<=w.length;p++)d.push(u===2?t(w,p*u):i(w,p*u));return d}async function f(s){if(s?.type!==2)return"";let c=Math.min(s.count,64);return(c<=4?s.inline.subarray(0,c):await e(s.offset,c)).toString("latin1").replace(/\0.*$/s,"").trim()}async function m(s){let[c]=await a(s.entries.get(274),1);return c!==void 0&&c>=1&&c<=8?c:1}async function y(s){let c=[s],u=new Set;for(let h=0;c.length>0&&h<12;h++){let w=c.shift(),[d]=await a(w.entries.get(262),1),[p]=await a(w.entries.get(259),1);if(d!==void 0&&Ie.has(d)||p!==void 0&&Ee.has(p))return!0;for(let l of[...await a(w.entries.get(330),8),w.next]){if(l===0||u.has(l))continue;u.add(l);let b=await o(l);b&&c.push(b)}}return!1}return{directory:o,text:f,orientation:m,hasMosaic:y,u32:i}}function V(e){let n=e.toString("latin1",0,2);return n==="II"?!0:n==="MM"?!1:void 0}async function Y(e,n){let t=V(e.subarray(n,n+2));if(t===void 0)return 1;let r=j(async(a,f)=>e.subarray(n+a,n+a+f),t),o=await r.directory(r.u32(e,n+4));return o?r.orientation(o):1}async function Pe(e){if(e[0]!==255||e[1]!==216)return 1;let n=2;for(;n+4<=e.length&&e[n]===255;){let t=e[n+1],i=e.readUInt16BE(n+2);if(t===225&&e.toString("latin1",n+4,n+10)==="Exif\0\0")return Y(e,n+10);if(t===218)break;n+=2+i}return 1}async function Be(e,n){let t=await e(0,Math.min(n,1048576)),i=[...x(t,0,t.length)].find(r=>r.type==="moov");if(!i)return 1;for(let r of x(t,i.start,i.end)){if(r.type!=="uuid"||t.toString("hex",r.start,r.start+16)!==Se)continue;let o=[...x(t,r.start+16,r.end)].find(a=>a.type==="CMT1");return o?Y(t,o.start):1}return 1}async function Re(e,n){if(n.length<92)return 1;let t=n.readUInt32BE(84),i=n.readUInt32BE(88);return t===0||i===0?1:Pe(await e(t,Math.min(i,65536)))}async function Me(e){let n;try{n=await pe(e,"r")}catch{return}try{let{size:t}=await n.stat(),i=async(u,h)=>{let w=Math.max(0,Math.min(h,t-u)),d=Buffer.alloc(w);return w>0&&await n.read(d,0,w,u),d},r=await i(0,96);if(r.length<16)return;let o=r.toString("latin1",0,4);if(r.toString("latin1",0,15)==="FUJIFILMCCD-RAW")return{ext:".raf",orientation:await Re(i,r)};if(r.toString("latin1",4,12)==="ftypcrx ")return{ext:".cr3",orientation:await Be(i,t)};let a=V(r);if(a===void 0)return;let f=j(i,a),m=await f.directory(f.u32(r,4));if(!m)return;let y=await f.orientation(m);if(o==="IIRO"||o==="IIRS"||o==="MMOR")return{ext:".orf",orientation:y};if(o==="IIU\0")return{ext:".rw2",orientation:y};if(o!=="II*\0"&&o!=="MM\0*")return;if(m.entries.has(50706))return{ext:".dng",orientation:y};if(r.toString("latin1",8,11)==="CR")return{ext:".cr2",orientation:y};let s=(await f.text(m.entries.get(271))).toLowerCase(),c=be.find(([u])=>s.startsWith(u));return!c||!await f.hasMosaic(m)?void 0:{ext:c[1],orientation:y}}catch{return}finally{await n.close().catch(()=>{})}}async function Ue(e=process.platform){return F(e)?await(await q()).installed("raw")!==void 0:k()}async function Z(e,n){let{installed:t,runExtension:i}=await q(),r=await t("raw");if(r===void 0)throw U(e,n);return{ext:r,runExtension:i}}async function G(e,n,t){let i=K(e).toLowerCase();if((xe[n.ext]??[n.ext]).includes(i))return t(e);let r=await W(I(A(),"forge-raw-"));try{let o=I(r,`photo${n.ext}`);return await we(e,o),await t(o)}finally{await R(r,{recursive:!0,force:!0}).catch(()=>{})}}async function rt(e,n,t=process.platform){if(F(t)){let{ext:a,runExtension:f}=await Z(e,t),m=await f(a,["--info","--in",e],{subject:e,platform:t});if(!(m.width>0&&m.height>0))throw new Error("the raw extension reported no size");return{width:m.width,height:m.height}}let{stdout:i}=await G(e,n,a=>$("/usr/bin/sips",["-g","typeIdentifier","-g","pixelWidth","-g","pixelHeight",a],{timeout:3e4}));if(!/typeIdentifier:\s*\S*raw-image/.test(i))return;let r=Number(/pixelWidth:\s*(\d+)/.exec(i)?.[1]??0),o=Number(/pixelHeight:\s*(\d+)/.exec(i)?.[1]??0);if(!(r===0||o===0))return n.orientation>=5?{width:o,height:r}:{width:r,height:o}}async function Q(e,n=process.platform){if(F(n))return De(e,n);if(!await Ue(n))throw U(e,n);let t=await Me(e)??{ext:K(e).toLowerCase(),orientation:1},i=I(A(),`forge-raw-${he(8).toString("hex")}.png`),r=async()=>{await R(i,{force:!0}).catch(()=>{})};try{return await G(e,t,o=>$("/usr/bin/sips",["-s","format","png",o,"--out",i],{timeout:3e5})),{path:i,cleanup:r}}catch(o){throw await r(),o}}async function De(e,n){let t=await W(I(A(),"forge-raw-")),i=async()=>{await R(t,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:r,runExtension:o}=await Z(e,n),a=I(t,"decoded.rgb"),f=I(t,"decoded.png"),{width:m,height:y}=await o(r,["--in",e,"--out",a],{subject:e,platform:n});return await(await P())(await ye(a),{raw:{width:m,height:y,channels:3}}).png().toFile(f),await R(a,{force:!0}),{path:f,cleanup:i}}catch(r){throw await i(),r}}async function ft(e,n){return n!=="heic"&&n!=="raw"?e:Fe(e,n)}var ke=4,X=256*1024*1024,T=X,ee=6e4,te=ee,M;function Ae(){clearTimeout(M),M=setTimeout(()=>g.clear(),te),M.unref?.()}var g=new Map;async function Fe(e,n){let{size:t,mtimeMs:i}=await Ne(e);Ae();let r=`${n}\0${e}`,o=g.get(r);if(g.delete(r),o&&o.size===t&&o.mtimeMs===i)return g.set(r,o),o.png;let a={size:t,mtimeMs:i,png:Ce(e,n),bytes:0};return g.set(r,a),a.png.then(f=>{a.bytes=f.length,f.length>T&&g.get(r)===a&&g.delete(r),Te()},()=>{g.get(r)===a&&g.delete(r)}),a.png}function Te(){let e=0;for(let n of g.values())e+=n.bytes;for(let[n,t]of g){if(g.size<=ke&&e<=T)break;g.delete(n),e-=t.bytes}}async function Ce(e,n){if(n==="heic"&&!await _())throw S(e);let t=n==="heic"?await O(e):await Q(e);try{return await ve(t.path)}finally{await t.cleanup()}}function ut(){g.clear(),clearTimeout(M)}function dt(e){te=e??ee}function mt(e){T=e??X}export{_ as a,$e as b,qe as c,Me as d,Ue as e,rt as f,ft as g,ut as h,dt as i,mt as j};
|
|
3
|
+
import{n as S,o as U}from"./chunk-ZBMJTIYR.js";import{b as P}from"./chunk-KXKQDFHX.js";import{readFile as ve,stat as Ne}from"node:fs/promises";import{execFile as ie}from"node:child_process";import{randomBytes as oe}from"node:crypto";import{mkdtemp as ae,open as H,readFile as se,rm as D}from"node:fs/promises";import{tmpdir as J}from"node:os";import{join as B}from"node:path";import{promisify as ce}from"node:util";var v=ce(ie),z=async()=>({...await import("./paths-6OENILJ4.js"),...await import("./run-GUFPETHF.js")}),E,N=e=>e!=="darwin";async function _(e=process.platform){return N(e)?await(await z()).installed("heic")!==void 0:k()}async function k(){if(E!==void 0)return E;try{await v("/usr/bin/sips",["--help"],{timeout:5e3}),E=!0}catch{E=!1}return E}async function O(e,n=process.platform){if(N(n))return fe(e,n);let t=B(J(),`forge-heic-${oe(8).toString("hex")}.png`),i=async()=>{await D(t,{force:!0}).catch(()=>{})};try{return await v("/usr/bin/sips",["-s","format","png",e,"--out",t],{timeout:12e4}),{path:t,cleanup:i}}catch(r){throw await i(),r}}async function L(e,n){let{installed:t,runExtension:i}=await z(),r=await t("heic");if(r===void 0)throw S(e,n);return{ext:r,runExtension:i}}async function fe(e,n){let t=await ae(B(J(),"forge-heic-")),i=async()=>{await D(t,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:r,runExtension:o}=await L(e,n),a=B(t,"decoded.rgba"),f=B(t,"decoded.png"),{width:m,height:y}=await o(r,["--in",e,"--out",a],{subject:e});return await(await P())(await se(a),{raw:{width:m,height:y,channels:4}}).png().toFile(f),await D(a,{force:!0}),{path:f,cleanup:i}}catch(r){throw await i(),r}}var ue=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),de=new Set(["avif","avis"]);async function $e(e){let n;try{n=await H(e,"r")}catch{return!1}try{let t=Buffer.alloc(64),{bytesRead:i}=await n.read(t,0,64,0);if(i<12||t.toString("latin1",4,8)!=="ftyp")return!1;let r=Math.min(t.readUInt32BE(0),i),o=[];for(let a=8;a+4<=r;a+=4)o.push(t.toString("latin1",a,a+4));return o.some(a=>de.has(a))?!1:o.some(a=>ue.has(a))}catch{return!1}finally{await n.close().catch(()=>{})}}async function qe(e,n=process.platform){if(N(n)){let{ext:a,runExtension:f}=await L(e,n),m=await f(a,["--info","--in",e],{subject:e});return{width:m.width,height:m.height,hasAlpha:m.hasAlpha??!0}}let{stdout:t}=await v("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",e],{timeout:3e4}),i=Number(/pixelWidth:\s*(\d+)/.exec(t)?.[1]??0),r=Number(/pixelHeight:\s*(\d+)/.exec(t)?.[1]??0),o=await me(e);return{width:o?r:i,height:o?i:r,hasAlpha:/hasAlpha:\s*yes/i.test(t)}}function*x(e,n,t){let i=n;for(;i+8<=t;){let r=e.readUInt32BE(i),o=8;if(r===1&&i+16<=t?(r=Number(e.readBigUInt64BE(i+8)),o=16):r===0&&(r=t-i),r<o)return;yield{type:e.toString("latin1",i+4,i+8),start:i+o,end:Math.min(i+r,t)},i+=r}}async function me(e){let n=await H(e,"r");try{let t=Buffer.alloc(262144),{bytesRead:i}=await n.read(t,0,t.length,0),r=[...x(t,0,i)].find(l=>l.type==="meta");if(!r)return!1;let o=[...x(t,r.start+4,r.end)],a=o.find(l=>l.type==="pitm"),f=o.find(l=>l.type==="iprp");if(!a||!f)return!1;let m=t.readUInt8(a.start)===0?t.readUInt16BE(a.start+4):t.readUInt32BE(a.start+4),y=[...x(t,f.start,f.end)],s=y.find(l=>l.type==="ipco"),c=y.find(l=>l.type==="ipma");if(!s||!c)return!1;let u=new Map;if([...x(t,s.start,s.end)].forEach((l,b)=>{l.type==="irot"&&u.set(b+1,t.readUInt8(l.start)&3)}),u.size===0)return!1;let h=t.readUInt8(c.start),w=(t.readUInt8(c.start+3)&1)===1,d=c.start+4,p=t.readUInt32BE(d);d+=4;for(let l=0;l<p&&d<c.end;l++){let b=h<1?t.readUInt16BE(d):t.readUInt32BE(d);d+=h<1?2:4;let ne=t.readUInt8(d);d+=1;for(let C=0;C<ne;C++){let re=w?t.readUInt16BE(d)&32767:t.readUInt8(d)&127;if(d+=w?2:1,b===m&&(u.get(re)??0)%2===1)return!0}}return!1}catch{return!1}finally{await n.close().catch(()=>{})}}import{execFile as le}from"node:child_process";import{randomBytes as he}from"node:crypto";import{copyFile as we,mkdtemp as W,open as pe,readFile as ye,rm as R}from"node:fs/promises";import{tmpdir as A}from"node:os";import{extname as K,join as I}from"node:path";import{promisify as ge}from"node:util";var $=ge(le),q=async()=>({...await import("./paths-6OENILJ4.js"),...await import("./run-GUFPETHF.js")}),F=e=>e!=="darwin",xe={".nef":[".nef",".nrw"],".arw":[".arw",".srf",".sr2"],".rw2":[".rw2",".rwl"],".3fr":[".3fr",".fff"],".dcr":[".dcr",".kdc"]},be=[["nikon",".nef"],["sony",".arw"],["pentax",".pef"],["ricoh",".pef"],["samsung",".srw"],["hasselblad",".3fr"],["seiko epson",".erf"],["epson",".erf"],["kodak",".dcr"],["eastman kodak",".dcr"],["leaf",".mos"]],Ie=new Set([32803,34892]),Ee=new Set([32767,32769,32770,34316,34713,65e3,65535]),Se="85c0b687820f11e08111f4ce462b6a48";function j(e,n){let t=(s,c)=>n?s.readUInt16LE(c):s.readUInt16BE(c),i=(s,c)=>n?s.readUInt32LE(c):s.readUInt32BE(c),r={1:1,2:1,3:2,4:4,7:1,13:4};async function o(s){if(s<=0)return;let c=await e(s,2);if(c.length<2)return;let u=t(c,0);if(u===0||u>1e3)return;let h=await e(s+2,u*12+4);if(h.length<u*12+4)return;let w=new Map;for(let d=0;d<u;d++){let p=d*12;w.set(t(h,p),{type:t(h,p+2),count:i(h,p+4),inline:h.subarray(p+8,p+12),offset:i(h,p+8)})}return{entries:w,next:i(h,u*12)}}async function a(s,c=16){if(!s)return[];let u=r[s.type]===2?2:4,h=Math.min(s.count,c),w=h*u<=4?s.inline:await e(s.offset,h*u),d=[];for(let p=0;p<h&&(p+1)*u<=w.length;p++)d.push(u===2?t(w,p*u):i(w,p*u));return d}async function f(s){if(s?.type!==2)return"";let c=Math.min(s.count,64);return(c<=4?s.inline.subarray(0,c):await e(s.offset,c)).toString("latin1").replace(/\0.*$/s,"").trim()}async function m(s){let[c]=await a(s.entries.get(274),1);return c!==void 0&&c>=1&&c<=8?c:1}async function y(s){let c=[s],u=new Set;for(let h=0;c.length>0&&h<12;h++){let w=c.shift(),[d]=await a(w.entries.get(262),1),[p]=await a(w.entries.get(259),1);if(d!==void 0&&Ie.has(d)||p!==void 0&&Ee.has(p))return!0;for(let l of[...await a(w.entries.get(330),8),w.next]){if(l===0||u.has(l))continue;u.add(l);let b=await o(l);b&&c.push(b)}}return!1}return{directory:o,text:f,orientation:m,hasMosaic:y,u32:i}}function V(e){let n=e.toString("latin1",0,2);return n==="II"?!0:n==="MM"?!1:void 0}async function Y(e,n){let t=V(e.subarray(n,n+2));if(t===void 0)return 1;let r=j(async(a,f)=>e.subarray(n+a,n+a+f),t),o=await r.directory(r.u32(e,n+4));return o?r.orientation(o):1}async function Pe(e){if(e[0]!==255||e[1]!==216)return 1;let n=2;for(;n+4<=e.length&&e[n]===255;){let t=e[n+1],i=e.readUInt16BE(n+2);if(t===225&&e.toString("latin1",n+4,n+10)==="Exif\0\0")return Y(e,n+10);if(t===218)break;n+=2+i}return 1}async function Be(e,n){let t=await e(0,Math.min(n,1048576)),i=[...x(t,0,t.length)].find(r=>r.type==="moov");if(!i)return 1;for(let r of x(t,i.start,i.end)){if(r.type!=="uuid"||t.toString("hex",r.start,r.start+16)!==Se)continue;let o=[...x(t,r.start+16,r.end)].find(a=>a.type==="CMT1");return o?Y(t,o.start):1}return 1}async function Re(e,n){if(n.length<92)return 1;let t=n.readUInt32BE(84),i=n.readUInt32BE(88);return t===0||i===0?1:Pe(await e(t,Math.min(i,65536)))}async function Me(e){let n;try{n=await pe(e,"r")}catch{return}try{let{size:t}=await n.stat(),i=async(u,h)=>{let w=Math.max(0,Math.min(h,t-u)),d=Buffer.alloc(w);return w>0&&await n.read(d,0,w,u),d},r=await i(0,96);if(r.length<16)return;let o=r.toString("latin1",0,4);if(r.toString("latin1",0,15)==="FUJIFILMCCD-RAW")return{ext:".raf",orientation:await Re(i,r)};if(r.toString("latin1",4,12)==="ftypcrx ")return{ext:".cr3",orientation:await Be(i,t)};let a=V(r);if(a===void 0)return;let f=j(i,a),m=await f.directory(f.u32(r,4));if(!m)return;let y=await f.orientation(m);if(o==="IIRO"||o==="IIRS"||o==="MMOR")return{ext:".orf",orientation:y};if(o==="IIU\0")return{ext:".rw2",orientation:y};if(o!=="II*\0"&&o!=="MM\0*")return;if(m.entries.has(50706))return{ext:".dng",orientation:y};if(r.toString("latin1",8,11)==="CR")return{ext:".cr2",orientation:y};let s=(await f.text(m.entries.get(271))).toLowerCase(),c=be.find(([u])=>s.startsWith(u));return!c||!await f.hasMosaic(m)?void 0:{ext:c[1],orientation:y}}catch{return}finally{await n.close().catch(()=>{})}}async function Ue(e=process.platform){return F(e)?await(await q()).installed("raw")!==void 0:k()}async function Z(e,n){let{installed:t,runExtension:i}=await q(),r=await t("raw");if(r===void 0)throw U(e,n);return{ext:r,runExtension:i}}async function G(e,n,t){let i=K(e).toLowerCase();if((xe[n.ext]??[n.ext]).includes(i))return t(e);let r=await W(I(A(),"forge-raw-"));try{let o=I(r,`photo${n.ext}`);return await we(e,o),await t(o)}finally{await R(r,{recursive:!0,force:!0}).catch(()=>{})}}async function rt(e,n,t=process.platform){if(F(t)){let{ext:a,runExtension:f}=await Z(e,t),m=await f(a,["--info","--in",e],{subject:e,platform:t});if(!(m.width>0&&m.height>0))throw new Error("the raw extension reported no size");return{width:m.width,height:m.height}}let{stdout:i}=await G(e,n,a=>$("/usr/bin/sips",["-g","typeIdentifier","-g","pixelWidth","-g","pixelHeight",a],{timeout:3e4}));if(!/typeIdentifier:\s*\S*raw-image/.test(i))return;let r=Number(/pixelWidth:\s*(\d+)/.exec(i)?.[1]??0),o=Number(/pixelHeight:\s*(\d+)/.exec(i)?.[1]??0);if(!(r===0||o===0))return n.orientation>=5?{width:o,height:r}:{width:r,height:o}}async function Q(e,n=process.platform){if(F(n))return De(e,n);if(!await Ue(n))throw U(e,n);let t=await Me(e)??{ext:K(e).toLowerCase(),orientation:1},i=I(A(),`forge-raw-${he(8).toString("hex")}.png`),r=async()=>{await R(i,{force:!0}).catch(()=>{})};try{return await G(e,t,o=>$("/usr/bin/sips",["-s","format","png",o,"--out",i],{timeout:3e5})),{path:i,cleanup:r}}catch(o){throw await r(),o}}async function De(e,n){let t=await W(I(A(),"forge-raw-")),i=async()=>{await R(t,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:r,runExtension:o}=await Z(e,n),a=I(t,"decoded.rgb"),f=I(t,"decoded.png"),{width:m,height:y}=await o(r,["--in",e,"--out",a],{subject:e,platform:n});return await(await P())(await ye(a),{raw:{width:m,height:y,channels:3}}).png().toFile(f),await R(a,{force:!0}),{path:f,cleanup:i}}catch(r){throw await i(),r}}async function ft(e,n){return n!=="heic"&&n!=="raw"?e:Fe(e,n)}var ke=4,X=256*1024*1024,T=X,ee=6e4,te=ee,M;function Ae(){clearTimeout(M),M=setTimeout(()=>g.clear(),te),M.unref?.()}var g=new Map;async function Fe(e,n){let{size:t,mtimeMs:i}=await Ne(e);Ae();let r=`${n}\0${e}`,o=g.get(r);if(g.delete(r),o&&o.size===t&&o.mtimeMs===i)return g.set(r,o),o.png;let a={size:t,mtimeMs:i,png:Ce(e,n),bytes:0};return g.set(r,a),a.png.then(f=>{a.bytes=f.length,f.length>T&&g.get(r)===a&&g.delete(r),Te()},()=>{g.get(r)===a&&g.delete(r)}),a.png}function Te(){let e=0;for(let n of g.values())e+=n.bytes;for(let[n,t]of g){if(g.size<=ke&&e<=T)break;g.delete(n),e-=t.bytes}}async function Ce(e,n){if(n==="heic"&&!await _())throw S(e);let t=n==="heic"?await O(e):await Q(e);try{return await ve(t.path)}finally{await t.cleanup()}}function ut(){g.clear(),clearTimeout(M)}function dt(e){te=e??ee}function mt(e){T=e??X}export{_ as a,$e as b,qe as c,Me as d,Ue as e,rt as f,ft as g,ut as h,dt as i,mt as j};
|
|
@@ -2,5 +2,5 @@ import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
3
|
import{a as l,c}from"./chunk-MF3KKEFB.js";import{e as p,f as u}from"./chunk-I25E2XDH.js";import{execFile as P}from"node:child_process";import{access as N,constants as A,mkdir as I,readFile as E,realpath as _,writeFile as F}from"node:fs/promises";import{homedir as B}from"node:os";import{dirname as C,join as f,posix as R,sep as m,win32 as S}from"node:path";import{promisify as T}from"node:util";var w=T(P),H=["yt-dlp","video"],X=e=>H.includes(e),a={"yt-dlp":{binary:"yt-dlp",name:"yt-dlp",formula:"yt-dlp",versionArgs:["--version"],version:e=>e.trim().split(`
|
|
4
4
|
`)[0]?.match(/^\d+(\.\d+)+$/)?.[0]},video:{binary:"ffmpeg",name:"ffmpeg",formula:"ffmpeg",versionArgs:["-hide_banner","-version"],version:e=>e.match(/ffmpeg version (\S+)/)?.[1],beside:["ffprobe"]}},Y=e=>a[e].name,q=e=>a[e].formula;function $(e,n){let r=e.split(".").map(Number),i=n.split(".").map(Number);for(let t=0;t<Math.max(r.length,i.length);t++){let o=r[t]??0,s=i[t]??0;if(Number.isNaN(o)||Number.isNaN(s))return e>n;if(o!==s)return o>s}return!1}function g(e){let n=p(e);return n&&(u(n)?.version??u(n,"darwin","universal")?.version)}function y({platform:e=process.platform,env:n=process.env,deep:r=!1}={}){let t=(n.PATH??n.Path??"").split(e==="win32"?";":":").filter(Boolean);if(e==="darwin"&&t.push("/opt/homebrew/bin","/usr/local/bin"),r){let o=n.HOME??B(),{join:s}=e==="win32"?S:R;t.push(s(o,".local","bin"),s(o,"bin"),"/opt/local/bin","/usr/bin")}return[...new Set(t)]}var O=(e,n=process.platform)=>n==="win32"?`${e}.exe`:e;async function d(e){try{return await N(e,A.X_OK),!0}catch{return!1}}async function b(e,n){let r=a[e];if(await d(n)){for(let i of r.beside??[])if(!await d(f(C(n),O(i))))return;try{let{stdout:i}=await w(n,r.versionArgs,{timeout:5e3}),t=r.version(i);if(t===void 0)return;let o=await _(n).catch(()=>n),s=g(e);return{id:e,path:n,version:t,homebrew:o.includes(`${m}Cellar${m}`),tooOld:e==="yt-dlp"&&s!==void 0&&$(s,t)}}catch{return}}}var h=()=>f(l(),"own.json");async function v(){try{let e=JSON.parse(await E(h(),"utf8"));return typeof e=="object"&&e!==null?e:{}}catch{return{}}}async function j(e){let n=(await v())[e];return typeof n=="string"&&n!==""?n:void 0}async function z(e,n){let r=await v();n===void 0?delete r[e]:r[e]=n,await I(l(),{recursive:!0}),await F(h(),`${JSON.stringify(r,null,2)}
|
|
5
|
-
`)}async function J(e,n={}){let r=await j(e);if(r!==void 0){let o=await b(e,r);if(o)return o}let t=process.env.FORGE_NO_OWN_TOOLS==="1"&&n.dirs===void 0?[]:n.dirs??y({deep:n.deep??!1});for(let o of t){let s=await b(e,f(o,O(a[e].binary)));if(s)return s}}async function k(e){if(await c(e)===void 0)return 0;try{let{removeExtension:n,extensionBytes:r}=await import("./manager-
|
|
5
|
+
`)}async function J(e,n={}){let r=await j(e);if(r!==void 0){let o=await b(e,r);if(o)return o}let t=process.env.FORGE_NO_OWN_TOOLS==="1"&&n.dirs===void 0?[]:n.dirs??y({deep:n.deep??!1});for(let o of t){let s=await b(e,f(o,O(a[e].binary)));if(s)return s}}async function k(e){if(await c(e)===void 0)return 0;try{let{removeExtension:n,extensionBytes:r}=await import("./manager-HBAXHJL4.js"),i=await r(e);return await n(e)?i:0}catch{return 0}}async function Q(e={}){let n=await J("yt-dlp",e);if(n&&!n.tooOld)return await k("yt-dlp"),{entry:n.path,own:!0};let r=await c("yt-dlp");return r?{entry:r.entry,own:!1}:void 0}async function x(e){if(e.brew!==void 0)return await d(e.brew)?e.brew:void 0;for(let n of y({env:{PATH:process.env.PATH??""}})){let r=f(n,"brew");if(await d(r))return r}}async function V(e,n={}){if(e.tooOld)return g(e.id);if(!e.homebrew)return;let r=await x(n);if(r!==void 0)try{let{stdout:i}=await w(r,["outdated","--json=v2","--formula",a[e.id].formula],{timeout:15e3,env:{...process.env,HOMEBREW_NO_AUTO_UPDATE:"1"}}),t=JSON.parse(i);if(!Array.isArray(t.formulae))return;let o=t.formulae[0]?.current_version;return typeof o=="string"?o:null}catch{return}}var Z=e=>e.homebrew?"Homebrew":e.id==="yt-dlp"?"yt-dlp":void 0;async function ee(e,n={}){let r,i;if(e.homebrew){let t=await x(n);if(t===void 0)throw new Error("Homebrew was not found");r=t,i=["upgrade",a[e.id].formula]}else if(e.id==="yt-dlp")r=e.path,i=["--update"];else throw new Error(`${a[e.id].name} cannot update itself`);try{await w(r,i,{timeout:10*6e4,maxBuffer:8<<20,...n.signal?{signal:n.signal}:{}})}catch(t){if(n.signal?.aborted)throw n.signal.reason??t;let o=t,s=(o.stderr??"").trim().split(`
|
|
6
6
|
`).filter(Boolean).at(-1)?.replace(/^Error:\s*/,"");throw new Error(s||o.message||"the update failed")}}export{H as a,X as b,Y as c,q as d,$ as e,y as f,b as g,j as h,z as i,J as j,k,Q as l,V as m,Z as n,ee as o};
|
|
@@ -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 B,c as C,d as U}from"./chunk-
|
|
3
|
+
import{b as B,c as C,d as U}from"./chunk-UGYBXR4V.js";import{i as q}from"./chunk-RRVD63NF.js";import{c as T}from"./chunk-V6GWPR2A.js";import{A as M,B as w,a as x,ca as E,da as A,ma as R,q as I,t as k,y as J,z as P}from"./chunk-ZBMJTIYR.js";function D(e=1,t=100){let o=Math.max(1,t-e+1);return 1+Math.max(0,Math.ceil(Math.log2(o)))}async function O(e){let t=e.min??1,o=e.max??100,c=D(t,o),a=0,n=async f=>(a+=1,e.onAttempt?.(a,c),e.encode(f)),s=()=>e.signal?.aborted===!0,u=await n(o);if(s())return{quality:o,bytes:u,missed:!1,cancelled:!0};if(u<=e.targetBytes)return{quality:o,bytes:u,missed:!1};let d=t,p=o,m;for(;d<=p;){let f=Math.floor((d+p)/2),g=await n(f);if(s())return{quality:f,bytes:g,missed:!1,cancelled:!0};g<=e.targetBytes?(m={quality:f,bytes:g,missed:!1},d=f+1):p=f-1}if(m)return m;let b=await e.encode(t);return{quality:t,bytes:b,missed:!0}}import{existsSync as L}from"node:fs";import{resolve as v}from"node:path";function N(e){let t=e.sources[0]?.path??e.outputs[0]??"",o=new Set;for(let c of e.outputs){let a=v(c);if(o.has(a))return{output:c,error:M(t,c)};o.add(a)}}function W(e,t,o){let c=N(e);if(c)return c;let a=e.sources[0]?.path??e.outputs[0]??"";for(let n of e.outputs){let s=v(n);if(e.sources.some(d=>T(d.path,s))&&!o)return{output:n,error:w(n,e.op)};let u=t.get(s);if(u){let d=u.sources[0]?.path??u.outputs[0]??"";return{output:n,error:P([d,a],n)}}if(L(s)&&!o)return{output:n,error:J(n,e.op)}}}function _(e,t){let o=[],c=[],a=new Map;for(let n of e){let s=W(n,a,t.force);if(s){let u=n.sources[0]?.path??s.output;c.push({path:u,error:s.error});continue}for(let u of n.outputs)a.set(v(u),n);o.push(n)}return{jobs:o,failures:c}}async function z(e,t,o,c,a,n){let s=e.sources[0].path,u=r=>({kind:"failed",failure:{path:s,error:x(r)?r:R(s,r)}}),d=o(e);if(d?.sizeTo){let r=e.sources[0],i=e.options.compress!==void 0;if(i&&r.bytes<=t)return{kind:"failed",failure:{path:s,error:A(s,r.bytes,t)}};let l=t,h=d.sizeTo(e,l);return h&&i&&h.floor>=r.bytes?{kind:"failed",failure:{path:s,error:E(s,r.bytes,h.floor,!0)}}:h?{kind:"unreachable",entry:{job:e,smallest:h.floor,settings:{quality:1,media:{...e.options.media,targetBytes:h.floor}},error:k(r,t,h.floor)}}:(e.options={...e.options,media:{...e.options.media,targetBytes:l}},{kind:"ready"})}let p;try{p=await o(e)?.measurer?.(e)}catch(r){return u(r)}if(!p||p.ladder.length===0)return{kind:"refused",failure:{path:s,error:I(e.sources[0],e.target)}};let m=p,b=e.sources[0],f=e.options.compress!==void 0&&b.bytes<=t,g=f?b.bytes-1:t;if(a?.aborted)return{kind:"cancelled"};let F=Number.POSITIVE_INFINITY,y;try{for(let r of m.ladder){let i=await O({encode:l=>m.measure({...e.options,...r,quality:l}),targetBytes:g,...n===void 0?{}:{max:n},onAttempt:(l,h)=>c({type:"search:attempt",job:e,attempt:l,of:h,rung:r}),...a===void 0?{}:{signal:a}});if(i.cancelled)return{kind:"cancelled"};if(i.bytes<F&&(F=i.bytes,y={...r,quality:i.quality}),!i.missed)return e.options={...e.options,...r,quality:i.quality},{kind:"ready"}}}catch(r){return u(r)}return f?{kind:"failed",failure:{path:s,error:E(s,b.bytes,F,!0)}}:{kind:"unreachable",entry:{job:e,smallest:F,settings:y??{quality:1},error:k(e.sources[0],t,F)}}}async function te(e,t){let o=t.onEvent??(()=>{}),c=t.engineFor??q,a=t.targetBytes,n=_(e,{force:t.force}),s=a===void 0?0:n.jobs.filter(r=>r.op==="convert").length,u=[],d=0;await C(n.jobs,B(t.concurrency),async(r,i)=>{if(a===void 0||r.op!=="convert"){u[i]={kind:"ready"};return}if(t.signal?.aborted){u[i]={kind:"cancelled"};return}let l=await z(r,a,c,o,t.signal,t.maxQuality);u[i]=l,l.kind!=="cancelled"&&(d+=1,o({type:"search:settled",job:r,completed:d,total:s}))});let p=[...n.failures],m=[],b=[],f=[],g=!1;for(let[r,i]of n.jobs.entries()){let l=u[r]??{kind:"ready"};l.kind==="ready"?f.push(i):l.kind==="refused"?p.push(l.failure):l.kind==="failed"?b.push(l.failure):l.kind==="unreachable"?m.push(l.entry):g=!0}if(g)return{results:[],refusals:p,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let F=new Set,y=await U(f,{...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)}}),S=f.length-y.results.length;if(t.signal?.aborted&&S>0){let r=y.failures.filter(i=>F.has(i));return{...y,refusals:p,unreachable:m,failures:[...b,...r],cancelled:!0}}return{results:y.results,refusals:p,unreachable:m,failures:[...b,...y.failures],inputBytes:y.inputBytes,outputBytes:y.outputBytes}}export{_ as a,te as b};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as t}from"./chunk-63XCSYHM.js";import{resolve as s}from"node:path";function c(r,e){return{forge:r,ok:!0,card:e,failures:[]}}function J(r,e){return{forge:r,ok:!0,palette:e,failures:[]}}function f(r,e){return{forge:r,ok:!0,scale:e,failures:[]}}function a(r){let e=t(r),n=e.sources.map(o=>s(o.path));return{op:r.job.op,source:n[0]??"",sources:n,outputs:e.outputs.map(o=>s(o)),inputBytes:e.sources.reduce((o,u)=>o+u.bytes,0),outputBytes:e.outputBytes,warnings:e.warnings.map(o=>({code:o.code,message:o.message}))}}function i(r){let{error:e}=r;return{...r.path?{path:s(r.path)}:{},code:e.code,title:e.title,detail:e.detail,...e.hint===void 0?{}:{hint:e.hint}}}function l(r,e){return{forge:r,ok:e.failures.length===0,results:e.results.map(a),failures:e.failures.map(i)}}function m(r,e){return l(r,{results:[],failures:[{error:e}]})}function b(r,e){return{forge:r,ok:!0,formats:e,failures:[]}}function x(r,e){return{forge:r,ok:e.failures.length===0,probes:e.probes,failures:e.failures.map(i)}}function d(r,e,n){return{forge:r,ok:!0,config:e,warnings:n.map(o=>({code:o.code,message:o.message})),failures:[]}}function y(r,e){return{forge:r,ok:!0,extensions:e.extensions,...e.changed?{changed:e.changed}:{},failures:[]}}export{c as a,J as b,f as c,a as d,i as e,l as f,m as g,b as h,x as i,d as j,y as k};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as s}from"./chunk-J7FLFHQJ.js";import{c as r}from"./chunk-VLVNA4T3.js";import{a}from"./chunk-H3DIRJFE.js";import{dirname as f}from"node:path";var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function m(e){return e instanceof o}function v(e){return new o({code:"file-not-found",title:"File not found",detail:`${r(e)} could not be found.`,short:`${r(e)} could not be found.`,hint:"Check the filename and try again."})}function k(e){return new o({code:"not-a-file",title:"Not a file",detail:`${r(e)} is not a file.`,short:`${r(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function C(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(e)} could not be read.`,short:`${r(e)} could not be read.`,hint:"Check the file permissions and try again."})}function S(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${r(e)} could not be found: part of its path is not a directory.`,short:`part of ${r(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function T(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${r(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${r(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function N(e){return new o({code:"path-too-long",title:"Path too long",detail:`${r(e)}'s path is too long for the filesystem to resolve.`,short:`${r(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function I(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${r(e)} could not be checked.`,short:`${r(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function P(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${r(e)} is ${t}, which Forge cannot read.`,short:`${r(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function H(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${r(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function O(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function R(e){return new o({code:"unsupported-source",title:"No colours",detail:`There are no colours in ${e} that Forge can read.`,hint:"Write one a line, a name and a colour (bg #F8F1E6), or use a CSV with name and hex columns, CSS variables or design tokens."})}function A(e,t){let n=t.slice(0,8).join("; "),i=t.length>8?`; and ${t.length-8} more`:"";return new o({code:"unsupported-source",title:"Not colours",detail:`${t.length===1?"One line":`${t.length} lines`} of ${e} could not be read as a colour: ${n}${i}.`,hint:"Write each as a name and a colour, such as bg #F8F1E6, or take the line out."})}function W(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e,t)} is a HEIC photo, which needs Forge's free HEIC extension on ${n}.`,short:"HEIC needs the heic extension.",hint:"Install it with: forge extensions add heic",shellHint:"Open /extensions to install it."})}return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function U(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which needs Forge's free RAW extension on ${n}.`,short:"RAW needs the raw extension.",hint:"Install it with: forge extensions add raw",shellHint:"Open /extensions to install it."})}return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which Forge reads with macOS's own RAW support.`,short:"RAW needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function D(e){return new o({code:"raw-decoder-unavailable",title:"Cannot read this RAW",detail:`${r(e)} is a camera RAW photo that this Mac cannot read.`,short:"macOS cannot read RAW photos from this camera.",hint:"A newer camera usually needs a newer macOS."})}function M(e,t){let n=r(e.path);if(t!==void 0&&t!==e.format){let i=a[t].label;return a[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${n} \u2192 ${i} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${i} is lossless \u2014 there is no quality to trade away, so ${n} cannot be made to fit as ${i}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let i=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:i>0?`${n}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${n} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${n} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function J(e){let t=r(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${a[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function j(e,t,n){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:n??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:n??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function z(e,t,n){let i=e.kind==="media"?`The smallest ${r(e.path)} can get is ${s(n)}, which is still over ${s(t)}.`:`${r(e.path)} is ${s(n)} even at the lowest quality, which is still over ${s(t)}.`;return new o({code:"target-unreachable",title:"Cannot get that small",detail:i,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function L(e,t,n){return new o({code:"unsupported-target",title:`Can't convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is a ${a[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${n.join(", ")}`})}function q(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${r(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function V(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${a[t].label}`,detail:`${r(e)} is a ${a[t].label} file, but its content could not be read.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:n})}function Y(e,t={}){let n=r(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${n} is password-protected.`,short:`${n} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${n} --to jpeg --password-stdin`})}var c=e=>e==="convert"||e==="boost"||e==="remove-background";function _(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:c(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function X(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${r(e[0])} and ${r(e[1])} would both become ${r(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function B(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${r(e)} would write ${r(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function G(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${r(e)} is both the input and the output.`,hint:c(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:c(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function w(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(f(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var b=new Set(["EACCES","EPERM","EROFS"]);function K(e,t){if(m(t))return t;let n=t?.code;return n!==void 0&&b.has(n)?w(e,t):t}function Q(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function Z(e){return new o({code:"empty-directory",title:"No images found",detail:`${r(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function ee(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function te(e,t,n){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${n} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function oe(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function ne(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function re(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function ie(e,t,n,i){return new o({code:"extension-outdated",title:"Extension out of date",detail:`${e} ${n} cannot ${t}; that needs ${i} or later.`,hint:`Update it with: forge extensions add ${e}`,shellHint:"Open /extensions to update it."})}function ae(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function se(e,t,n=process.platform){let i=n==="win32"?"PC":n==="darwin"?"Mac":"computer";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this ${i}: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function le(e,t=process.platform){let n=t==="win32"?"Windows":t==="darwin"?"macOS":t==="linux"?"Linux":"this system";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} is not available on ${n}.`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function de(e){return new o({code:"update-unavailable",title:"Cannot update this Forge",detail:`This copy of Forge was not installed with npm i -g, so ${e} cannot be installed over it.`,hint:"npm i -g forge-terminal"})}function ue(e,t=process.platform){return t==="win32"?new o({code:"update-denied",title:"Forge is in use",detail:`npm could not replace Forge's files to update it to ${e}. Windows keeps them locked while Forge runs: close every Forge window, then run the command below. If Node is installed for every user, run it in a terminal opened as administrator.`,short:"Windows locks Forge while it runs: close it, then run this",hint:`npm i -g forge-terminal@${e}`}):new o({code:"update-denied",title:"npm needs permission",detail:`npm needs permission to update Forge to ${e}.`,short:"npm needs permission to update Forge",hint:`sudo npm i -g forge-terminal@${e}`})}function ce(e,t){return new o({code:"update-failed",title:"Update failed",detail:`npm could not install Forge ${e}: ${t}`,short:"npm could not install the update",hint:`npm i -g forge-terminal@${e}`})}function pe(){return new o({code:"update-unreachable",title:"Could not check for updates",detail:"The npm registry could not be reached.",short:"could not reach npm",hint:"Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge update",shellHint:"Check your connection, then try again."})}function he(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function ge(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function fe(e,t,n){let i=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${i}.`,hint:n==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:n==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function me(e){return new o({code:"no-subject",title:"No subject found",detail:`${r(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function we(e,t,n){return n===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${r(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${r(e)} is too large to boost that far; ${t}x is the most it can take.`:`${r(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function be(e,t,n,i=process.platform){let l=n===1?"sharpen":"boost",d=i==="win32"?"PC":i==="darwin"?"Mac":"computer",u=Math.max(1,Math.round(t/60));return new o({code:"boost-too-slow",title:`Too slow to ${l}`,detail:`${r(e)} would take about ${u} ${u===1?"minute":"minutes"} to ${l} on this ${d}.`,hint:"Try a smaller photo."})}function xe(e,t){return new o({code:"resize-too-large",title:"Too large to resize to",detail:`${r(e)} would be ${t.width} \xD7 ${t.height}.`,hint:"Resize works up to 16,384 px a side and 100 megapixels."})}var x={darwin:"\u2303\u21E7\u23184",win32:"Win+Shift+S"};function $e(e,t=process.platform){let n=x[t];return new o({code:"no-clipboard-image",title:"No image",detail:e==="text"?"The clipboard holds text, not a picture.":"The clipboard is empty.",hint:n===void 0?"Copy a picture or a screenshot, then run forge clip again.":`Copy a picture, or take a screenshot with ${n}, then run forge clip again.`})}function Fe(e=process.platform){return new o({code:"clipboard-unavailable",title:"No clipboard",detail:e==="linux"?"Forge reads the clipboard of a Wayland or X11 desktop, and not over SSH.":"Forge reads the clipboard on macOS, Windows and Linux, and not over SSH."})}function ye(e){return new o({code:"clipboard-tool-missing",title:`Clipboard needs ${e}`,detail:`Forge reaches the clipboard through ${e}, and it is not on this computer.`,short:`${e} is not on this computer`,hint:`Install it with sudo apt install ${e} (or your distribution's package manager), then try again.`})}function Ee(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function ve(e,t,n,i=!1){let l=r(e);if(i)return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} is no smaller even at the lowest quality, so nothing was written.`,short:"nothing written"});let d=n>t?`would grow from ${s(t)} to ${s(n)}`:`would stay at ${s(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} ${d}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function ke(e,t,n){return new o({code:"cannot-compress-more",title:"Already small enough",detail:`${r(e)} is ${s(t)}, already under ${s(n)}, so nothing was written.`,short:"already under that size"})}function Ce(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function Se(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function Te(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Ne(e){return new o({code:"animated-crop",title:"Can't crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function Ie(e){return new o({code:"animated-rotate",title:"Can't rotate an animation",detail:`${r(e)} is animated; rotating works on still images.`})}function Pe(e,t=process.platform,n=!1){let i=p(t),l=n?`forge extensions add video (or ${i})`:t==="linux"?`${i} (or your distribution's package manager)`:i;return new o({code:"ffmpeg-missing",title:"Video and audio need ffmpeg",detail:`${r(e)} is a video or audio file, and ffmpeg is not on this computer.`,short:"ffmpeg is not on this computer",hint:`Install it with ${l}, then run Forge again.`})}function He(e,t,n=process.platform){let i=a[e].label,l=/^[AEFHILMNORSX]/.test(t.codec)?"an":"a",d=t.encoders,u=d.length>1?`${d.slice(0,-1).join(", ")} or ${d.at(-1)}`:d[0]??"",h=d.length>1?"any of them":"it",g=n==="linux"?"Install a full build of ffmpeg, then run Forge again. On Fedora, RPM Fusion's ffmpeg replaces ffmpeg-free.":n==="win32"?`Install a full build of ffmpeg, such as gyan.dev's (${p(n)}), then run Forge again.`:`Install a full build of ffmpeg (${p(n)}), then run Forge again.`;return new o({code:"encoder-missing",title:`Your ffmpeg can't write ${i}`,detail:`${i} needs ${l} ${t.codec} encoder${t.sound?" for its sound":""}: ${u}. Your ffmpeg was built without ${h}.`,short:`Your ffmpeg has no ${t.codec} encoder`,hint:g})}function p(e=process.platform){return e==="win32"?"winget install ffmpeg":e==="linux"?"sudo apt install ffmpeg":"brew install ffmpeg"}function Oe(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${r(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}function Re(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function Ae(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){return n==="whisper"?new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e,t)} cannot be read by whisper.`,hint:"Video and sound files can be transcribed."}):new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e)} cannot be read by Apple's speech recogniser.`,hint:"MP4, MOV, M4A, MP3, WAV and AIFF can be transcribed; with ffmpeg (brew install ffmpeg), any video or sound file."})}function We(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){let i=n==="apple"?"Apple's speech recogniser":"The whisper extension";return new o({code:"language-unsupported",title:"Language not supported",detail:`${i} does not support ${e}.`,hint:"Pass another with --language, for example --language en-US."})}function Ue(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function De(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function Me(e=!1){return e?new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs Forge's free read-text extension.",short:"Needs the read-text extension.",hint:"Install it with: forge extensions add read-text",shellHint:"Open /extensions to install it."}):new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs macOS 26 or later.",short:"Reading text needs macOS 26 or later."})}function Je(e){let t=r(e);return new o({code:"no-text",title:"No text found",detail:`No text found in ${t}`,short:`No text found in ${t}`})}function je(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function ze(e,t={}){let n=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&n.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&n.push("",` ${e.cause.stack??e.cause.message}`),n}export{m as a,v as b,k as c,C as d,S as e,T as f,N as g,I as h,P as i,H as j,O as k,R as l,A as m,W as n,U as o,D as p,M as q,J as r,j as s,z as t,L as u,q as v,V as w,Y as x,_ as y,X as z,B as A,G as B,w as C,K as D,Q as E,Z as F,ee as G,te as H,oe as I,ne as J,re as K,ie as L,ae as M,se as N,le as O,de as P,ue as Q,ce as R,pe as S,he as T,ge as U,fe as V,me as W,we as X,be as Y,xe as Z,$e as _,Fe as $,ye as aa,Ee as ba,ve as ca,ke as da,Ce as ea,Se as fa,Te as ga,Ne as ha,Ie as ia,Pe as ja,He as ka,p as la,Oe as ma,Re as na,Ae as oa,We as pa,Ue as qa,De as ra,Me as sa,Je as ta,je as ua,ze as va};
|
|
@@ -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-PUGNBNSV.js";import"./chunk-W53XNVNH.js";import"./chunk-SM735FG7.js";import"./chunk-GYERZAZU.js";import"./chunk-7MC3LDNP.js";import"./chunk-VDQMK2B2.js";import"./chunk-Q6KQWJ4J.js";import"./chunk-6RMRWBMB.js";import"./chunk-4YK4XWYS.js";import"./chunk-X6PZIFFX.js";import"./chunk-UGYBXR4V.js";import"./chunk-6HQKTDGG.js";import"./chunk-U3D3EU33.js";import"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import"./chunk-P6JX5ZQT.js";import"./chunk-O7DK3GJT.js";import"./chunk-RRVD63NF.js";import"./chunk-EEQSUBBL.js";import"./chunk-MPSLPE4C.js";import"./chunk-FAUL5L2W.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{b as clipLines,a as runClip,d as runClipCommand,c as runUndo};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c}from"./chunk-
|
|
3
|
+
import{a,b,c}from"./chunk-OXDRJO4V.js";import"./chunk-SM735FG7.js";import"./chunk-V6GWPR2A.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{a as copy,c as linuxText,b as paste};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as V}from"./chunk-RM3XA72H.js";import{g as F,h as G,i as B}from"./chunk-TFGK7IRZ.js";import{b as O,c as H}from"./chunk-POM7FXIV.js";import{i as D,l as _,m as M,o as U}from"./chunk-7XFLG32B.js";import{b as x,c as v,h as E,i as $,j as h}from"./chunk-N32JL4UI.js";import{a as J,b as T,c as W}from"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import{a as b}from"./chunk-P6JX5ZQT.js";import"./chunk-RRVD63NF.js";import"./chunk-EEQSUBBL.js";import"./chunk-MPSLPE4C.js";import"./chunk-FAUL5L2W.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import{b as R,c as N,d as P,h as j,k as I,l as L,m as A}from"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import{c as w}from"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";import{readFile as nt}from"node:fs/promises";import{basename as st,resolve as z}from"node:path";function d(t,e){let o=h(e);if(!o)return;let s=o.alpha!==void 0&&o.alpha<1?o.alpha:void 0;return{name:t,hex:x(o.rgb),...s===void 0?{}:{alpha:s}}}function Y(t){let e=t.replace(/^/,"").trim();if(e==="")return{colours:[],bad:[]};if(e.startsWith("{")||e.startsWith("["))try{return X(JSON.parse(e))}catch{}return rt(e.split(/\r?\n/))}var m=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Q=["hex","colour","color","value","$value"];function X(t){let e={colours:[],bad:[]};if(Array.isArray(t)){for(let c of t){if(!m(c))continue;let i=typeof c.name=="string"?c.name:void 0,p=Q.find(a=>typeof c[a]=="string");if(!i||!p)continue;let l=c[p],f=d(i,l);f?e.colours.push(f):e.bad.push(`${i}: ${l}`)}return e}if(!m(t))return e;let o=Object.keys(t).filter(c=>!c.startsWith("$")),s=o.length===1?t[o[0]]:void 0,r=m(s)&&!("$value"in s)?s:t,n=(c,i=0)=>{let p=/^\{(.+)\}$/.exec(c.trim());if(!p||i>8)return c;let l=t;for(let f of p[1].split("."))l=m(l)?l[f]:void 0;return m(l)&&typeof l.$value=="string"?n(l.$value,i+1):typeof l=="string"?n(l,i+1):c},u=(c,i,p)=>{let l=c.$type??p;for(let[f,a]of Object.entries(c)){if(f.startsWith("$"))continue;let C=[...i,f].join("/");if(m(a)&&"$value"in a){let g=a.$type??l,y=a.$value;if(typeof y!="string")continue;let S=d(C,n(y));S?e.colours.push(S):g==="color"&&e.bad.push(`${C}: ${y}`)}else if(m(a))u(a,[...i,f],l);else if(typeof a=="string"){let g=d(C,n(a));g&&e.colours.push(g)}}};return u(r,[]),e}function q(t){let e=[],o="",s=!1;for(let r=0;r<t.length;r++){let n=t[r];s?n==='"'&&t[r+1]==='"'?(o+='"',r++):n==='"'?s=!1:o+=n:n==='"'?s=!0:n===","?(e.push(o.trim()),o=""):o+=n}return e.push(o.trim()),e}var Z=["name","token","label"],tt=["hex","colour","color","value","rgb"];function et(t,e,o){let s={colours:[],bad:[]};for(let r of t){if(r.trim()==="")continue;let n=q(r),u=n[e]??"",c=n[o]??"",i=u?d(u,c):void 0;i?s.colours.push(i):s.bad.push(r.trim())}return s}function ot(t){let e=t.replace(/^[-*•]\s+/,"").replace(/[;,]$/,"").trim();for(let r of[" ",":","=",","]){let n=e.indexOf(r);if(n<=0)continue;let u=d(e.slice(0,n).trim(),e.slice(n+1).trim());if(u?.name)return u}let o=e.split(/\s+/);for(let r=1;r<o.length;r++){let n=d(o.slice(0,r).join(" "),o.slice(r).join(" "));if(n)return n}for(let r=o.length-1;r>=1;r--){let n=d(o.slice(r).join(" "),o.slice(0,r).join(" "));if(n)return n}let s=d("",e);return s?{...s,name:s.hex}:void 0}function rt(t){let e=q(t[0]??"").map(c=>c.toLowerCase()),o=e.findIndex(c=>Z.includes(c)),s=e.findIndex(c=>tt.includes(c));if(e.length>1&&o!==-1&&s!==-1)return et(t.slice(1),o,s);let r=t.some(c=>/^\s*--[\w-]+\s*:/.test(c)),n={colours:[],bad:[]},u=!1;for(let c of t){let i=c.replace(/\/\*.*?\*\//g,"");if(u){let f=i.indexOf("*/");if(f===-1)continue;i=i.slice(f+2),u=!1}let p=i.indexOf("/*");if(p!==-1&&(i=i.slice(0,p),u=!0),i=i.trim(),i===""||i.startsWith("//"))continue;if(r){let f=/^--([\w-]+)\s*:\s*(.+?)\s*;?$/.exec(i);if(!f)continue;let a=d(f[1],f[2]);a&&n.colours.push(a);continue}if(i.startsWith("#")&&!h(i.split(/\s+/)[0]))continue;let l=ot(i);l?n.colours.push(l):n.bad.push(i)}return n}var k=({r:t,g:e,b:o},s)=>s?`\x1B[38;2;${t};${e};${o}m\u2588\u2588\x1B[39m `:"";function it(t,e){let o=v(e),s,r=Number.POSITIVE_INFINITY;for(let n of t){let u=(n.centre.L-o.L)**2+(n.centre.a-o.a)**2+(n.centre.b-o.b)**2;u<r&&(r=u,s=n)}return s}async function ct(t){let{pixels:e}=await V(t.input),o=_(e);if(o.length===0)throw I(t.input);let s=t.inside?it(o,t.inside):void 0,r=s?M(e,s):o,n=T(b,{source:z(t.input),...s?{inside:s.hex}:{},colours:r.map(c=>({hex:c.hex,rgb:E(c.rgb),oklch:$(c.rgb),share:c.share}))});return{groups:r,...s?{parent:s}:{},doc:n,svg:()=>G(w(t.input),r,"light",s?.hex)}}async function Et(t,e){let{groups:o,doc:s,svg:r}=await ct(t);if(t.svg)return{exitCode:0,stdout:[r()],stderr:[]};if(e.json)return{exitCode:0,stdout:[JSON.stringify(s)],stderr:[]};let n=U(o.map(u=>u.share));return{exitCode:0,stdout:o.map((u,c)=>`${k(u.rgb,e.colour)}${u.hex} ${String(n[c]).padStart(3)}%`),stderr:[]}}async function Rt(t,e){let o=D(t.colour);if(t.svg)return{exitCode:0,stdout:[B(t.colour,o)],stderr:[]};let s=o.map(r=>({...r,...H(r.rgb)}));if(e.json){let r=W(b,{reference:x(t.colour),steps:s.map(n=>({step:n.step,hex:n.hex,oklch:$(n.rgb),white:n.white,black:n.black}))});return{exitCode:0,stdout:[JSON.stringify(r)],stderr:[]}}return{exitCode:0,stdout:s.map(r=>`${String(r.step).padStart(4)} ${k(r.rgb,e.colour)}${r.hex} white ${r.white.toFixed(1)} ${O(r.white)} \xB7 black ${r.black.toFixed(1)} ${O(r.black)}`),stderr:[]}}async function ut(){let t=[];for await(let e of process.stdin)t.push(Buffer.from(e));return Buffer.concat(t).toString("utf8")}async function at(t){try{return await nt(t,"utf8")}catch(e){let o=e.code;throw o==="ENOENT"||o==="ENOTDIR"?R(t):o==="EISDIR"?N(t):o==="EACCES"||o==="EPERM"?P(t):j(t,e)}}var K=t=>t.alpha===void 0?t.hex:`${t.hex} ${Math.round(t.alpha*100)}%`;async function Nt(t,e,o=ut){let s=t.input==="-",r=s?await o():await at(t.input),n=s?"the text from stdin":w(t.input),{colours:u,bad:c}=Y(r);if(c.length>0)throw A(n,c);if(u.length===0)throw L(n);if(t.svg){let i=t.title??(s?"Colours":st(t.input).replace(/\..*$/,"")||"Colours"),p=u.length,l=u.map(a=>({id:a.name,name:a.name,value:K(a),hex:a.hex,...a.alpha===void 0?{}:{alpha:a.alpha}}));return{exitCode:0,stdout:[F(i,`${p} colour${p===1?"":"s"}`,l,"light",{perRow:8})],stderr:[]}}if(e.json){let i=J(b,{source:s?"-":z(t.input),colours:u});return{exitCode:0,stdout:[JSON.stringify(i)],stderr:[]}}return{exitCode:0,stdout:u.map(i=>{let p=h(i.hex)?.rgb??{r:0,g:0,b:0};return`${k(p,e.colour)}${K(i)} ${i.name}`}),stderr:[]}}export{ct as readPalette,Nt as runCard,Et as runPalette,Rt as runScale};
|
|
@@ -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 s}from"./chunk-WE6KP4FR.js";import{
|
|
3
|
+
import{a as s}from"./chunk-WE6KP4FR.js";import{G as a}from"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";var d=["open","convert","compress","sharpen","open-file","preset"];function f(t){let[e,n,...r]=t,o=n==="open-pdf"?"open-file":n;if(e==="install"||e==="remove")return{kind:e};if(e==="run"||e==="open"){if(!d.includes(o))throw a(`No menu action called "${o??""}".`);if(o==="preset"){let[i,...c]=r;if(e!=="run"||i===void 0||!s(i))throw a(`No preset called "${i??""}".`);return{kind:"run",action:o,preset:i,paths:c}}return{kind:e,action:o,paths:r}}throw a(`No menu command called "${e??""}".`)}function p(t,e,n=!1){switch(t){case"convert":return{paths:e,mode:"convert",advance:!0};case"compress":return{paths:e,mode:"compress",advance:!0};case"open-file":return{paths:e,mode:n?"pdf":"convert",advance:!1};default:return{paths:[],mode:"convert",advance:!1}}}async function h(t,e){let[n]=e;return p(t,e,t==="open-file"&&n!==void 0&&await u(n))}async function u(t){let{open:e}=await import("node:fs/promises");try{let n=await e(t,"r");try{let r=Buffer.alloc(1024),{bytesRead:o}=await n.read(r,0,r.length,0);return r.subarray(0,o).includes("%PDF-")}finally{await n.close()}}catch{return!1}}export{p as openedFor,h as openedForClick,f as parseMenuArgs};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b}from"./chunk-
|
|
3
|
+
import{a,b}from"./chunk-HTA25PO2.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{a as CONFIG_KEYS,b as runConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e}from"./chunk-
|
|
3
|
+
import{a,b,c,d,e}from"./chunk-ILQDMVJR.js";import"./chunk-4MJEEEFA.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{a as OPS,d as chainLabels,e as reasonsFor,c as stepLabel,b as withStep};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{g as a,h as b,i as c,j as d}from"./chunk-
|
|
3
|
+
import{g as a,h as b,i as c,j as d}from"./chunk-WBW6G4N6.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{b as clearDecodedCacheForTests,a as decodedInput,c as idleDecodedCacheForTests,d as limitDecodedCacheForTests};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as $,b as R,d as g,e as F,f as m,g as G}from"./chunk-
|
|
3
|
+
import{a as $,b as R,d as g,e as F,f as m,g as G}from"./chunk-6RCS3KBP.js";import{H as k,a as N,i as I,j as O}from"./chunk-ZX5FDZZW.js";import"./chunk-6RMRWBMB.js";import{c as b}from"./chunk-MF3KKEFB.js";import"./chunk-I25E2XDH.js";import{c as S}from"./chunk-N72E43Z3.js";import{a as T,b as v,c as _,d as A,e as D}from"./chunk-4KGC5ZBZ.js";import{a as P}from"./chunk-HON4OV7M.js";import{f as E}from"./chunk-V6GWPR2A.js";import{a as y}from"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";import{spawn as ee}from"node:child_process";import{homedir as Te}from"node:os";import{join as M,resolve as ve}from"node:path";import{appendFileSync as te,mkdirSync as C,readFileSync as ne,renameSync as re,rmSync as x,statSync as L}from"node:fs";import{join as j}from"node:path";var ie={quiet:500,cap:3e3,poll:50},oe=15e3,X=e=>new Promise(n=>setTimeout(n,e));async function H(e,n,t,r=ie){C(e,{recursive:!0});let i=j(e,`${n}.spool`),o=j(e,`${n}.lock`),s=p=>{try{return ne(p,"utf8").split(`
|
|
4
4
|
`).filter(Boolean)}catch{return[]}},u=()=>{try{return L(i).size}catch{return 0}};for(te(i,`${t}
|
|
5
|
-
`);;){try{C(o)}catch{try{Date.now()-L(o).mtimeMs>oe&&x(o,{recursive:!0,force:!0})}catch{}if(await X(r.poll),!s(i).includes(t))return null;continue}try{let p=Date.now(),l=u(),c=Date.now();for(;Date.now()-c<r.quiet&&Date.now()-p<r.cap;){await X(r.poll);let d=u();d!==l&&(l=d,c=Date.now())}let a=`${i}.${process.pid}.${Date.now()}`;try{re(i,a)}catch{return[t]}let f=[...new Set(s(a))];return x(a,{force:!0}),f}finally{x(o,{recursive:!0,force:!0})}}}import{realpathSync as se}from"node:fs";import{delimiter as ae,join as ue}from"node:path";function U(e,n,t=process.platform){let r=s=>{try{return se(s)}catch{return}},i=r(e)??e,o=t==="win32"?"node.exe":"node";for(let s of(n??"").split(ae)){if(s==="")continue;let u=ue(s,o);if(u!==e&&r(u)===i)return u}return e}import{basename as w,dirname as ce,extname as le,join as fe}from"node:path";var q={"gnome-terminal":["--"],konsole:["-e"],"xfce4-terminal":["-x"],kitty:[],alacritty:["-e"],wezterm:["start","--"],ghostty:["-e"],xterm:["-e"],"x-terminal-emulator":["-e"],"xdg-terminal-exec":[]},pe=["xdg-terminal-exec","x-terminal-emulator","gnome-terminal","konsole","xfce4-terminal","kitty","alacritty","wezterm","ghostty","xterm"];function B(e,n,t){let i=[...e!==void 0&&e in q?[e]:[],...pe].find(t);return i===void 0?void 0:[i,[...q[i]??[],...n]]}function me(e,n,t){if(t==="linux")return B(e,n,()=>!0)??["xterm",["-e",...n]];if(t==="win32")return e==="wt"?["wt.exe",["-w","new",...n]]:["conhost.exe",n];if(e==="ghostty")return["/usr/bin/open",["-na","Ghostty","--args","-e",...n]];let r=`exec ${n.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 W(e){let n=w(e,le(e));return E(fe(ce(e),`${n}-sharp.png`))}function de(e){let n=e.flatMap(o=>"output"in o?[o.output]:[]),t=e.flatMap(o=>"error"in o?[o]:[]),[r]=t;if(r===void 0)return{title:n.length===1?w(n[0]):`${n.length} files`,body:"Sharpened"};let i=r.input?w(r.input):"file";return e.length===1?{title:`${i} not sharpened`,body:r.error}:{title:`${n.length} of ${e.length} files sharpened`,body:`${i}: ${r.error}`}}function ge(e,n){let t=n.flatMap(s=>"output"in s?[s]:[]),r=n.flatMap(s=>"error"in s?[s]:[]),[i]=r;if(i===void 0){let s=t[0]?.chain??[];return{title:t.length===1?w(t[0]?.output??""):`${t.length} files`,body:[e,...s.length>0?[s.join(" \u2500\u25B8 ")]:[]].join(" \xB7 ")}}let o=i.input?w(i.input):"file";return n.length===1?{title:`${e} didn\u2019t finish`,body:`${o}: ${i.error}`}:{title:`${e} finished ${t.length} of ${n.length} files`,body:`${o}: ${i.error}`}}async function z(e,n,t,r){if(e==="preset"){if(r===void 0||t.runPreset===void 0)return;let u=[];for(let a of n){let f=await t.runPreset(r,a);u.push("error"in f?{input:a,...f}:f)}let{title:p,body:l}=ge(r,u);await t.notify(p,l);let c=u.flatMap(a=>"output"in a?[a.output]:[]).at(-1);c!==void 0&&await t.reveal(c);return}if(e==="sharpen"){let u=[];for(let f of n){let d=await t.sharpen(f);u.push("error"in d?{input:f,...d}:d)}let{title:p,body:l}=de(u);await t.notify(p,l);let a=u.flatMap(f=>"output"in f?[f.output]:[]).at(-1);a!==void 0&&await t.reveal(a);return}let i=e==="open"?[]:n,o=[...t.self,"menu","open",e,...i],s=t.platform==="linux"?B(t.terminal,o,t.has??(()=>!0)):me(t.terminal,o,t.platform);if(s===void 0)return t.notify(he,we);await t.launch(...s)}var he="Forge could not open",we="No terminal was found to open it in.";import{mkdirSync as ye,readFileSync as Me,writeFileSync as Pe}from"node:fs";import{join as Re}from"node:path";async function J(e,n){if(!n.global||!F(e.platform))return;let t=R(e);if(n.enabled===!1){t!==void 0&&await m(e);return}if(!(t!==void 0&&$(t,e))&&(await g(e),t===void 0))return e.platform==="darwin"?"Added Forge to Finder\u2019s Quick Actions":"Added Forge to the right-click menu"}async function K(e){let n=R(e);if(n===void 0)return;let{xdgConfigHome:t,...r}=e;await g({...r,...n,presets:e.presets??[]})}var V=e=>Re(e.menuDir,"terminal"),xe=new Set(["Apple_Terminal","iTerm.app","ghostty"]),Ee={WezTerm:"wezterm",ghostty:"ghostty",kitty:"kitty"};function be(e){if(e.TERM_PROGRAM)return Ee[e.TERM_PROGRAM];if(!e.TMUX){if(e.KITTY_WINDOW_ID)return"kitty";if(e.ALACRITTY_WINDOW_ID||e.ALACRITTY_SOCKET)return"alacritty";if(e.KONSOLE_VERSION)return"konsole";if(e.GNOME_TERMINAL_SCREEN||e.GNOME_TERMINAL_SERVICE)return"gnome-terminal";if(e.XTERM_VERSION)return"xterm"}}function Y(e,n){let t=e.platform==="win32"?n.WT_SESSION?"wt":"console":e.platform==="linux"?be(n):xe.has(n.TERM_PROGRAM??"")?n.TERM_PROGRAM:void 0;if(t)try{ye(e.menuDir,{recursive:!0}),Pe(V(e),t)}catch{}}function Q(e){try{return Me(V(e),"utf8").trim()||void 0}catch{return}}import{rmSync as Se}from"node:fs";async function Z(e,n){await m(e),n.out("\u2713 Removed Forge from the right-click menu");let{code:t,output:r}=await n.npm(["uninstall","--global","forge-terminal"]);return t!==0?(n.out(`\u2715 npm could not uninstall forge-terminal: ${D(r)}`),1):(n.out("\u2713 Uninstalled forge-terminal"),Se(n.forgeDir,{recursive:!0,force:!0}),n.out("\u2713 Deleted Forge\u2019s settings"),0)}var _e=()=>M(P(),"forge","menu");async function Ae(){try{let{loadPreferences:e}=await import("./preferences-3P4V2EDX.js"),{prefs:n}=await e();return(n.presets??[]).filter(t=>t.quickAction).map(t=>t.name)}catch{return[]}}async function h(e){return{platform:process.platform,home:Te(),menuDir:_e(),node:U(process.execPath,process.env.PATH),execArgv:process.execArgv,forge:v(process.argv[1])??"",...process.env.XDG_CONFIG_HOME?{xdgConfigHome:process.env.XDG_CONFIG_HOME}:{},...process.env.XDG_DATA_HOME?{xdgDataHome:process.env.XDG_DATA_HOME}:{},...process.env.XDG_CONFIG_DIRS?{xdgConfigDirs:process.env.XDG_CONFIG_DIRS}:{},...process.env.PATH?{path:process.env.PATH}:{},version:e,sharpen:await b("boost")!==void 0,presets:await Ae(),run:G}}async function mt(e){if(process.env.FORGE_NO_MENU)return;let n=await h(e);Y(n,process.env);let{loadPreferences:t}=await import("./preferences-3P4V2EDX.js"),{prefs:r}=await t();return J(n,{global:T(n.forge,n.platform),enabled:r.rightClickMenu!==!1})}async function dt(){let{isInstalled:e}=await import("./install-
|
|
5
|
+
`);;){try{C(o)}catch{try{Date.now()-L(o).mtimeMs>oe&&x(o,{recursive:!0,force:!0})}catch{}if(await X(r.poll),!s(i).includes(t))return null;continue}try{let p=Date.now(),l=u(),c=Date.now();for(;Date.now()-c<r.quiet&&Date.now()-p<r.cap;){await X(r.poll);let d=u();d!==l&&(l=d,c=Date.now())}let a=`${i}.${process.pid}.${Date.now()}`;try{re(i,a)}catch{return[t]}let f=[...new Set(s(a))];return x(a,{force:!0}),f}finally{x(o,{recursive:!0,force:!0})}}}import{realpathSync as se}from"node:fs";import{delimiter as ae,join as ue}from"node:path";function U(e,n,t=process.platform){let r=s=>{try{return se(s)}catch{return}},i=r(e)??e,o=t==="win32"?"node.exe":"node";for(let s of(n??"").split(ae)){if(s==="")continue;let u=ue(s,o);if(u!==e&&r(u)===i)return u}return e}import{basename as w,dirname as ce,extname as le,join as fe}from"node:path";var q={"gnome-terminal":["--"],konsole:["-e"],"xfce4-terminal":["-x"],kitty:[],alacritty:["-e"],wezterm:["start","--"],ghostty:["-e"],xterm:["-e"],"x-terminal-emulator":["-e"],"xdg-terminal-exec":[]},pe=["xdg-terminal-exec","x-terminal-emulator","gnome-terminal","konsole","xfce4-terminal","kitty","alacritty","wezterm","ghostty","xterm"];function B(e,n,t){let i=[...e!==void 0&&e in q?[e]:[],...pe].find(t);return i===void 0?void 0:[i,[...q[i]??[],...n]]}function me(e,n,t){if(t==="linux")return B(e,n,()=>!0)??["xterm",["-e",...n]];if(t==="win32")return e==="wt"?["wt.exe",["-w","new",...n]]:["conhost.exe",n];if(e==="ghostty")return["/usr/bin/open",["-na","Ghostty","--args","-e",...n]];let r=`exec ${n.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 W(e){let n=w(e,le(e));return E(fe(ce(e),`${n}-sharp.png`))}function de(e){let n=e.flatMap(o=>"output"in o?[o.output]:[]),t=e.flatMap(o=>"error"in o?[o]:[]),[r]=t;if(r===void 0)return{title:n.length===1?w(n[0]):`${n.length} files`,body:"Sharpened"};let i=r.input?w(r.input):"file";return e.length===1?{title:`${i} not sharpened`,body:r.error}:{title:`${n.length} of ${e.length} files sharpened`,body:`${i}: ${r.error}`}}function ge(e,n){let t=n.flatMap(s=>"output"in s?[s]:[]),r=n.flatMap(s=>"error"in s?[s]:[]),[i]=r;if(i===void 0){let s=t[0]?.chain??[];return{title:t.length===1?w(t[0]?.output??""):`${t.length} files`,body:[e,...s.length>0?[s.join(" \u2500\u25B8 ")]:[]].join(" \xB7 ")}}let o=i.input?w(i.input):"file";return n.length===1?{title:`${e} didn\u2019t finish`,body:`${o}: ${i.error}`}:{title:`${e} finished ${t.length} of ${n.length} files`,body:`${o}: ${i.error}`}}async function z(e,n,t,r){if(e==="preset"){if(r===void 0||t.runPreset===void 0)return;let u=[];for(let a of n){let f=await t.runPreset(r,a);u.push("error"in f?{input:a,...f}:f)}let{title:p,body:l}=ge(r,u);await t.notify(p,l);let c=u.flatMap(a=>"output"in a?[a.output]:[]).at(-1);c!==void 0&&await t.reveal(c);return}if(e==="sharpen"){let u=[];for(let f of n){let d=await t.sharpen(f);u.push("error"in d?{input:f,...d}:d)}let{title:p,body:l}=de(u);await t.notify(p,l);let a=u.flatMap(f=>"output"in f?[f.output]:[]).at(-1);a!==void 0&&await t.reveal(a);return}let i=e==="open"?[]:n,o=[...t.self,"menu","open",e,...i],s=t.platform==="linux"?B(t.terminal,o,t.has??(()=>!0)):me(t.terminal,o,t.platform);if(s===void 0)return t.notify(he,we);await t.launch(...s)}var he="Forge could not open",we="No terminal was found to open it in.";import{mkdirSync as ye,readFileSync as Me,writeFileSync as Pe}from"node:fs";import{join as Re}from"node:path";async function J(e,n){if(!n.global||!F(e.platform))return;let t=R(e);if(n.enabled===!1){t!==void 0&&await m(e);return}if(!(t!==void 0&&$(t,e))&&(await g(e),t===void 0))return e.platform==="darwin"?"Added Forge to Finder\u2019s Quick Actions":"Added Forge to the right-click menu"}async function K(e){let n=R(e);if(n===void 0)return;let{xdgConfigHome:t,...r}=e;await g({...r,...n,presets:e.presets??[]})}var V=e=>Re(e.menuDir,"terminal"),xe=new Set(["Apple_Terminal","iTerm.app","ghostty"]),Ee={WezTerm:"wezterm",ghostty:"ghostty",kitty:"kitty"};function be(e){if(e.TERM_PROGRAM)return Ee[e.TERM_PROGRAM];if(!e.TMUX){if(e.KITTY_WINDOW_ID)return"kitty";if(e.ALACRITTY_WINDOW_ID||e.ALACRITTY_SOCKET)return"alacritty";if(e.KONSOLE_VERSION)return"konsole";if(e.GNOME_TERMINAL_SCREEN||e.GNOME_TERMINAL_SERVICE)return"gnome-terminal";if(e.XTERM_VERSION)return"xterm"}}function Y(e,n){let t=e.platform==="win32"?n.WT_SESSION?"wt":"console":e.platform==="linux"?be(n):xe.has(n.TERM_PROGRAM??"")?n.TERM_PROGRAM:void 0;if(t)try{ye(e.menuDir,{recursive:!0}),Pe(V(e),t)}catch{}}function Q(e){try{return Me(V(e),"utf8").trim()||void 0}catch{return}}import{rmSync as Se}from"node:fs";async function Z(e,n){await m(e),n.out("\u2713 Removed Forge from the right-click menu");let{code:t,output:r}=await n.npm(["uninstall","--global","forge-terminal"]);return t!==0?(n.out(`\u2715 npm could not uninstall forge-terminal: ${D(r)}`),1):(n.out("\u2713 Uninstalled forge-terminal"),Se(n.forgeDir,{recursive:!0,force:!0}),n.out("\u2713 Deleted Forge\u2019s settings"),0)}var _e=()=>M(P(),"forge","menu");async function Ae(){try{let{loadPreferences:e}=await import("./preferences-3P4V2EDX.js"),{prefs:n}=await e();return(n.presets??[]).filter(t=>t.quickAction).map(t=>t.name)}catch{return[]}}async function h(e){return{platform:process.platform,home:Te(),menuDir:_e(),node:U(process.execPath,process.env.PATH),execArgv:process.execArgv,forge:v(process.argv[1])??"",...process.env.XDG_CONFIG_HOME?{xdgConfigHome:process.env.XDG_CONFIG_HOME}:{},...process.env.XDG_DATA_HOME?{xdgDataHome:process.env.XDG_DATA_HOME}:{},...process.env.XDG_CONFIG_DIRS?{xdgConfigDirs:process.env.XDG_CONFIG_DIRS}:{},...process.env.PATH?{path:process.env.PATH}:{},version:e,sharpen:await b("boost")!==void 0,presets:await Ae(),run:G}}async function mt(e){if(process.env.FORGE_NO_MENU)return;let n=await h(e);Y(n,process.env);let{loadPreferences:t}=await import("./preferences-3P4V2EDX.js"),{prefs:r}=await t();return J(n,{global:T(n.forge,n.platform),enabled:r.rightClickMenu!==!1})}async function dt(){let{isInstalled:e}=await import("./install-KGFOAQCU.js");return e(await h(""))}async function gt(e){let{VERSION:n}=await import("./theme-ISNQEBTS.js"),{savePreferences:t}=await import("./preferences-3P4V2EDX.js"),r=await h(n);e?await g(r):await m(r),await t({rightClickMenu:e})}async function ht(){if(!process.env.FORGE_NO_MENU)try{await K(await h(""))}catch{}}async function De(e){let{parseArgs:n}=await import("./args-5CQKOHYO.js"),{runIntent:t}=await import("./execute-KTLXJTU2.js"),r=n([e,"--sharpen","--output",W(e)]),i=await t(r),o=i.results[0]?.job.outputs[0];if(o!==void 0)return{output:o};let s=i.failures[0]?.error;return{error:y(s)?s.detail:"It could not be sharpened."}}async function Ne(e,n){let{runPresetCommand:t}=await import("./preset-command-4OVFEH7Y.js"),{loadPreferences:r}=await import("./preferences-3P4V2EDX.js"),{chainLabels:i}=await import("./continue-editing-M6WESEVB.js");try{let o=await t({kind:"preset",inputs:[n],name:e,force:!1,recursive:!1,debug:!1,keepBoth:!0}),s=o.results[0],u=s?.job.outputs[0];if(s!==void 0&&u!==void 0){let{prefs:l}=await r(),c=l.presets?.find(f=>f.name===e)?.steps,a=s.job.sources[0]?.format;return{output:u,chain:c&&a?i(a,c):[]}}let p=o.failures[0]?.error;return{error:y(p)?p.detail:"It could not be made."}}catch(o){return{error:y(o)?o.detail:"It could not be made."}}}var Ie=(e,n)=>new Promise(t=>{let r=ee(e,n,{detached:!0,stdio:"ignore"});r.on("error",()=>t()),r.unref(),t()});async function wt(e,n){let t=await h(n);if(e.kind==="install")return await g(t),0;if(e.kind==="remove")return await m(t),0;if(e.kind!=="run")return 2;let r=e.paths.map(i=>ve(i));if(t.platform==="win32"&&r.length===1){let i=e.preset===void 0?e.action:`preset-${e.preset}`,o=await H(M(t.menuDir,"spool"),i,r[0]);if(o===null)return 0;r=o}return await z(e.action,r,{platform:t.platform,self:[t.node,...t.execArgv,t.forge],terminal:Q(t),launch:Ie,sharpen:De,runPreset:Ne,notify:(i,o)=>k(i,o,t.platform,{icon:M(t.menuDir,O({paint:"forge"}))}),has:i=>I(i,t.path),reveal:async i=>{await S(i,t.platform)}},e.preset),0}async function yt(e,n){let t=await h(e),r=i=>new Promise(o=>{let s=t.platform==="win32"?A(t.node):void 0,[u,p]=s!==void 0?[t.node,[s,...i]]:[_(t.node),i],l="",c=ee(u,p,{stdio:["ignore","pipe","pipe"]});c.stdout.setEncoding("utf8").on("data",a=>{l+=a}),c.stderr.setEncoding("utf8").on("data",a=>{l+=a}),c.on("error",a=>o({code:null,output:`${l}
|
|
6
6
|
${a.message}`})),c.on("close",a=>o({code:a,output:l}))});return Z(t,{forgeDir:M(P(),"forge"),npm:r,out:n})}export{mt as menuAtStart,dt as menuIsOn,h as realMenuEnv,ht as resyncMenu,wt as runMenuCommand,yt as runUninstall,gt 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-GYERZAZU.js";import"./chunk-7MC3LDNP.js";import"./chunk-VDQMK2B2.js";import"./chunk-Q6KQWJ4J.js";import"./chunk-6RMRWBMB.js";import"./chunk-4YK4XWYS.js";import"./chunk-X6PZIFFX.js";import"./chunk-UGYBXR4V.js";import"./chunk-6HQKTDGG.js";import"./chunk-U3D3EU33.js";import"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import"./chunk-P6JX5ZQT.js";import"./chunk-O7DK3GJT.js";import"./chunk-RRVD63NF.js";import"./chunk-EEQSUBBL.js";import"./chunk-MPSLPE4C.js";import"./chunk-FAUL5L2W.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{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-L57UZTYE.js";import"./chunk-Q6KQWJ4J.js";import"./chunk-POM7FXIV.js";import"./chunk-7XFLG32B.js";import"./chunk-I25E2XDH.js";import"./chunk-IBPGC4N2.js";import"./chunk-N32JL4UI.js";import"./chunk-P6JX5ZQT.js";import"./chunk-EEQSUBBL.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{e as ExtensionsFlow,c as byteCount,b as extensionCredits,d as extensionsChip,a as realManager};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{f as d}from"./chunk-I25E2XDH.js";import{a as c}from"./chunk-J7FLFHQJ.js";import"./chunk-TMUK2DD3.js";function y(e){let t=Object.entries(e.assets).find(([n])=>n.startsWith(`${process.platform}-`));return d(e)?.version??t?.[1]?.version??""}function x(e){return{id:e.entry.id,title:e.entry.title,summary:e.entry.summary,version:y(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 E(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 v(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)} ${E(n)}`,`${" ".repeat(t)} ${n.entry.licence}`])}async function w(e,t={}){let{installExtension:n,listExtensions:a,removeExtension:p}=await import("./manager-
|
|
3
|
+
import{f as d}from"./chunk-I25E2XDH.js";import{a as c}from"./chunk-J7FLFHQJ.js";import"./chunk-TMUK2DD3.js";function y(e){let t=Object.entries(e.assets).find(([n])=>n.startsWith(`${process.platform}-`));return d(e)?.version??t?.[1]?.version??""}function x(e){return{id:e.entry.id,title:e.entry.title,summary:e.entry.summary,version:y(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 E(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 v(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)} ${E(n)}`,`${" ".repeat(t)} ${n.entry.licence}`])}async function w(e,t={}){let{installExtension:n,listExtensions:a,removeExtension:p}=await import("./manager-HBAXHJL4.js"),i,s;if(e.action==="add"&&e.id!==void 0){let o=(await a()).find(f=>f.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{hideUnneeded:m}=await import("./needed-GMZEKBH4.js"),r=await m(await a());return{stdout:s===void 0?v(r):[s],data:{extensions:r.map(x),...i?{changed:i}:{}}}}export{w as runExtensions,x as toExtensionJson};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-MPSLPE4C.js";import"./chunk-TMUK2DD3.js";export{a as ffmpegCandidates,c as findFfmpeg,e as forceFfmpegForTests,i as frameAt,g as keyframeAtOrBefore,d as knownFfmpeg,f as probeMedia,b as readNames,j as readProgress,k as runFfmpeg,h as soundLevels};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h}from"./chunk-
|
|
3
|
+
import{m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h}from"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{c as decodeToPng,a as encode,d as encodeToBuffer,g as guessCrop,h as imageEngine,f as loadCropView,e as measureImage,b as writeAtomic};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
3
|
+
import{a,b,c,d,e,f,g}from"./chunk-6RCS3KBP.js";import"./chunk-ZX5FDZZW.js";import"./chunk-6RMRWBMB.js";import"./chunk-V6GWPR2A.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{e as hasMenu,d as installMenu,c as isInstalled,b as readState,f as removeMenu,g as runProgram,a as stateMatches};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e,f}from"./chunk-
|
|
3
|
+
import{a,b,c,d,e,f}from"./chunk-4KGC5ZBZ.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{f as installUpdate,a as installedGlobally,e as lastWords,c as npmBeside,d as npmCliBeside,b as runningScript};
|