forge-terminal 0.1.0 → 0.2.1

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.
Files changed (212) hide show
  1. package/README.md +333 -24
  2. package/dist/chunks/adm-zip-SQKLKBDP.js +3 -0
  3. package/dist/chunks/available-HEUREG6L.js +3 -0
  4. package/dist/chunks/boot-BUGERSEB.js +3 -0
  5. package/dist/chunks/catalog-NTACQH5V.js +3 -0
  6. package/dist/chunks/cfb-V6M2PYOD.js +13 -0
  7. package/dist/chunks/chunk-2WYHI73Y.js +3 -0
  8. package/dist/chunks/chunk-4YCO7S4K.js +3 -0
  9. package/dist/chunks/chunk-5B7WODWH.js +3 -0
  10. package/dist/chunks/chunk-C2WYXNRM.js +4 -0
  11. package/dist/chunks/chunk-C7OOWUMU.js +3 -0
  12. package/dist/chunks/chunk-EOYBXOCV.js +4 -0
  13. package/dist/chunks/chunk-G2D6BKOS.js +4 -0
  14. package/dist/chunks/chunk-HUAEVW2A.js +3 -0
  15. package/dist/chunks/chunk-J7FLFHQJ.js +3 -0
  16. package/dist/chunks/chunk-L76Q54MB.js +3 -0
  17. package/dist/chunks/chunk-LFE3WRU4.js +3 -0
  18. package/dist/chunks/chunk-PBIS2ONZ.js +3 -0
  19. package/dist/chunks/chunk-PD5DFBCU.js +3 -0
  20. package/dist/chunks/chunk-PN73WK2S.js +3 -0
  21. package/dist/chunks/chunk-QVACE4IE.js +3 -0
  22. package/dist/chunks/chunk-TEGB7JRM.js +3 -0
  23. package/dist/chunks/chunk-TMUK2DD3.js +3 -0
  24. package/dist/chunks/chunk-UNVHKJW4.js +41 -0
  25. package/dist/chunks/chunk-VH5RWPGZ.js +10 -0
  26. package/dist/chunks/chunk-XFEHJ4C7.js +3 -0
  27. package/dist/chunks/chunk-YXDEOLNA.js +3 -0
  28. package/dist/chunks/colour-DE6N6AZO.js +3 -0
  29. package/dist/chunks/config-command-SQXRTBRO.js +3 -0
  30. package/dist/chunks/dist-J2V6ITHG.js +29 -0
  31. package/dist/chunks/es-T2U7NBLD.js +3 -0
  32. package/dist/chunks/execute-M3C3TTWB.js +3 -0
  33. package/dist/chunks/extensions-command-HJDBUBYO.js +3 -0
  34. package/dist/chunks/image-GYUUMS6H.js +3 -0
  35. package/dist/chunks/launch-WBUFRVQ7.js +65 -0
  36. package/dist/chunks/lib-TPEJ5CJJ.js +46 -0
  37. package/dist/chunks/lock-XD4L3WFM.js +3 -0
  38. package/dist/chunks/manager-KBJTXZ27.js +4 -0
  39. package/dist/chunks/paths-JUM6GKQU.js +3 -0
  40. package/dist/chunks/pdf-compress-IMRFBLZF.js +3 -0
  41. package/dist/chunks/react-devtools-core-UM4FS6CU.js +3 -0
  42. package/dist/chunks/run-RXVQD4DZ.js +4 -0
  43. package/dist/chunks/server-DU7QWDAH.js +73 -0
  44. package/dist/chunks/theme-DESCJOCE.js +3 -0
  45. package/dist/chunks/word-OGQ2KZAJ.js +24 -0
  46. package/dist/index.js +67 -95
  47. package/dist/third-party-licenses.txt +2856 -0
  48. package/package.json +28 -21
  49. package/skills/forge/SKILL.md +149 -0
  50. package/dist/cli/args.js +0 -278
  51. package/dist/cli/args.js.map +0 -1
  52. package/dist/cli/config-command.js +0 -55
  53. package/dist/cli/config-command.js.map +0 -1
  54. package/dist/cli/execute.js +0 -377
  55. package/dist/cli/execute.js.map +0 -1
  56. package/dist/cli/report.js +0 -123
  57. package/dist/cli/report.js.map +0 -1
  58. package/dist/cli/spinner.js +0 -60
  59. package/dist/cli/spinner.js.map +0 -1
  60. package/dist/cli/stdin.js +0 -47
  61. package/dist/cli/stdin.js.map +0 -1
  62. package/dist/config/preferences.js +0 -143
  63. package/dist/config/preferences.js.map +0 -1
  64. package/dist/core/actions/compress.js +0 -157
  65. package/dist/core/actions/compress.js.map +0 -1
  66. package/dist/core/actions/convert.js +0 -270
  67. package/dist/core/actions/convert.js.map +0 -1
  68. package/dist/core/actions/extract.js +0 -94
  69. package/dist/core/actions/extract.js.map +0 -1
  70. package/dist/core/actions/index.js +0 -23
  71. package/dist/core/actions/index.js.map +0 -1
  72. package/dist/core/actions/merge.js +0 -16
  73. package/dist/core/actions/merge.js.map +0 -1
  74. package/dist/core/actions/rotate.js +0 -36
  75. package/dist/core/actions/rotate.js.map +0 -1
  76. package/dist/core/actions/split.js +0 -65
  77. package/dist/core/actions/split.js.map +0 -1
  78. package/dist/core/atomic.js +0 -61
  79. package/dist/core/atomic.js.map +0 -1
  80. package/dist/core/capabilities.js +0 -59
  81. package/dist/core/capabilities.js.map +0 -1
  82. package/dist/core/compress.js +0 -76
  83. package/dist/core/compress.js.map +0 -1
  84. package/dist/core/describe.js +0 -49
  85. package/dist/core/describe.js.map +0 -1
  86. package/dist/core/errors.js +0 -469
  87. package/dist/core/errors.js.map +0 -1
  88. package/dist/core/execute-jobs.js +0 -122
  89. package/dist/core/execute-jobs.js.map +0 -1
  90. package/dist/core/formats.js +0 -108
  91. package/dist/core/formats.js.map +0 -1
  92. package/dist/core/order.js +0 -44
  93. package/dist/core/order.js.map +0 -1
  94. package/dist/core/output-path.js +0 -176
  95. package/dist/core/output-path.js.map +0 -1
  96. package/dist/core/pages.js +0 -107
  97. package/dist/core/pages.js.map +0 -1
  98. package/dist/core/pdf-compress.js +0 -206
  99. package/dist/core/pdf-compress.js.map +0 -1
  100. package/dist/core/plan.js +0 -42
  101. package/dist/core/plan.js.map +0 -1
  102. package/dist/core/resolve.js +0 -115
  103. package/dist/core/resolve.js.map +0 -1
  104. package/dist/core/run.js +0 -66
  105. package/dist/core/run.js.map +0 -1
  106. package/dist/core/suggest.js +0 -50
  107. package/dist/core/suggest.js.map +0 -1
  108. package/dist/core/types.js +0 -2
  109. package/dist/core/types.js.map +0 -1
  110. package/dist/core/units.js +0 -94
  111. package/dist/core/units.js.map +0 -1
  112. package/dist/core/write-safety.js +0 -128
  113. package/dist/core/write-safety.js.map +0 -1
  114. package/dist/engines/heic.js +0 -166
  115. package/dist/engines/heic.js.map +0 -1
  116. package/dist/engines/image.js +0 -342
  117. package/dist/engines/image.js.map +0 -1
  118. package/dist/engines/pdf.js +0 -444
  119. package/dist/engines/pdf.js.map +0 -1
  120. package/dist/engines/pdfium.js +0 -161
  121. package/dist/engines/pdfium.js.map +0 -1
  122. package/dist/engines/registry.js +0 -65
  123. package/dist/engines/registry.js.map +0 -1
  124. package/dist/engines/types.js +0 -2
  125. package/dist/engines/types.js.map +0 -1
  126. package/dist/engines/word.js +0 -385
  127. package/dist/engines/word.js.map +0 -1
  128. package/dist/index.js.map +0 -1
  129. package/dist/shell/App.js +0 -1972
  130. package/dist/shell/App.js.map +0 -1
  131. package/dist/shell/ClickTargets.js +0 -183
  132. package/dist/shell/ClickTargets.js.map +0 -1
  133. package/dist/shell/ThemeContext.js +0 -21
  134. package/dist/shell/ThemeContext.js.map +0 -1
  135. package/dist/shell/blocks.js +0 -160
  136. package/dist/shell/blocks.js.map +0 -1
  137. package/dist/shell/clipboard.js +0 -64
  138. package/dist/shell/clipboard.js.map +0 -1
  139. package/dist/shell/commands.js +0 -51
  140. package/dist/shell/commands.js.map +0 -1
  141. package/dist/shell/components/Banner.js +0 -73
  142. package/dist/shell/components/Banner.js.map +0 -1
  143. package/dist/shell/components/CommandPalette.js +0 -37
  144. package/dist/shell/components/CommandPalette.js.map +0 -1
  145. package/dist/shell/components/FileCard.js +0 -59
  146. package/dist/shell/components/FileCard.js.map +0 -1
  147. package/dist/shell/components/HintBar.js +0 -18
  148. package/dist/shell/components/HintBar.js.map +0 -1
  149. package/dist/shell/components/Hints.js +0 -21
  150. package/dist/shell/components/Hints.js.map +0 -1
  151. package/dist/shell/components/MergeList.js +0 -268
  152. package/dist/shell/components/MergeList.js.map +0 -1
  153. package/dist/shell/components/ModeHeader.js +0 -21
  154. package/dist/shell/components/ModeHeader.js.map +0 -1
  155. package/dist/shell/components/PageGrid.js +0 -324
  156. package/dist/shell/components/PageGrid.js.map +0 -1
  157. package/dist/shell/components/PathInput.js +0 -147
  158. package/dist/shell/components/PathInput.js.map +0 -1
  159. package/dist/shell/components/Progress.js +0 -43
  160. package/dist/shell/components/Progress.js.map +0 -1
  161. package/dist/shell/components/Prompt.js +0 -667
  162. package/dist/shell/components/Prompt.js.map +0 -1
  163. package/dist/shell/components/ResultLinks.js +0 -26
  164. package/dist/shell/components/ResultLinks.js.map +0 -1
  165. package/dist/shell/components/Select.js +0 -152
  166. package/dist/shell/components/Select.js.map +0 -1
  167. package/dist/shell/components/Slider.js +0 -48
  168. package/dist/shell/components/Slider.js.map +0 -1
  169. package/dist/shell/components/StagedFiles.js +0 -92
  170. package/dist/shell/components/StagedFiles.js.map +0 -1
  171. package/dist/shell/components/ThemePicker.js +0 -18
  172. package/dist/shell/components/ThemePicker.js.map +0 -1
  173. package/dist/shell/components/UnitRow.js +0 -30
  174. package/dist/shell/components/UnitRow.js.map +0 -1
  175. package/dist/shell/flows/pdf.js +0 -424
  176. package/dist/shell/flows/pdf.js.map +0 -1
  177. package/dist/shell/frame-geometry.js +0 -56
  178. package/dist/shell/frame-geometry.js.map +0 -1
  179. package/dist/shell/hyperlink.js +0 -27
  180. package/dist/shell/hyperlink.js.map +0 -1
  181. package/dist/shell/intro.js +0 -101
  182. package/dist/shell/intro.js.map +0 -1
  183. package/dist/shell/launch.js +0 -75
  184. package/dist/shell/launch.js.map +0 -1
  185. package/dist/shell/mark.js +0 -134
  186. package/dist/shell/mark.js.map +0 -1
  187. package/dist/shell/mouse.js +0 -209
  188. package/dist/shell/mouse.js.map +0 -1
  189. package/dist/shell/redraw.js +0 -36
  190. package/dist/shell/redraw.js.map +0 -1
  191. package/dist/shell/reveal.js +0 -24
  192. package/dist/shell/reveal.js.map +0 -1
  193. package/dist/shell/stage.js +0 -34
  194. package/dist/shell/stage.js.map +0 -1
  195. package/dist/shell/terminal-write.js +0 -16
  196. package/dist/shell/terminal-write.js.map +0 -1
  197. package/dist/shell/theme.js +0 -178
  198. package/dist/shell/theme.js.map +0 -1
  199. package/dist/shell/useFrameOrigin.js +0 -175
  200. package/dist/shell/useFrameOrigin.js.map +0 -1
  201. package/dist/shell/useKeys.js +0 -28
  202. package/dist/shell/useKeys.js.map +0 -1
  203. package/dist/shell/useMouse.js +0 -150
  204. package/dist/shell/useMouse.js.map +0 -1
  205. package/dist/shell/useMouseRouting.js +0 -69
  206. package/dist/shell/useMouseRouting.js.map +0 -1
  207. package/dist/shell/width.js +0 -62
  208. package/dist/shell/width.js.map +0 -1
  209. package/dist/utils/display-path.js +0 -31
  210. package/dist/utils/display-path.js.map +0 -1
  211. package/dist/utils/unescape-path.js +0 -68
  212. package/dist/utils/unescape-path.js.map +0 -1
@@ -0,0 +1,10 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{b as h,c as b,d as A,e as F,f as x,g as w,h as R}from"./chunk-QVACE4IE.js";import{i as M}from"./chunk-L76Q54MB.js";import{i as L,j as O,m as j}from"./chunk-YXDEOLNA.js";import{d as k,g as C,p as v,r as I,x as S}from"./chunk-PD5DFBCU.js";var D=[[15,"rose"],[45,"red"],[70,"orange"],[95,"amber"],[120,"yellow"],[140,"lime"],[165,"green"],[185,"teal"],[215,"cyan"],[250,"sky"],[280,"blue"],[295,"indigo"],[315,"violet"],[340,"purple"],[355,"pink"],[360,"rose"]];function T(t){let{C:e,h:r}=x(b(t));return e<.03?"grey":(D.find(([n])=>r<n)??[360,"rose"])[1]}var d=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),z=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"colour",$='font-family="Inter"';function P(t,e,r,n="light"){let o=n==="dark",i=o?"#FAFAFA":"#111111",s=o?"#A1A1AA":"#71717A",c=o?"#FFFFFF":"#000000",a=r.length>8?64:104,l=10,g=48+r.length*a+Math.max(0,r.length-1)*l,m=84+a+56,p=a>80?12:10,f=`<text id="title" x="24" y="38" ${$} font-size="15" font-weight="600" fill="${i}">${d(t)}</text><text id="subtitle" x="24" y="58" ${$} font-size="12" fill="${s}">${d(e)}</text>`,U=r.map((u,W)=>`<g id="${z(u.id)}" transform="translate(${24+W*(a+l)} 80)"><rect id="swatch" width="${a}" height="${a}" rx="${p}" fill="${u.hex}" stroke="${c}" stroke-opacity="0.08"/><text id="name" x="1" y="${a+22}" ${$} font-size="13" font-weight="600" fill="${i}">${d(u.name)}</text><text id="value" x="1" y="${a+40}" ${$} font-size="11" fill="${s}">${d(u.value)}</text></g>`).join(`
4
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${g}" height="${m}" viewBox="0 0 ${g} ${m}">
5
+ <g id="${z(t)}">
6
+ <rect id="card" width="${g}" height="${m}" rx="0" fill="${o?"#18181B":"#FFFFFF"}"/>
7
+ ${f}
8
+ ${U}
9
+ </g>
10
+ </svg>`}function Z(t,e,r="light",n){let o=t.replace(/\.[^.]+$/,""),i=e.length;return P(t,n?`${i} shade${i===1?"":"s"} of ${n}`:`${i} colour${i===1?"":"s"}, most of the image first`,e.map((s,c)=>({id:`${o}-${c+1}`,name:s.hex,value:R(s.rgb),hex:s.hex})),r)}function _(t,e,r="light"){let n=T(t);return P(`${n[0]?.toUpperCase()??""}${n.slice(1)}`,`from ${h(t)} \xB7 50\u2013950 in OKLCH`,e.map(o=>({id:`${n}-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),r)}var y=t=>{let e=t/255;return e<=.04045?e/12.92:((e+.055)/1.055)**2.4},B=({r:t,g:e,b:r})=>.2126*y(t)+.7152*y(e)+.0722*y(r);function E(t,e){let[r,n]=[B(t),B(e)].sort((o,i)=>i-o);return(r+.05)/(n+.05)}function et(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"large":"fails"}var G={r:255,g:255,b:255},N={r:0,g:0,b:0},H=t=>Math.floor(t*10)/10;function rt(t){return{white:H(E(t,G)),black:H(E(t,N))}}var K=[50,100,200,300,400,500,600,700,800,900,950],q=[1,.86,.68,.46,.22],J=[.2,.4,.6,.8,1];function it(t){let{L:e,C:r,h:n}=x(b(t)),o=r<.015,i=Math.max(.975,e),s=e<.16?.42*e:Math.max(.16,.42*e);return K.map((c,a)=>{if(a===5)return{step:c,rgb:{...t},hex:h(t),reference:!0};let l=a<5,g=l?q[a]:J[a-6],m=l?e+(i-e)*g:e-(e-s)*g,p=o?0:r*(l?1-.88*g:1-.45*g);for(;p>0&&!F(w({L:m,C:p,h:n}));)p-=.002;let f=A(w({L:m,C:Math.max(0,p),h:n}));return{step:c,rgb:f,hex:h(f),reference:!1}})}async function pt(t,e=192){let r=await M(t);if(r.kind!=="image")throw v(t,`a ${k[r.format].label}`);let n=r.format==="heic";if(n&&!await L())throw I(t);let o=n?await O(t):void 0;try{let s=(await j())(o?.path??t,{animated:!1}),{data:c,info:a}=await(n?s:s.rotate()).resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:r,pixels:{width:a.width,height:a.height,rgba:new Uint8Array(c.buffer,c.byteOffset,c.length)}}}catch(i){throw C(i)?i:S(t,i)}finally{await o?.cleanup()}}export{Z as a,_ as b,et as c,rt as d,it as e,pt as f};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as m}from"./chunk-4YCO7S4K.js";import{S as l}from"./chunk-PD5DFBCU.js";import{randomBytes as h}from"node:crypto";import{link as y,mkdir as p,readdir as x,readFile as P,rename as E,rm as c,stat as L,writeFile as S}from"node:fs/promises";import{join as u}from"node:path";var b=720*60*1e3,k=600*1e3,M=200,F=600*1e3;function a(){return u(m(),".locks")}function f(t){return u(a(),`${t}.lock`)}function v(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function s(t){try{let n=JSON.parse(await P(t,"utf8"));return typeof n.pid!="number"||typeof n.token!="string"?void 0:n}catch{return}}async function d(t,n){if(n===void 0||!v(n.pid))return!0;let e=await L(t).catch(()=>{});return e!==void 0&&Date.now()-e.mtimeMs>b}async function D(t){let n=`${t}.stale-${h(4).toString("hex")}`;try{await E(t,n)}catch{return}let e=await s(n);e!==void 0&&!await d(n,e)&&await y(n,t).catch(()=>{}),await c(n,{force:!0})}async function A(){let t=await x(a()).catch(()=>[]);for(let n of t){if(!/\.lock\.(stale-)?[0-9a-f]+$/.test(n))continue;let e=u(a(),n),i=await L(e).catch(()=>{});i&&Date.now()-i.mtimeMs>F&&await c(e,{force:!0})}}async function g(t,n){await p(a(),{recursive:!0});let e=f(t),i={pid:process.pid,token:h(8).toString("hex"),at:Date.now(),...n!==void 0?{what:n}:{}},r=`${e}.${i.token}`;await S(r,JSON.stringify(i),{flag:"wx"});try{for(let o=0;o<2;o++){try{return await y(r,e),i}catch(w){if(w.code!=="EEXIST")throw w}if(!await d(e,await s(e)))return;await D(e)}return}finally{await c(r,{force:!0})}}async function T(t,n){let e=f(t);(await s(e))?.token===n.token&&await c(e,{force:!0})}async function _(t){let n=f(t),e=await s(n);if(!(e===void 0||await d(n,e)))return{pid:e.pid,...e.what!==void 0?{what:e.what}:{}}}async function H(t,n,e={}){let i=Date.now()+(e.waitMs??k);await p(a(),{recursive:!0}),await A();let r=await g(t,e.what);for(r===void 0&&(e.waitMs??k)>0&&e.onWait?.();r===void 0;){if(e.signal?.aborted)throw e.signal.reason??new Error("aborted");if(Date.now()>=i)throw l(t,await _(t),e.action??"run");await new Promise(o=>setTimeout(o,M)),r=await g(t,e.what)}try{return await n()}finally{await T(t,r)}}export{k as a,_ as b,H as c};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{E as G,F as b,G as Q,I as M,N as V,V as Z,W as Y,X as ee,Y as R,c as F,d as m,g as A,h as H,i as C,j as P,k as W,l as q,m as J,n as X,o as j,r as y,x as K,y as T}from"./chunk-PD5DFBCU.js";import{randomBytes as Me}from"node:crypto";import{constants as Re}from"node:fs";import{access as ke,readFile as se,rename as De,rm as Le,stat as Ne,writeFile as Ue}from"node:fs/promises";import{basename as $e,dirname as _e,join as He}from"node:path";import{randomBytes as me}from"node:crypto";import{constants as pe}from"node:fs";import{access as he,mkdir as ue,rename as le,rm as ge,writeFile as we}from"node:fs/promises";import{dirname as ye}from"node:path";async function I(e){let r=ye(e);try{await ue(r,{recursive:!0})}catch(t){let i=b(e,t);throw i===t?Q(e,t):i}try{await he(r,pe.W_OK)}catch(t){throw G(e,t)}}async function it(e,r){await I(e);let t=`${e}.${me(6).toString("hex")}.tmp`;try{return await we(t,r),await le(t,e),r.byteLength}catch(i){throw await ge(t,{force:!0}).catch(()=>{}),b(e,i)}}function st(e){if(m[e].hasAlpha)return;let r=Object.keys(m).filter(t=>m[t].hasAlpha&&t!=="heic").join(", ");return M(`${m[e].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${r}.`)}var te="1.1.0";function be(e,r){let t=e.split(".").map(n=>Number.parseInt(n,10)||0),i=r.split(".").map(n=>Number.parseInt(n,10)||0);for(let n=0;n<Math.max(t.length,i.length);n++){let a=(t[n]??0)-(i[n]??0);if(a!==0)return a>0}return!0}function k(e){return e!==void 0&&be(e,te)?[2,3,4]:[2,4]}function ct(e,r,t){if(e===1||k(r).some(n=>n===e))return;if(t!==void 0&&k(t).some(n=>n===e))return V("boost",`boost ${e}\xD7`,r,te);let i=k(r).map(n=>`--boost ${n}`);return M(`No released boost makes ${e}\xD7 yet.`,`Try ${i.slice(0,-1).join(", ")} or ${i.at(-1)}.`)}var xe=16384,Se=1e8;function re(e,r,t){let i=Math.max(e,r)*t;if(i>xe)return{side:i};let n=e*t*r*t;if(n>Se)return{megapixels:Math.round(n/1e6)}}var w=e=>Math.max(1,Math.round(e));function D(e,r){return"percent"in r?{width:w(e.width*r.percent/100),height:w(e.height*r.percent/100)}:"width"in r?{width:w(r.width),height:w(e.height*r.width/e.width)}:{width:w(e.width*r.height/e.height),height:w(r.height)}}function ie(e){return re(e.width,e.height,1)}import{execFile as Ie}from"node:child_process";import{randomBytes as ve}from"node:crypto";import{open as ne,rm as Ee}from"node:fs/promises";import{tmpdir as Oe}from"node:os";import{join as ze}from"node:path";import{promisify as Be}from"node:util";var L=Be(Ie),x;async function S(){if(x!==void 0)return x;try{await L("/usr/bin/sips",["--help"],{timeout:5e3}),x=!0}catch{x=!1}return x}async function E(e){let r=ze(Oe(),`forge-heic-${ve(8).toString("hex")}.png`),t=async()=>{await Ee(r,{force:!0}).catch(()=>{})};try{return await L("/usr/bin/sips",["-s","format","png",e,"--out",r],{timeout:12e4}),{path:r,cleanup:t}}catch(i){throw await t(),i}}var Fe=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),Ae=new Set(["avif","avis"]);async function ae(e){let r;try{r=await ne(e,"r")}catch{return!1}try{let t=Buffer.alloc(64),{bytesRead:i}=await r.read(t,0,64,0);if(i<12||t.toString("latin1",4,8)!=="ftyp")return!1;let n=Math.min(t.readUInt32BE(0),i),a=[];for(let o=8;o+4<=n;o+=4)a.push(t.toString("latin1",o,o+4));return a.some(o=>Ae.has(o))?!1:a.some(o=>Fe.has(o))}catch{return!1}finally{await r.close().catch(()=>{})}}async function oe(e){let{stdout:r}=await L("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",e],{timeout:3e4}),t=Number(/pixelWidth:\s*(\d+)/.exec(r)?.[1]??0),i=Number(/pixelHeight:\s*(\d+)/.exec(r)?.[1]??0),n=await Pe(e);return{width:n?i:t,height:n?t:i,hasAlpha:/hasAlpha:\s*yes/i.test(r)}}function*v(e,r,t){let i=r;for(;i+8<=t;){let n=e.readUInt32BE(i),a=8;if(n===1&&i+16<=t?(n=Number(e.readBigUInt64BE(i+8)),a=16):n===0&&(n=t-i),n<a)return;yield{type:e.toString("latin1",i+4,i+8),start:i+a,end:Math.min(i+n,t)},i+=n}}async function Pe(e){let r=await ne(e,"r");try{let t=Buffer.alloc(262144),{bytesRead:i}=await r.read(t,0,t.length,0),n=[...v(t,0,i)].find(c=>c.type==="meta");if(!n)return!1;let a=[...v(t,n.start+4,n.end)],o=a.find(c=>c.type==="pitm"),l=a.find(c=>c.type==="iprp");if(!o||!l)return!1;let g=t.readUInt8(o.start)===0?t.readUInt16BE(o.start+4):t.readUInt32BE(o.start+4),s=[...v(t,l.start,l.end)],h=s.find(c=>c.type==="ipco"),f=s.find(c=>c.type==="ipma");if(!h||!f)return!1;let p=new Map;if([...v(t,h.start,h.end)].forEach((c,B)=>{c.type==="irot"&&p.set(B+1,t.readUInt8(c.start)&3)}),p.size===0)return!1;let U=t.readUInt8(f.start),$=(t.readUInt8(f.start+3)&1)===1,d=f.start+4,ce=t.readUInt32BE(d);d+=4;for(let c=0;c<ce&&d<f.end;c++){let B=U<1?t.readUInt16BE(d):t.readUInt32BE(d);d+=U<1?2:4;let fe=t.readUInt8(d);d+=1;for(let _=0;_<fe;_++){let de=$?t.readUInt16BE(d)&32767:t.readUInt8(d)&127;if(d+=$?2:1,B===g&&(p.get(de)??0)%2===1)return!0}}return!1}catch{return!1}finally{await r.close().catch(()=>{})}}function u(e){let r;return()=>(r??=e(),r)}var O=u(async()=>(await import("sharp")).default),bt=u(()=>import("./es-T2U7NBLD.js")),xt=u(()=>import("@hyzyla/pdfium")),St=u(async()=>(await import("./lib-TPEJ5CJJ.js")).default),It=u(async()=>(await import("./word-OGQ2KZAJ.js")).default),vt=u(async()=>(await import("./adm-zip-SQKLKBDP.js")).default),Et=u(async()=>(await import("./cfb-V6M2PYOD.js")).default);async function Te(){let e=Object.getOwnPropertyDescriptor(globalThis,"localStorage");if(!e?.configurable)return import("./dist-J2V6ITHG.js");Object.defineProperty(globalThis,"localStorage",{value:void 0,configurable:!0,enumerable:e.enumerable??!1,writable:!0});try{return await import("./dist-J2V6ITHG.js")}finally{Object.defineProperty(globalThis,"localStorage",e)}}var Ot=u(Te);var Ce=new Set(["jpeg","png","webp","avif","heic","gif","tiff"]),We=new Set(["jpeg","png","webp","avif","gif","tiff"]),qe={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function Je(e,r){if(r.format==="heif")return r.compression==="av1"?"avif":"heic";let t=qe[r.format??""];if(!t)throw j(e,r.format??"an unknown format");return t}async function Xe(e){let r;try{r=await Ne(e)}catch(n){let a=n.code;throw a==="ENOENT"?H(e):a==="EACCES"||a==="EPERM"?P(e):a==="ENOTDIR"?W(e):a==="ELOOP"?q(e):a==="ENAMETOOLONG"?J(e):X(e,n)}if(!r.isFile())throw C(e);try{await ke(e,Re.R_OK)}catch{throw P(e)}if(await ae(e)){if(!await S())throw y(e);let n;try{n=await oe(e)}catch(a){throw T(e,"heic",a)}if(n.width===0||n.height===0)throw T(e,"heic",void 0);return{kind:"image",path:e,format:"heic",width:n.width,height:n.height,bytes:r.size,hasAlpha:n.hasAlpha,frames:1}}let t=await O(),i;try{i=await t(e).metadata()}catch(n){throw K(e,n)}return{kind:"image",path:e,format:Je(e,i),width:i.autoOrient?.width??i.width??0,height:i.autoOrient?.height??i.height??0,bytes:r.size,hasAlpha:i.hasAlpha??!1,frames:i.pages??1}}function N(e,r,t){let i=t??m[r].defaultQuality;switch(r){case"jpeg":return e.jpeg({quality:i,mozjpeg:!0});case"webp":return e.webp({quality:i});case"avif":return e.avif({quality:i});case"png":return e.png({compressionLevel:9});case"gif":return e.gif();case"tiff":return e.tiff({compression:"deflate"});case"heic":throw new Error("heic is not writable; the capability graph should have prevented this");case"pdf":throw new Error("pdf is not an image target; the capability graph should have prevented this");case"docx":throw new Error("docx is not an image target; the capability graph should have prevented this");case"doc":throw new Error("doc is not an image target; the capability graph should have prevented this")}}async function je(e,r){let t=_e(r);await I(r);let i=He(t,`.forge-tmp-${Me(6).toString("hex")}-${$e(r)}`);try{return await Ue(i,e),await De(i,r),e.length}catch(n){throw await Le(i,{force:!0}).catch(()=>{}),b(r,n)}}async function z(e,r,t,i,n,a){if(e.kind!=="image")throw new Error("pipelineFor received a non-image source");if(n===void 0&&e.format==="heic"&&!await S())throw y(e.path);let o=n===void 0&&e.format==="heic"?await E(e.path):void 0,l=async()=>{await o?.cleanup()},s=(await O())(n??o?.path??e.path,i?{animated:!0}:{});if(s=s.rotate(),t.trim&&(s=s.trim()),t.resize){if(!a&&t.trim)throw new Error("pipelineFor needs the resolved size to resize a trimmed image");let h=a??D(e,t.resize);s=s.resize(h.width,h.height,{fit:"fill"})}return e.hasAlpha&&!m[r].hasAlpha&&(s=s.flatten({background:t.background})),s=t.keepMetadata?s.keepMetadata():s.keepIccProfile(),{pipeline:s,cleanup:l}}async function Ut(e,r){let t={background:"#ffffff",keepMetadata:!1},{pipeline:i,cleanup:n}=await z(e,"png",t,!1);try{await i.png({compressionLevel:1}).toFile(r)}finally{await n()}}async function $t(e,r,t){let{pipeline:i,cleanup:n}=await z(e,r,t,!1);try{return await N(i,r,t.quality).toBuffer()}finally{await n()}}async function Ke(e){let r={width:e.width,height:e.height};if(e.frames>1)return{upright:r,trimmed:"animated"};if(e.format==="heic"&&!await S())throw y(e.path);let t=e.format==="heic"?await E(e.path):void 0;try{let i=await O(),{info:n}=await i(t?.path??e.path).rotate().trim().jpeg({quality:1}).toBuffer({resolveWithObject:!0});return n.width===r.width&&n.height===r.height?{upright:r,trimmed:"nothing"}:{upright:r,trimmed:{width:n.width,height:n.height}}}catch(i){throw A(i)?i:R(e.path,i)}finally{await t?.cleanup()}}async function Ge(e,r){if(e.op!=="convert")throw new Error(`image engine cannot ${e.op}`);let t=e.sources[0],i=e.outputs[0];if(t.kind!=="image")throw new Error("the image engine cannot convert a document source");let n=m[e.target],a=[];r({phase:"reading"});let o=t.frames>1,l=o&&n.animatable;o&&!n.animatable&&a.push({code:"animation-flattened",message:`${F(t.path)} has ${t.frames} frames, and ${n.label} cannot animate. Only the first frame was converted.`});let g;if(e.options.trim||e.options.resize){let f={width:t.width,height:t.height};if(e.options.trim){if(o)throw ee(t.path);let{trimmed:p}=await Ke(t);if(p==="nothing"){if(!e.options.resize)throw Y(t.path);a.push({code:"nothing-trimmed",message:`${F(t.path)} has no empty edges; resized only.`})}else p!=="animated"&&(f=p)}if(e.options.resize&&(g=D(f,e.options.resize),ie(g)))throw Z(t.path,g)}r({phase:"decoding"});let{pipeline:s,cleanup:h}=await z(t,e.target,e.options,l,void 0,g);try{await I(i),r({phase:"encoding"});let f=await N(s,e.target,e.options.quality).toBuffer();r({phase:"writing"});let p=await je(f,i);return{job:e,outputBytes:p,warnings:a}}catch(f){throw A(f)?f:R(t.path,f)}finally{await h()}}async function Qe(e){if(e.format!=="heic")return se(e.path);if(!await S())throw y(e.path);let r=await E(e.path);try{return await se(r.path)}finally{await r.cleanup()}}async function Ve(e){if(e.op!=="convert"||!m[e.target].lossy)return;let r=e.sources[0];if(r.kind!=="image")return;let t=await Qe(r);return{ladder:[{}],measure:async i=>{let{pipeline:n}=await z(r,e.target,i,!1,t);return(await N(n,e.target,i.quality).toBuffer()).length}}}var _t={id:"image",reads:Ce,writes:We,ops:new Set(["convert"]),probe:Xe,run:Ge,measurer:Ve};export{st as a,k as b,ct as c,xe as d,re as e,it as f,D as g,ie as h,S as i,E as j,ae as k,u as l,O as m,bt as n,xt as o,St as p,It as q,vt as r,Et as s,Ot as t,N as u,je as v,Ut as w,$t as x,Ke as y,_t as z};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as $,b as S,c as u,d as k,e as O,f as C}from"./chunk-VH5RWPGZ.js";import{c as w,d as I,f as y}from"./chunk-PBIS2ONZ.js";import{a as h,b as g}from"./chunk-PN73WK2S.js";import{b as m,c as d,h as f,i as p}from"./chunk-QVACE4IE.js";import"./chunk-L76Q54MB.js";import{a as l}from"./chunk-G2D6BKOS.js";import"./chunk-YXDEOLNA.js";import{c as b,q as x}from"./chunk-PD5DFBCU.js";import"./chunk-J7FLFHQJ.js";import"./chunk-TMUK2DD3.js";import{resolve as R}from"node:path";var P=({r:t,g:n,b:o},s)=>s?`\x1B[38;2;${t};${n};${o}m\u2588\u2588\x1B[39m `:"";function N(t,n){let o=d(n),s,e=Number.POSITIVE_INFINITY;for(let r of t){let a=(r.centre.L-o.L)**2+(r.centre.a-o.a)**2+(r.centre.b-o.b)**2;a<e&&(e=a,s=r)}return s}async function D(t,n){let{pixels:o}=await C(t.input),s=w(o);if(s.length===0)throw x(t.input);let e=t.inside?N(s,t.inside):void 0,r=e?I(o,e):s;if(t.svg)return{exitCode:0,stdout:[$(b(t.input),r,"light",e?.hex)],stderr:[]};if(n.json){let i=h(l,{source:R(t.input),...e?{inside:e.hex}:{},colours:r.map(c=>({hex:c.hex,rgb:f(c.rgb),oklch:p(c.rgb),share:c.share}))});return{exitCode:0,stdout:[JSON.stringify(i)],stderr:[]}}let a=y(r.map(i=>i.share));return{exitCode:0,stdout:r.map((i,c)=>`${P(i.rgb,n.colour)}${i.hex} ${String(a[c]).padStart(3)}%`),stderr:[]}}async function H(t,n){let o=O(t.colour);if(t.svg)return{exitCode:0,stdout:[S(t.colour,o)],stderr:[]};let s=o.map(e=>({...e,...k(e.rgb)}));if(n.json){let e=g(l,{reference:m(t.colour),steps:s.map(r=>({step:r.step,hex:r.hex,oklch:p(r.rgb),white:r.white,black:r.black}))});return{exitCode:0,stdout:[JSON.stringify(e)],stderr:[]}}return{exitCode:0,stdout:s.map(e=>`${String(e.step).padStart(4)} ${P(e.rgb,n.colour)}${e.hex} white ${e.white.toFixed(1)} ${u(e.white)} \xB7 black ${e.black.toFixed(1)} ${u(e.black)}`),stderr:[]}}export{D as runPalette,H as runScale};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a,b}from"./chunk-HUAEVW2A.js";import"./chunk-EOYBXOCV.js";import"./chunk-PD5DFBCU.js";import"./chunk-J7FLFHQJ.js";import"./chunk-TMUK2DD3.js";export{a as CONFIG_KEYS,b as runConfig};