forge-terminal 0.5.8 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -12
- package/dist/chunks/{about-credits-PQSIWSE2.js → about-credits-XL2AIGQ7.js} +1 -1
- package/dist/chunks/args-PS5SVBZY.js +3 -0
- package/dist/chunks/boot-QRKC4QBA.js +3 -0
- package/dist/chunks/check-HOITNMJX.js +3 -0
- package/dist/chunks/{chunk-6RCS3KBP.js → chunk-2JU3YZQU.js} +1 -1
- package/dist/chunks/{chunk-Q6KQWJ4J.js → chunk-2L66A2X6.js} +1 -1
- package/dist/chunks/chunk-2OSM4W4D.js +3 -0
- package/dist/chunks/{chunk-XGG3NYQN.js → chunk-3HG7RXC2.js} +1 -1
- package/dist/chunks/chunk-3IX3QA76.js +3 -0
- package/dist/chunks/chunk-3SVHRKQH.js +6 -0
- package/dist/chunks/chunk-4MZV4SRU.js +4 -0
- package/dist/chunks/chunk-4NDZTK22.js +3 -0
- package/dist/chunks/{chunk-7XFLG32B.js → chunk-5FJT4BNY.js} +1 -1
- package/dist/chunks/chunk-5XJCMMCM.js +3 -0
- package/dist/chunks/chunk-65Y7YCZZ.js +3 -0
- package/dist/chunks/{chunk-WBW6G4N6.js → chunk-6HUYBVQA.js} +1 -1
- package/dist/chunks/chunk-BSFBZBAI.js +16 -0
- package/dist/chunks/chunk-BWJNZT75.js +6 -0
- package/dist/chunks/{chunk-WE6KP4FR.js → chunk-BYUOU2Q2.js} +1 -1
- package/dist/chunks/chunk-CCNRNCRU.js +3 -0
- package/dist/chunks/chunk-ECA4PW5T.js +3 -0
- package/dist/chunks/chunk-EIPMQFIF.js +3 -0
- package/dist/chunks/chunk-EJWTYDBJ.js +3 -0
- package/dist/chunks/chunk-EYOO35US.js +3 -0
- package/dist/chunks/chunk-FGR6QCG5.js +3 -0
- package/dist/chunks/chunk-FWVE3GNA.js +3 -0
- package/dist/chunks/{chunk-ILQDMVJR.js → chunk-FXA45V4B.js} +1 -1
- package/dist/chunks/chunk-G6L5NIJ5.js +19 -0
- package/dist/chunks/chunk-GIG4I2IC.js +23 -0
- package/dist/chunks/chunk-HXKLYK3M.js +7 -0
- package/dist/chunks/chunk-I2LPGKUU.js +3 -0
- package/dist/chunks/chunk-JD3RB6IV.js +66 -0
- package/dist/chunks/{chunk-W53XNVNH.js → chunk-JUA63KQK.js} +1 -1
- package/dist/chunks/{chunk-4KGC5ZBZ.js → chunk-NLM2SP3F.js} +1 -1
- package/dist/chunks/chunk-NMGQGYVM.js +3 -0
- package/dist/chunks/chunk-NUCGWLOY.js +8 -0
- package/dist/chunks/{chunk-SM735FG7.js → chunk-NUTTDNTG.js} +1 -1
- package/dist/chunks/chunk-PA7AG2NK.js +55 -0
- package/dist/chunks/{chunk-KTCHWHQB.js → chunk-PISCJKIG.js} +1 -1
- package/dist/chunks/chunk-PON65UTS.js +3 -0
- package/dist/chunks/chunk-QIMSNTKL.js +3 -0
- package/dist/chunks/{chunk-4MJEEEFA.js → chunk-QO4JUY6B.js} +1 -1
- package/dist/chunks/chunk-QPUKPSPZ.js +3 -0
- package/dist/chunks/{chunk-JI7YY44M.js → chunk-S7BZPV5T.js} +1 -1
- package/dist/chunks/chunk-SFN3LBB6.js +3 -0
- package/dist/chunks/{chunk-OXDRJO4V.js → chunk-TNIPRV6K.js} +1 -1
- package/dist/chunks/{chunk-SZRSAL64.js → chunk-UEAZTRTL.js} +1 -1
- package/dist/chunks/chunk-UI4EUC3S.js +3 -0
- package/dist/chunks/chunk-UN5DSJE2.js +3 -0
- package/dist/chunks/chunk-UUTBDIFR.js +3 -0
- package/dist/chunks/chunk-WID72ZII.js +4 -0
- package/dist/chunks/chunk-X2YUHPOU.js +4 -0
- package/dist/chunks/chunk-X4QI2EYV.js +3 -0
- package/dist/chunks/chunk-YBA6DJQ4.js +3 -0
- package/dist/chunks/chunk-YJZEHJ6U.js +3 -0
- package/dist/chunks/chunk-YYZYZWF5.js +80 -0
- package/dist/chunks/clip-command-4ON3Q57W.js +3 -0
- package/dist/chunks/clipboard-W67Q22JG.js +3 -0
- package/dist/chunks/colour-2BGK2BFR.js +3 -0
- package/dist/chunks/command-ZX3L5VFO.js +3 -0
- package/dist/chunks/config-command-VEGQPXVB.js +3 -0
- package/dist/chunks/continue-editing-LTMIEFRD.js +3 -0
- package/dist/chunks/decoded-SK6W44WW.js +3 -0
- package/dist/chunks/{entry-HGEJC7CZ.js → entry-3R2GK3IW.js} +2 -2
- package/dist/chunks/execute-TC3QZ6GL.js +3 -0
- package/dist/chunks/extensions-3SG2LW7R.js +3 -0
- package/dist/chunks/{extensions-command-65QEMN2L.js → extensions-command-RNAPQYWV.js} +1 -1
- package/dist/chunks/ffmpeg-G4TRWUTV.js +3 -0
- package/dist/chunks/image-67XO45NW.js +3 -0
- package/dist/chunks/install-UN3YGSJW.js +3 -0
- package/dist/chunks/{install-KGFOAQCU.js → install-X7EEH5CQ.js} +1 -1
- package/dist/chunks/launch-EGFNGHLN.js +18 -0
- package/dist/chunks/lock-5ZO5PCZP.js +3 -0
- package/dist/chunks/manager-272REVNF.js +4 -0
- package/dist/chunks/{needed-6GCBKP3S.js → needed-7IUPDEJB.js} +1 -1
- package/dist/chunks/notify-UD7FQAWX.js +3 -0
- package/dist/chunks/{own-KMIT2CXF.js → own-5BD5BVE7.js} +1 -1
- package/dist/chunks/pdfium-MHPBLZY5.js +3 -0
- package/dist/chunks/preferences-E2CH2YSG.js +3 -0
- package/dist/chunks/preset-command-5I3NZ2OP.js +3 -0
- package/dist/chunks/registry-DWFV4GBG.js +3 -0
- package/dist/chunks/{run-GUFPETHF.js → run-3DX3SROY.js} +1 -1
- package/dist/chunks/server-TF32DQEO.js +81 -0
- package/dist/chunks/signals-QSXY3F2A.js +3 -0
- package/dist/chunks/text-layer-PFIDCTEL.js +5 -0
- package/dist/chunks/theme-4Y66DDAO.js +3 -0
- package/dist/chunks/transcribe-HH5P3PV4.js +3 -0
- package/dist/chunks/transcribe-command-VY5HYNXV.js +3 -0
- package/dist/chunks/update-command-6VVDG75Y.js +3 -0
- package/dist/chunks/update-note-XV2T2NNG.js +3 -0
- package/dist/chunks/watch-command-BMSMGIHK.js +3 -0
- package/dist/helpers/forge-transcribe +0 -0
- package/dist/index.js +16 -15
- package/package.json +17 -5
- package/dist/chunks/args-J5JEHQLE.js +0 -3
- package/dist/chunks/boot-ETZUHG3U.js +0 -3
- package/dist/chunks/check-B6NP7BEM.js +0 -3
- package/dist/chunks/chunk-2M5PPZIS.js +0 -36
- package/dist/chunks/chunk-4OSMYHKQ.js +0 -4
- package/dist/chunks/chunk-4RNVZQRC.js +0 -3
- package/dist/chunks/chunk-6TTONCYR.js +0 -6
- package/dist/chunks/chunk-BP6CVOQR.js +0 -66
- package/dist/chunks/chunk-DD5Z6NSH.js +0 -3
- package/dist/chunks/chunk-DHW72U6X.js +0 -3
- package/dist/chunks/chunk-FAUL5L2W.js +0 -3
- package/dist/chunks/chunk-FEFNS6YZ.js +0 -3
- package/dist/chunks/chunk-H3DIRJFE.js +0 -3
- package/dist/chunks/chunk-H3KW7HTC.js +0 -3
- package/dist/chunks/chunk-HTA25PO2.js +0 -3
- package/dist/chunks/chunk-J7FLFHQJ.js +0 -3
- package/dist/chunks/chunk-J7Z7ULLN.js +0 -3
- package/dist/chunks/chunk-KH5DHZ2U.js +0 -8
- package/dist/chunks/chunk-N32JL4UI.js +0 -3
- package/dist/chunks/chunk-N6RCLJE6.js +0 -4
- package/dist/chunks/chunk-NAE3AJ3M.js +0 -3
- package/dist/chunks/chunk-NMECUMJD.js +0 -7
- package/dist/chunks/chunk-NUW4YOJ6.js +0 -3
- package/dist/chunks/chunk-RQWWUCGQ.js +0 -3
- package/dist/chunks/chunk-RT6EXB2P.js +0 -3
- package/dist/chunks/chunk-T4CLHCLJ.js +0 -4
- package/dist/chunks/chunk-TFGK7IRZ.js +0 -19
- package/dist/chunks/chunk-TJ5YBJEO.js +0 -3
- package/dist/chunks/chunk-TLHUFIXD.js +0 -3
- package/dist/chunks/chunk-V6GWPR2A.js +0 -3
- package/dist/chunks/chunk-VBDRWNEG.js +0 -3
- package/dist/chunks/chunk-YISJTRB6.js +0 -72
- package/dist/chunks/chunk-YPAFAG4W.js +0 -6
- package/dist/chunks/chunk-Z6IQV737.js +0 -3
- package/dist/chunks/chunk-ZBMJTIYR.js +0 -3
- package/dist/chunks/chunk-ZX5FDZZW.js +0 -55
- package/dist/chunks/clip-command-QIMH2U7N.js +0 -3
- package/dist/chunks/clipboard-IZJTBTSW.js +0 -3
- package/dist/chunks/colour-3MFAFJNN.js +0 -3
- package/dist/chunks/command-GAGAD65W.js +0 -3
- package/dist/chunks/config-command-CKPJXJEE.js +0 -3
- package/dist/chunks/continue-editing-M6WESEVB.js +0 -3
- package/dist/chunks/decoded-XWKU23RG.js +0 -3
- package/dist/chunks/execute-MRVDAKZO.js +0 -3
- package/dist/chunks/extensions-ONARRS5Q.js +0 -3
- package/dist/chunks/ffmpeg-RTFJS67A.js +0 -3
- package/dist/chunks/image-R5C3AWHT.js +0 -3
- package/dist/chunks/install-MFYGS5TG.js +0 -3
- package/dist/chunks/launch-T7YOO7BQ.js +0 -17
- package/dist/chunks/lock-BG3CLOHA.js +0 -3
- package/dist/chunks/manager-5EJGANFW.js +0 -4
- package/dist/chunks/notify-NQNNOBFC.js +0 -3
- package/dist/chunks/pdfium-77L526HZ.js +0 -3
- package/dist/chunks/preferences-3P4V2EDX.js +0 -3
- package/dist/chunks/preset-command-3ILRQZSJ.js +0 -3
- package/dist/chunks/registry-K245FDI2.js +0 -3
- package/dist/chunks/server-M5YGJHOL.js +0 -77
- package/dist/chunks/text-layer-LHZNDMPZ.js +0 -3
- package/dist/chunks/theme-XKWZV7OX.js +0 -3
- package/dist/chunks/transcribe-SQC6QTV5.js +0 -3
- package/dist/chunks/transcribe-command-PAHSXMWG.js +0 -3
- package/dist/chunks/update-command-DWEBUFT5.js +0 -3
- package/dist/chunks/update-note-NRPILOCL.js +0 -3
- package/dist/chunks/watch-command-QOMMDISG.js +0 -3
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ That puts `forge` on your `PATH`, so it works from any directory. Verify:
|
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
forge --version
|
|
53
|
-
# 0.
|
|
53
|
+
# 0.6.0
|
|
54
54
|
|
|
55
55
|
forge photo.jpg --to webp
|
|
56
56
|
```
|
|
@@ -211,7 +211,7 @@ Forge stores preferences at `~/.config/forge/config.json`, or
|
|
|
211
211
|
|
|
212
212
|
```bash
|
|
213
213
|
forge config list # show every setting and where it lives
|
|
214
|
-
forge config set output ~/Desktop # default output folder
|
|
214
|
+
forge config set output ~/Desktop # default output folder, made on first save
|
|
215
215
|
forge config set theme light # dark or light
|
|
216
216
|
forge config set quality 80 # what the quality slider opens on
|
|
217
217
|
forge config set update-check off # stop the once-a-day update check
|
|
@@ -331,7 +331,8 @@ forge *.jpg --max-size 1mb # a whole folder
|
|
|
331
331
|
```
|
|
332
332
|
|
|
333
333
|
`--quality` without `--to` compresses; with `--to` it converts, as it always
|
|
334
|
-
has.
|
|
334
|
+
has. So does an `-o` whose extension names another format: `forge photo.jpg
|
|
335
|
+
--max-size 100kb -o small.webp` writes a WebP that fits. `--quality` and `--max-size` are mutually exclusive — they ask the same
|
|
335
336
|
question two ways, and Forge will not guess which wins.
|
|
336
337
|
|
|
337
338
|
A PNG or GIF is compressed by cutting it to fewer colours, which is what
|
|
@@ -489,15 +490,16 @@ forge extensions remove boost
|
|
|
489
490
|
```
|
|
490
491
|
|
|
491
492
|
```bash
|
|
492
|
-
forge photo.jpg --sharpen # photo-sharp.
|
|
493
|
-
forge photo.jpg --boost # photo-2x.
|
|
494
|
-
forge photo.jpg --boost 3 # photo-3x.
|
|
495
|
-
forge photo.jpg --boost 4 # photo-4x.
|
|
493
|
+
forge photo.jpg --sharpen # photo-sharp.jpg (the same size, sharper)
|
|
494
|
+
forge photo.jpg --boost # photo-2x.jpg (2x, the default)
|
|
495
|
+
forge photo.jpg --boost 3 # photo-3x.jpg (needs boost 1.1.0 or later)
|
|
496
|
+
forge photo.jpg --boost 4 # photo-4x.jpg
|
|
496
497
|
forge photo.jpg --remove-bg # photo-cutout.png
|
|
497
498
|
forge photo.jpg --remove-bg --to webp
|
|
498
499
|
```
|
|
499
500
|
|
|
500
|
-
Output goes beside the source unless `-o` says otherwise. Boost keeps
|
|
501
|
+
Output goes beside the source unless `-o` says otherwise. Boost keeps the
|
|
502
|
+
image's format unless `--to` or `-o`'s extension names another, and keeps
|
|
501
503
|
transparency, and flattens it onto `--background` only when `--to` names a
|
|
502
504
|
format that cannot carry it. A cutout must be saved in a format that holds
|
|
503
505
|
transparency (PNG, WebP, AVIF, TIFF); JPEG is refused, because flattening would
|
|
@@ -682,6 +684,10 @@ $ forge big.pdf --to png --pages 1,2 # big.pdf has 300 pages
|
|
|
682
684
|
4.2 KB → 928 B total
|
|
683
685
|
```
|
|
684
686
|
|
|
687
|
+
`-o` naming a file numbers the pages after it, in its folder: `-o
|
|
688
|
+
out/pages.png` writes `out/pages-1.png`, `out/pages-2.png`… One page out is
|
|
689
|
+
`out/pages.png` itself.
|
|
690
|
+
|
|
685
691
|
### image → PDF
|
|
686
692
|
|
|
687
693
|
```
|
|
@@ -898,8 +904,8 @@ forge <inputs...> --to <format> [options]
|
|
|
898
904
|
|
|
899
905
|
| Flag | Meaning |
|
|
900
906
|
| --- | --- |
|
|
901
|
-
| `-t, --to <format>` | target format (
|
|
902
|
-
| `-o, --output <path>` | output file or directory |
|
|
907
|
+
| `-t, --to <format>` | target format (without it, the format `-o`'s extension names) |
|
|
908
|
+
| `-o, --output <path>` | output file or directory; a leading `~` is home |
|
|
903
909
|
| `-q, --quality <n>` | 1–100, lossy targets only, **requires `--to`** |
|
|
904
910
|
| `--background <css>` | fill colour when flattening alpha (default white) |
|
|
905
911
|
| `--keep-metadata` | preserve EXIF/GPS instead of stripping it |
|
|
@@ -1141,7 +1147,7 @@ photo.png · PNG · 122 KB · 2756×774
|
|
|
1141
1147
|
With `--json`:
|
|
1142
1148
|
|
|
1143
1149
|
```json
|
|
1144
|
-
{"forge":"0.
|
|
1150
|
+
{"forge":"0.6.0","ok":true,"probes":[{"path":"/Users/me/photo.png","kind":"image","format":"png","bytes":122449,"width":2756,"height":774,"targets":["jpeg","png","webp","avif","gif","tiff","pdf"],"actions":["convert"]}],"failures":[]}
|
|
1145
1151
|
```
|
|
1146
1152
|
|
|
1147
1153
|
`targets` and `actions` come from the engines' own capabilities, so they are
|
|
@@ -1167,7 +1173,7 @@ succeeded) and `failures`. A conversion, compression or page operation adds
|
|
|
1167
1173
|
|
|
1168
1174
|
```jsonc
|
|
1169
1175
|
{
|
|
1170
|
-
"forge": "0.
|
|
1176
|
+
"forge": "0.6.0",
|
|
1171
1177
|
"ok": false,
|
|
1172
1178
|
"results": [
|
|
1173
1179
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
3
|
import"./chunk-TMUK2DD3.js";import{readFile as x}from"node:fs/promises";import{dirname as m,join as u}from"node:path";import{fileURLToPath as C}from"node:url";var c=[{name:"sharp \xB7 libvips",licence:"Apache-2.0 \xB7 LGPL-3.0",does:"images",packages:["sharp"]},{name:"PDFium",licence:"BSD-3-Clause",does:"PDF pages",packages:[]},{name:"pdf-lib",licence:"MIT",does:"writing PDFs",packages:["pdf-lib"]},{name:"mammoth \xB7 docx",licence:"BSD-2-Clause \xB7 MIT",does:"Word documents",packages:["mammoth","docx"]},{name:"Ink \xB7 React",licence:"MIT",does:"this screen",packages:["ink","react"]}],g=[{name:"@hyzyla/pdfium",licence:"MIT"}],h=[{name:"Noto Sans",licence:"OFL-1.1"},{name:"xkcd colour survey",licence:"CC0-1.0"}];function l(n){let t=[];for(let e of n.split(`
|
|
4
|
-
`)){let i=/^((?:@[^/\s]+\/)?[^@\s]+)@\S+ — (.+)$/.exec(e);i&&t.push({name:i[1],licence:i[2].replace(/^\((.*)\)$/,"$1")})}return t}var d=n=>n.name.replace(/^@/,"");function p({bundled:n,extensions:t}){let e=new Set(c.flatMap(s=>s.packages)),i=[...n.filter(s=>!e.has(s.name)),...g,...h].sort((s,r)=>d(s).localeCompare(d(r)));return[{title:"App",credits:c.map(({packages:s,...r})=>r)},...t.length>0?[{title:"Extensions",credits:t}]:[],{title:"Others",credits:i}]}var f="third-party-licenses.txt";function y(n){let t=[],e=m(n);for(let i=0;i<4;i++)t.push(u(e,f),u(e,"dist",f)),e=m(e);return t}async function k(n){for(let t of y(C(n))){let e=await x(t,"utf8").catch(()=>{});if(e!==void 0)return{path:t,text:e}}}async function F({from:n=import.meta.url,list:t=async()=>(await import("./manager-
|
|
4
|
+
`)){let i=/^((?:@[^/\s]+\/)?[^@\s]+)@\S+ — (.+)$/.exec(e);i&&t.push({name:i[1],licence:i[2].replace(/^\((.*)\)$/,"$1")})}return t}var d=n=>n.name.replace(/^@/,"");function p({bundled:n,extensions:t}){let e=new Set(c.flatMap(s=>s.packages)),i=[...n.filter(s=>!e.has(s.name)),...g,...h].sort((s,r)=>d(s).localeCompare(d(r)));return[{title:"App",credits:c.map(({packages:s,...r})=>r)},...t.length>0?[{title:"Extensions",credits:t}]:[],{title:"Others",credits:i}]}var f="third-party-licenses.txt";function y(n){let t=[],e=m(n);for(let i=0;i<4;i++)t.push(u(e,f),u(e,"dist",f)),e=m(e);return t}async function k(n){for(let t of y(C(n))){let e=await x(t,"utf8").catch(()=>{});if(e!==void 0)return{path:t,text:e}}}async function F({from:n=import.meta.url,list:t=async()=>(await import("./manager-272REVNF.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-3SG2LW7R.js"),r=i.filter(o=>o.installed!==void 0).flatMap(o=>s(o.entry)),a=p({bundled:l(e?.text??""),extensions:r});return e?{sections:a,file:e.path}:{sections:a}}export{F as loadCredits};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f,g}from"./chunk-YYZYZWF5.js";import"./chunk-QPUKPSPZ.js";import"./chunk-PISCJKIG.js";import"./chunk-HZDYZ5RD.js";import"./chunk-EYOO35US.js";import"./chunk-WID72ZII.js";import"./chunk-NMGQGYVM.js";import"./chunk-EEQSUBBL.js";import"./chunk-BSFBZBAI.js";import"./chunk-BWJNZT75.js";import"./chunk-3IX3QA76.js";import"./chunk-2OSM4W4D.js";import"./chunk-PON65UTS.js";import"./chunk-FWVE3GNA.js";import"./chunk-QO4JUY6B.js";import"./chunk-UN5DSJE2.js";import"./chunk-6HUYBVQA.js";import"./chunk-KXKQDFHX.js";import"./chunk-4MZV4SRU.js";import"./chunk-BYUOU2Q2.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as colourUsage,c as commandsHelp,g as parseArgs,e as subcommandHelp,f as wantsJson};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{s as a}from"./chunk-WID72ZII.js";import{e as l}from"./chunk-4MZV4SRU.js";import"./chunk-BYUOU2Q2.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:l,loadShell:()=>import("./launch-EGFNGHLN.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=a(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-UEAZTRTL.js";import"./chunk-4MZV4SRU.js";import"./chunk-BYUOU2Q2.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{b as CHECK_EVERY_MS,e as MAX_NOTES,g as NOTE_TEXT,f as NOTE_TITLE,a as REGISTRY_URL,o as availableUpdate,h as cachePath,m as checkNow,l as fetchLatest,c as isNewer,k as isStale,i as readCache,d as updateChecksEnabled,n as whatsNewFor,j as writeCache};
|
|
@@ -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 le,B as ge,C as pe,D as he,a,b as te,c as re,d as E,e as x,f as O,g as k,h as ie,j as oe,k as g,l as A,m as se,n as v,o as H,p as ae,q as F,r as L,s as R,t as ce,u as I,v as ue,w as fe,x as me,y as de,z as B}from"./chunk-
|
|
3
|
+
import{A as le,B as ge,C as pe,D as he,a,b as te,c as re,d as E,e as x,f as O,g as k,h as ie,j as oe,k as g,l as A,m as se,n as v,o as H,p as ae,q as F,r as L,s as R,t as ce,u as I,v as ue,w as fe,x as me,y as de,z as B}from"./chunk-PA7AG2NK.js";import{w as D}from"./chunk-UN5DSJE2.js";import{execFile as We}from"node:child_process";import{chmodSync as Q,existsSync as be,mkdirSync as Z,readdirSync as Pe,readFileSync as N,rmdirSync as Xe,rmSync as p,writeFileSync as Qe}from"node:fs";import{dirname as P,join as c}from"node:path";var Ge={convert:"#55c7d9",compress:"#79c98b",edit:"#b39ae8",pdf:"#ff6b4a"},Te="#55c7d9",Je="#a68ce0",Ke=4/5,Ve=(e,n,t,r)=>`<path fill="${r}" d="M${e} ${n}h${4*t}v${t}h${-3*t}v${t}h${2*t}v${t}h${-2*t}v${2*t}h${-t}z"/>`;function Ye(e,n){let t=n<=20,r=t?3:4,i=t?6:4.6,o=t?51:51.5,m=Array.from({length:r},(l,w)=>o-(r-1-w)*i).map(l=>`<line x1="${l}" y1="66" x2="${l+66*Ke}" y2="0"/>`).join(""),u=e==="forge"?"url(#w)":Ge[e];return`<svg width="${n}" height="${n}" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="w" gradientUnits="userSpaceOnUse" x1="34" y1="0" x2="62" y2="0"><stop offset="0" stop-color="${Te}"/><stop offset="1" stop-color="${Je}"/></linearGradient><clipPath id="c"><rect width="64" height="64" rx="14"/></clipPath><clipPath id="i"><rect x="1.5" y="1.5" width="61" height="61" rx="12.5"/></clipPath></defs><g clip-path="url(#c)"><rect width="64" height="64" fill="#1e1e1e"/><g clip-path="url(#i)" stroke="${u}" stroke-width="${t?3.6:2.4}">${m}</g>${Ve(16,12,8,"#e7e7e7")}</g><rect x=".75" y=".75" width="62.5" height="62.5" rx="13.5" fill="none" stroke="#3a3a3a" stroke-width="1.5"/></svg>`}async function S(e,n){let{default:t}=await import("sharp");return t(Buffer.from(Ye(e,n))).png().toBuffer()}function ye(e){let n=Buffer.alloc(6);n.writeUInt16LE(0,0),n.writeUInt16LE(1,2),n.writeUInt16LE(e.length,4);let t=6+16*e.length,r=e.map(({size:i,png:o})=>{let s=Buffer.alloc(16);return s[0]=i>=256?0:i,s[1]=i>=256?0:i,s.writeUInt16LE(1,4),s.writeUInt16LE(32,6),s.writeUInt32LE(o.length,8),s.writeUInt32LE(t,12),t+=o.length,s});return Buffer.concat([n,...r,...e.map(i=>i.png)])}function h(e){let n=[{action:"open",label:"Open Forge",kinds:["image","folder"],window:!0,paint:"forge"},{action:"open-file",label:"Open in Forge",kinds:["pdf","video","audio"],window:!0,paint:"pdf"},{action:"convert",label:"Convert in Forge",kinds:["image","folder","video","audio"],window:!0,paint:"convert"},{action:"compress",label:"Compress in Forge",kinds:["image","folder","video","audio"],window:!0,paint:"compress"},{action:"sharpen",label:"Sharpen in Forge",kinds:["image"],window:!1,paint:"edit"}],t=(e.presets??[]).map(r=>({action:"preset",preset:r,label:`${r} in Forge`,kinds:["image"],window:!1,paint:"forge"}));return[...e.sharpen?n:n.filter(r=>r.action!=="sharpen"),...t]}var U="Forge was uninstalled",j="Its menu items are removed.",$e="Forge could not start",we="Run forge in a terminal once to set its menu up again.";function xe(e){let{osascript:n,pbs:t}=e.tools??{osascript:"/usr/bin/osascript",pbs:"/System/Library/CoreServices/pbs"},r=[e.node,...e.execArgv,e.forge].map(a).join(" "),[i,o]=x({on:[],off:e.services,osascript:n}),s=[i,...o].map(a).join(" "),m=(u,l)=>`${a(n)} -e 'display notification "${l}" with title "${u}"'`;return`#!/bin/sh
|
|
4
4
|
# Forge's right-click menu. Rewritten by Forge whenever it sets the menu up.
|
|
5
5
|
if [ ! -f ${a(e.forge)} ]; then
|
|
6
6
|
# Forge is gone: take its menu with it, and say so once.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{d as s,h as a}from"./chunk-EEQSUBBL.js";import{a as
|
|
3
|
+
import{d as s,h as a}from"./chunk-EEQSUBBL.js";import{a as i}from"./chunk-CCNRNCRU.js";import{a as r}from"./chunk-FGR6QCG5.js";import{win32 as d}from"node:path";function l(n,e=process.platform){return e==="win32"?d.basename(n):n.split("/").pop()}function f(n){return n.facts?n.facts.video!==void 0:i[n.format].media==="video"}function v(n){return n==="mp3"?"mp3":n==="opus"?"opus":"m4a"}var u=n=>n===1?"mono":n===2?"stereo":`${n} channels`,m=n=>`${Math.round(n/100)/10} kHz`;function F(n){let e=r(n.bytes),o=n.facts;if(!o)return`${f(n)?"video":"sound"} \xB7 ${e}`;let t=[s(o.duration)];return o.video?(t.push(`${o.video.width}\xD7${o.video.height}`,`${o.video.fps} fps`),o.video.hdr&&t.push("HDR")):o.audio&&t.push(u(o.audio.channels),m(o.audio.sampleRate)),t.push(e),t.join(" \xB7 ")}function p(n){return n.facts?a(n.facts):void 0}function $(n){let e=p(n)??0;return[...e<1e6?["kb"]:[],...n.bytes>=1e6||e>=1e6?["mb"]:[],...n.bytes>1e9?["gb"]:[]]}var c=n=>n==="opus"?96:128;function k(n,e){let o=n.facts;if(!(!o?.audio||i[e].media!=="sound")){if(i[e].lossy)return Math.round(c(e)*1e3*o.duration/8);if(e==="wav"||e==="aiff")return Math.round(o.audio.sampleRate*o.audio.channels*2*o.duration)}}export{l as a,f as b,v as c,F as d,p as e,$ as f,k as g};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as i,d,e as p,f as a}from"./chunk-4MZV4SRU.js";import{P as n}from"./chunk-CCNRNCRU.js";import{stat as l}from"node:fs/promises";import{dirname as h,resolve as g}from"node:path";var C=["output","theme","quality","update-check"];async function b(s){if(s.action==="path")return{stdout:[i()],exitCode:0,config:{path:i()},warnings:[]};if(s.action==="list"){let{prefs:t,warning:o}=await p(),f=[`output ${t.defaultOutput}`,`theme ${t.theme??"not set"}`,`quality ${t.quality??"not set"}`,`update-check ${t.updateCheck===!1?"off":"on"}`,"",i()];return o!==void 0&&f.unshift(`\u26A0 ${o}`,""),{stdout:f,exitCode:0,config:{output:t.defaultOutput,theme:t.theme??null,quality:t.quality??null,"update-check":t.updateCheck===!1?"off":"on",path:i()},warnings:o===void 0?[]:[{code:"config-unreadable",message:o}]}}let{key:c,value:e}=s;if(c==="theme"){if(e!=="dark"&&e!=="light")throw n(`Theme must be dark or light, not ${e}.`);return await a({theme:e}),{stdout:[`theme is now ${e}`],exitCode:0,config:{theme:e},warnings:[]}}if(c==="quality"){let t=Number(e);if(!Number.isInteger(t)||t<1||t>100)throw n(`Quality must be a whole number between 1 and 100, not ${e}.`);return await a({quality:t}),{stdout:[`quality is now ${t}`],exitCode:0,config:{quality:t},warnings:[]}}if(c==="update-check"){if(e!=="on"&&e!=="off")throw n(`update-check must be on or off, not ${e}.`);return await a({updateCheck:e==="on"}),{stdout:[`update-check is now ${e}`],exitCode:0,config:{"update-check":e},warnings:[]}}if(e.trim().length===0)throw n("Output must be a folder path.");let u=g(d(e)),r=u;for(;;){let t=await l(r).catch(f=>f);if(!(t instanceof Error)){if(!t.isDirectory())throw n("Output must be a folder path.");break}if(t.code==="ENOTDIR")throw n("Output must be a folder path.");let o=h(r);if(o===r)break;r=o}return await a({defaultOutput:u}),{stdout:[`output is now ${u}`],exitCode:0,config:{output:u},warnings:[]}}export{C as a,b};
|
|
@@ -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-272REVNF.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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{o as x}from"./chunk-FWVE3GNA.js";import{w as _}from"./chunk-UN5DSJE2.js";import{b as y,d as h}from"./chunk-KXKQDFHX.js";import{D as l}from"./chunk-CCNRNCRU.js";import{readFile as D,rm as L}from"node:fs/promises";var S=new Set(["pdf"]),C=new Set(["jpeg","png"]),R=new Set(["convert"]),w;function A(){return w??=h().then(e=>e.PDFiumLibrary.init()),w}async function F(e,n){return await(await A()).loadDocument(e,n)}async function H(e,n){let r;try{r=await F(await D(e),n)}catch{return!1}return r.destroy(),!0}async function J(e){let n=await F(e);try{let r=[];for(let i=0;i<n.getPageCount();i++)r.push(n.getPage(i).getText());return r}finally{n.destroy()}}var O=3,U=3;function j(e,n,r,i){let t=r*i;if(t<=0)return 0;let o=e.wasmExports.malloc(16);try{let c=0;for(let a=0;a<e._FPDFPage_CountObjects(n);a++){let u=e._FPDFPage_GetObject(n,a);if(!u||e._FPDFPageObj_GetType(u)!==U||!e._FPDFPageObj_GetBounds(u,o,o+4,o+8,o+12))continue;let[s=0,p=0,P=0,m=0]=new Float32Array(e.HEAPU8.buffer,o,4),g=Math.min(P,r)-Math.max(s,0),d=Math.min(m,i)-Math.max(p,0);g>0&&d>0&&(c=Math.max(c,g*d/t))}return c}finally{e.wasmExports.free(o)}}async function W(e){let n=await F(e);try{let r=[];for(let i=0;i<n.getPageCount();i++){let{module:t,pageIdx:o}=n.getPage(i),c=t._FPDF_GetPageWidthF(o),a=t._FPDF_GetPageHeightF(o),u=[],s=t._FPDFPage_GetRotation(o)===0?t._FPDFText_LoadPage(o):0;if(s){let p=t.wasmExports.malloc(16);try{let P=t._FPDFText_CountChars(s);for(let m=0;m<P;m++){let g=t._FPDFText_GetUnicode(s,m),d=g>0&&g<=1114111?String.fromCodePoint(g):"\uFFFD";if(t._FPDFText_IsGenerated(s,m)||!t._FPDFText_GetLooseCharBox(s,m,p)){u.push({char:d});continue}let[T=0,G=0,E=0,I=0]=new Float32Array(t.HEAPU8.buffer,p,4),b=t._FPDFText_GetTextObject(s,m),f=b!==0&&t._FPDFTextObj_GetTextRenderMode(b)===O;u.push({char:d,box:[T,G,E,I],...f?{hidden:f}:{}})}}finally{t.wasmExports.free(p),t._FPDFText_ClosePage(s)}}r.push({width:c,height:a,chars:u,picture:j(t,o,c,a)})}return r}finally{n.destroy()}}var q={id:"pdfium",reads:S,writes:C,ops:R,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(e,n){if(e.op!=="convert")throw new Error(`pdfium cannot ${e.op}`);let r=e.sources[0];if(r.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(r.encrypted&&e.options.password===void 0)throw l(r.path);let i=e.options.dpi??150,t=e.options.pages??Array.from({length:r.pages},(a,u)=>u);if(t.length!==e.outputs.length)throw new Error(`pdfium was given ${t.length} pages but ${e.outputs.length} outputs`);for(let a of t)if(a<0||a>=r.pages)throw new Error(`pdfium was asked for page ${a}, but ${r.path} has ${r.pages} pages`);let o=await y(),c=await F(await D(r.path),e.options.password);try{let a=[],u=0;try{for(let[s,p]of t.entries()){let P=await c.getPage(p).render({scale:i/72,render:"bitmap",transparent:!0}),m=o(P.data,{raw:{width:P.width,height:P.height,channels:4}}).flatten({background:e.options.background}),g=await x(m,e.target,e.options.quality).toBuffer(),d=e.outputs[s];u+=await _(d,g),a.push(d),n({phase:"page",done:s+1,total:t.length})}}catch(s){throw await Promise.all(a.map(p=>L(p,{force:!0}))),s}return{job:e,outputBytes:u,warnings:[]}}finally{c.destroy()}}};export{F as a,H as b,J as c,W as d,q as e};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{l as k}from"./chunk-3HG7RXC2.js";import{c as I,e as $,f as P}from"./chunk-I25E2XDH.js";import{a as w}from"./chunk-PON65UTS.js";import{D as v,Da as E,Fa as m,X as S}from"./chunk-CCNRNCRU.js";var M="Summary and notes by Apple Intelligence. They may contain mistakes.";function L(t){let r=Math.floor(t),e=s=>String(s).padStart(2,"0"),n=Math.floor(r/3600),o=Math.floor(r/60)%60;return n>0?`${n}:${e(o)}:${e(r%60)}`:`${o}:${e(r%60)}`}var N=t=>t.split(/\s+/).filter(Boolean).length,D=60,j=140,R=1,V=10;function Y(t){let r=[],e;for(let n of t){if(e){let o=n.start-e.end;if(!(o>V||o>R&&e.words>=D||e.words>=j)){e.text+=` ${n.text}`,e.end=n.end,e.words+=N(n.text);continue}r.push({start:e.start,text:e.text})}e={start:n.start,end:n.end,text:n.text,words:N(n.text)}}return e&&r.push({start:e.start,text:e.text}),r}var T=t=>Y(t).flatMap(r=>[`**${L(r.start)}** ${r.text}`,""]),W=t=>/^https?:\/\/\S+$/.test(t)?`<${t}>`:t;function q(t,r,{transcript:e=!0}={}){let n=[`# ${r.title}`,"",W(r.from),""],o=t.notes;if(!o)return[...n,...T(t.segments)].join(`
|
|
4
|
+
`);let s=o.parts,p=a=>{let d=s[a];return d?`### ${d.refused?`Part ${a+1}`:d.heading} \xB7 ${L(d.start)}`:""};n.push(o.summary,"","## Notes",""),s.forEach((a,d)=>{n.push(p(d),""),a.points.length>0&&n.push(...a.points.map(l=>`- ${l}`),"")});let c=[`_${M}_`,""];return e?(n.push("## Transcript",""),s.forEach((a,d)=>{let l=s[d+1]?.start??Number.POSITIVE_INFINITY,b=t.segments.filter(h=>h.start>=a.start&&h.start<l);n.push(p(d),"",...T(b))}),[...n,...c].join(`
|
|
5
|
+
`)):[...n,...c].join(`
|
|
6
|
+
`)}function z(t){let r=[...t].map(e=>(e.codePointAt(0)??0)<32?" ":e).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return r===""?"transcript":r}var C=["en"];function Z(t){let r=t?.split(/[-_]/)[0]?.toLowerCase();return r!==void 0&&C.includes(r)}function rt(t){if(t.kind!=="media"){if(t.kind==="image"){let{path:r,format:e,bytes:n,width:o,height:s}=t;return{what:"image",path:r,format:e,bytes:n,width:o,height:s}}if(t.format!=="pdf")throw E(t.path);if(t.encrypted)throw v(t.path);return{what:"pdf",path:t.path,bytes:t.bytes,pages:t.pages}}}import{spawn as F}from"node:child_process";import{mkdtemp as G,rm as H}from"node:fs/promises";import{tmpdir as K}from"node:os";import{join as _}from"node:path";import{createInterface as B}from"node:readline";var U=[[/private video/i,"This video is private."],[/confirm your age/i,"This video is age-restricted."],[/members-only|join this channel/i,"This video is for channel members only."],[/live event will begin|premieres in/i,"This video has not started yet."],[/unavailable|has been removed|does not exist/i,"This video is unavailable."]],g=class extends Error{};function J(t=process.platform,r=process.arch){let e=$("yt-dlp");return e!==void 0&&P(e,t,r)!==void 0?S("yt-dlp"):m(`YouTube links on ${I(t)} need yt-dlp on your PATH.`,void 0,{hint:"Install yt-dlp (https://github.com/yt-dlp/yt-dlp) and put it on your PATH.",shellHint:"Install yt-dlp and put it on your PATH."})}async function ft(t,r={}){let e=await k();if(e===void 0)throw J();let n=await G(_(K(),"forge-yt-"));r.onDir?.(n);let o=()=>H(n,{recursive:!0,force:!0});try{let s;try{s=await A(e.entry,t,n,r)}catch(p){if(!(p instanceof g))throw p;if(e.own)throw m(`yt-dlp could not fetch this video: ${p.message}`,p);await X(e.entry,r.signal);try{s=await A(e.entry,t,n,r)}catch(c){throw c instanceof g?m(`yt-dlp could not fetch this video: ${c.message}`,c):c}}return{...s,dispose:o}}catch(s){throw await o(),s}}function A(t,r,e,n){let{signal:o}=n;if(o?.aborted)return Promise.reject(o.reason??new Error("aborted"));let s=["--js-runtimes",`node:${process.execPath}`,"--no-playlist","--no-warnings","--newline","--progress","-f","bestaudio[ext=m4a]/bestaudio","--print","before_dl:forge-facts %(.{title,uploader,duration,is_live})j","--progress-template","download:forge-bytes %(progress.downloaded_bytes)s %(progress.total_bytes,progress.total_bytes_estimate)s","--print","after_move:forge-file %(filepath)s","--no-simulate","-o",_(e,"sound.%(ext)s"),r];return new Promise((p,c)=>{let a=w(F(t,s,{stdio:["ignore","pipe","pipe"]})),d,l,b="",h=!1,y=i=>{h||(h=!0,o?.removeEventListener("abort",x),i())},x=()=>{a.kill("SIGKILL"),y(()=>c(o?.reason??new Error("aborted")))};o?.addEventListener("abort",x,{once:!0}),B({input:a.stdout}).on("line",i=>{if(i.startsWith("forge-facts ")){let u=JSON.parse(i.slice(12));if(u.is_live===!0){a.kill("SIGKILL"),y(()=>c(m("Live streams cannot be transcribed.")));return}d={title:String(u.title??""),uploader:String(u.uploader??""),seconds:Number(u.duration??0)},n.onEvent?.({kind:"facts",facts:d})}else if(i.startsWith("forge-bytes ")){let[u,f]=i.slice(12).split(" ").map(Number);Number.isFinite(u)&&Number.isFinite(f)&&(f??0)>0&&n.onEvent?.({kind:"bytes",done:u,total:f})}else i.startsWith("forge-file ")&&(l=i.slice(11))}),a.stderr.on("data",i=>{b+=i.toString()}),a.on("error",i=>y(()=>c(new g(i.message)))),a.on("close",i=>y(()=>{if(i===0&&d!==void 0&&l!==void 0)return p({path:l,facts:d});let u=b.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",f=U.find(([O])=>O.test(u));c(f?m(f[1]):new g(u||`yt-dlp exited ${i}`))}))})}function X(t,r){return new Promise((e,n)=>{let o=w(F(t,["--update"],{stdio:"ignore"})),s=()=>o.kill("SIGKILL");r?.addEventListener("abort",s,{once:!0}),o.on("error",()=>e()),o.on("close",()=>{r?.removeEventListener("abort",s),r?.aborted?n(r.reason??new Error("aborted")):e()})})}export{L as a,q as b,z as c,Z as d,rt as e,J as f,ft as g};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as l}from"./chunk-BYUOU2Q2.js";import{c as g}from"./chunk-NUCGWLOY.js";import{a as h}from"./chunk-HON4OV7M.js";import{O as u}from"./chunk-CCNRNCRU.js";import{copyFile as M,mkdir as N,readFile as b,rename as S,unlink as D,writeFile as j}from"node:fs/promises";import{homedir as F}from"node:os";import{dirname as c,join as O}from"node:path";import{execFileSync as x}from"node:child_process";import{homedir as m}from"node:os";import{join as k}from"node:path";var E={Desktop:"[Environment]::GetFolderPath('Desktop')",Downloads:"(Get-ItemProperty 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders').'{374DE290-123F-4565-9164-39C4925E467B}'"};function v(e){try{let n=x("powershell.exe",["-NoProfile","-NonInteractive","-Command",`[Console]::OutputEncoding=[Text.Encoding]::UTF8; ${E[e]}`],{encoding:"buffer",timeout:5e3,stdio:["ignore","pipe","ignore"]}).toString("utf8").trim();return n.length>0?n:void 0}catch{return}}var y=new Map;function a(e,t=process.platform,n=v){if(t!=="win32")return k(m(),e);let r=y.get(e);if(r!==void 0)return r;let o=n(e)?.replace(/%([^%]+)%/g,(w,C)=>process.env[C]??w),p=(o!==void 0&&!o.includes("%")?o:void 0)??k(m(),e);return y.set(e,p),p}var s={defaultOutput:"~/Desktop"};function d(){return O(h(),"forge","config.json")}function Q(e,t=process.platform){if(t==="win32"){if(e==="~/Desktop")return a("Desktop",t);if(e==="~/Downloads")return a("Downloads",t)}return e==="~"?F():e.startsWith("~/")?O(F(),e.slice(2)):e}function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R(e){let t={...s},n=[];if(e.theme!==void 0&&(e.theme==="dark"||e.theme==="light"?t.theme=e.theme:n.push("theme")),e.defaultOutput!==void 0&&(typeof e.defaultOutput=="string"&&e.defaultOutput.trim().length>0?t.defaultOutput=e.defaultOutput:n.push("defaultOutput")),e.quality!==void 0){let r=e.quality;typeof r=="number"&&Number.isInteger(r)&&r>=1&&r<=100?t.quality=r:n.push("quality")}if(e.updateCheck!==void 0&&(typeof e.updateCheck=="boolean"?t.updateCheck=e.updateCheck:n.push("updateCheck")),e.rightClickMenu!==void 0&&(typeof e.rightClickMenu=="boolean"?t.rightClickMenu=e.rightClickMenu:n.push("rightClickMenu")),e.searchMac!==void 0&&(typeof e.searchMac=="boolean"?t.searchMac=e.searchMac:n.push("searchMac")),e.lastOutput!==void 0&&(typeof e.lastOutput=="string"&&e.lastOutput.trim().length>0?t.lastOutput=e.lastOutput:n.push("lastOutput")),e.transcribeFormat!==void 0&&(g(e.transcribeFormat)?t.transcribeFormat=e.transcribeFormat:n.push("transcribeFormat")),e.presets!==void 0)if(Array.isArray(e.presets)){let r=e.presets.map(l);t.presets=r.filter(i=>i!==void 0),t.presets.length<r.length&&n.push("presets")}else n.push("presets");return{prefs:t,rejected:n}}async function $(){let e;try{e=await b(d(),"utf8")}catch{return"missing"}try{let t=JSON.parse(e);return P(t)?t:"broken"}catch{return"broken"}}async function V(){let e=d(),t;try{t=await b(e,"utf8")}catch(o){return o.code==="ENOENT"?{prefs:s}:{prefs:s,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let n;try{n=JSON.parse(t)}catch{return{prefs:s,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!P(n))return{prefs:s,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:r,rejected:i}=R(n);return i.length===0?{prefs:r}:{prefs:r,warning:`Ignored invalid config ${i.length===1?"setting":"settings"}: ${i.join(", ")}.`}}async function _(e){let t=d();try{await N(c(t),{recursive:!0})}catch(o){throw u(c(t),o)}let n=await $();n==="broken"&&await M(t,`${t}.bak`).catch(o=>{throw u(c(t),o)});let r=typeof n=="object"?{...n}:{};for(let[o,f]of Object.entries(e))f!==void 0&&(r[o]=f);let i=`${t}.${process.pid}.tmp`;try{await j(i,`${JSON.stringify(r,null,2)}
|
|
4
|
+
`,"utf8"),await S(i,t)}catch(o){throw await D(i).catch(()=>{}),u(c(t),o)}}export{a,s as b,d as c,Q as d,V as e,_ as f};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{j as h}from"./chunk-NMGQGYVM.js";import{g as l}from"./chunk-6HUYBVQA.js";import{b as c}from"./chunk-KXKQDFHX.js";import{B as p,a as s,f as m,n,p as f}from"./chunk-CCNRNCRU.js";async function x(r,i=192){let t=await h(r);if(t.kind!=="image")throw f(r,n(s[t.format].label));let u=await l(r,t.format);try{let e=await c(),{data:o,info:a}=await e(u,{animated:!1}).rotate().resize(i,i,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:t,pixels:{width:a.width,height:a.height,rgba:new Uint8Array(o.buffer,o.byteOffset,o.length)}}}catch(e){throw m(e)?e:p(r,e)}}export{x as a};
|
|
@@ -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 d,c as S,d as
|
|
3
|
+
import{b as d,c as S,d as y,e as T,f as R,g as w}from"./chunk-EYOO35US.js";import{P as A}from"./chunk-CCNRNCRU.js";var I={set:"tailwind",start:50,end:950,count:11},C=["tailwind","even","radix"],F=[0,50,100,150,200,250,300,350,400,450],_=[550,600,650,700,750,800,850,900,950,1e3],D=Array.from({length:19},(e,r)=>r+3),v=[20,50,100,150,200,260,330,420,500,560,750,920],U=8;function k({set:e,start:r,end:t,count:o}){if(!C.includes(e))return`The set must be tailwind, even or radix; got ${e}.`;if(e!=="radix"){if(!F.includes(r))return r%50===0?`The start must be from 0 to 450, so the colour (500) stays in the scale; got ${r}.`:`The start must be a multiple of 50; got ${r}.`;if(!_.includes(t))return t%50===0?`The end must be from 550 to 1000, so the colour (500) stays in the scale; got ${t}.`:`The end must be a multiple of 50; got ${t}.`;if(e==="even"&&!D.includes(o))return`An even set has 3 to 21 steps; got ${o}.`}}function x(e){let{set:r,start:t,end:o,count:n}=e;if(r==="radix")return v.map((m,l)=>({step:l+1,at:m}));if(r==="tailwind"){let m=new Set([t,o,500]);for(let l=Math.ceil((t+1)/100)*100;l<o;l+=100)m.add(l);return[...m].sort((l,c)=>l-c).map(l=>({step:l,at:l}))}let s=n-1,b=Math.round(s*(500-t)/(o-t)),a=Math.max(1,Math.min(s-1,b)),i=s-a,u=[];for(let m=0;m<=a;m++)u.push(t+(500-t)*m/a);for(let m=1;m<=i;m++)u.push(500+(o-500)*m/i);for(let m of[10,5,1]){let l=u.map(c=>Math.round(c/m)*m);if(new Set(l).size===l.length)return u.map((c,f)=>({step:l[f],at:c}))}return u.map(m=>({step:m,at:m}))}function B(e){return x(e).map(r=>r.step)}var oe=B(I);function se(e){return e.set==="radix"?U:x(e).findIndex(r=>r.at===500)}var $=[[50,1],[100,.86],[200,.68],[300,.46],[400,.22],[500,0]],Y=[[500,0],[600,.2],[700,.4],[800,.6],[900,.8],[950,1]];function G(e,r){for(let t=1;t<e.length;t++){let[o,n]=e[t-1],[s,b]=e[t];if(r<=s)return n+(b-n)*(r-o)/(s-o)}return e[e.length-1][1]}var H=.995,V=.35,W=5e-4;function ae(e,r=I){let t=k(r);if(t)throw A(t,"Try: Tailwind, from 50 to 950.");let{L:o,C:n,h:s}=R(S(e)),b=n<W,a=Math.max(.975,o),i=o<.16?.42*o:Math.max(.16,.42*o),u=x(r),m=u[u.length-1]?.at===1e3;return u.map(({step:l,at:c})=>{if(c===500)return{step:l,at:c,rgb:{...e},hex:d(e),reference:!0};let f,p;if(c>=50&&c<500){let h=G($,c);f=o+(a-o)*h,p=n*(1-.88*h)}else if(c<50){let h=(50-c)/50;f=a+(Math.max(H,a)-a)*h,p=n*.12*(1-h)}else if(c<=950||m){let h=m?(c-500)/500:G(Y,c);f=o-(o-i)*h,p=n*(1-.45*h)}else{let h=(c-950)/50;f=i*(1-V*h),p=n*.55*(1-.4*h)}for(b&&(p=0);p>0&&!T(w({L:f,C:p,h:s}));)p-=.002;let g=y(w({L:f,C:Math.max(0,p),h:s}));return{step:l,at:c,rgb:g,hex:d(g),reference:!1}})}var E=(e,r,t)=>(e.L[r]-t[0])**2+(e.A[r]-t[1])**2+(e.B[r]-t[2])**2;function X(e,r){let t=e.L.length,o=[0,0,0];for(let b=0;b<t;b++)o[0]+=e.L[b],o[1]+=e.A[b],o[2]+=e.B[b];let n=[[o[0]/t,o[1]/t,o[2]/t]],s=new Float64Array(t).fill(Number.POSITIVE_INFINITY);for(;n.length<r;){let b=n[n.length-1],a=0,i=-1;for(let u=0;u<t;u++){let m=E(e,u,b);m<s[u]&&(s[u]=m),s[u]>i&&(i=s[u],a=u)}n.push([e.L[a],e.A[a],e.B[a]])}return n}function P(e,r,t){let o=0,n=Number.POSITIVE_INFINITY;for(let s=0;s<t.length;s++){let b=E(e,r,t[s]);b<n&&(n=b,o=s)}return o}function q(e,r){let t=e.L.length,o=X(e,r),n=new Int32Array(t).fill(-1);for(let b=0;b<30;b++){let a=0;for(let u=0;u<t;u++){let m=P(e,u,o);n[u]!==m&&(n[u]=m,a++)}let i=o.map(()=>[0,0,0,0]);for(let u=0;u<t;u++){let m=i[n[u]];m[0]=m[0]+e.L[u],m[1]=m[1]+e.A[u],m[2]=m[2]+e.B[u],m[3]=m[3]+1}if(i.forEach(([u,m,l,c],f)=>{c&&(o[f]=[u/c,m/c,l/c])}),a===0)break}let s=o.map(b=>({centre:b,members:[]}));for(let b=0;b<t;b++)s[n[b]]?.members.push(b);return s.filter(b=>b.members.length>0)}function z(e,r){let t=e;for(;;){let o,n=r**2;for(let c=0;c<t.length;c++)for(let f=c+1;f<t.length;f++){let p=t[c].centre,g=t[f].centre,h=(p[0]-g[0])**2+(p[1]-g[1])**2+(p[2]-g[2])**2;h<n&&(n=h,o=[c,f])}if(!o)return t;let[s,b]=o,a=t[s],i=t[b],u=a.members.length,m=i.members.length,l=a.centre.map((c,f)=>(c*u+i.centre[f]*m)/(u+m));t=t.filter((c,f)=>f!==s&&f!==b),t.push({centre:l,members:[...a.members,...i.members]})}}function Q(e,r,t){let o=e.L.length,n=[...r].sort((a,i)=>i.members.length-a.members.length),s=n.filter((a,i)=>i===0||a.members.length/o>=t),b=s.map(a=>a.centre);for(let a of n)if(!s.includes(a))for(let i of a.members)s[P(e,i,b)].members.push(i);return s}function M(e,r,t,o){let n=e.length;if(n===0)return[];let s={L:e,A:r,B:t},b=z(q(s,Math.min(o.k,n)),o.merge);return Q(s,b,o.minShare)}var j={k:8,merge:.06,minShare:.015},J={k:4,merge:.03,minShare:.02},K=-1,Z=-2,L=128,ee=64,O=(e,r)=>({r:e.rgba[r*4],g:e.rgba[r*4+1],b:e.rgba[r*4+2]});function N(e,r,t){let o=r.length,n=new Float64Array(o),s=new Float64Array(o),b=new Float64Array(o);return r.forEach((a,i)=>{let u=S(O(e,a));n[i]=u.L,s[i]=u.a,b[i]=u.b}),M(n,s,b,t).map(a=>{let i=a.members[0],u=Number.POSITIVE_INFINITY;for(let l of a.members){let c=(n[l]-a.centre[0])**2+(s[l]-a.centre[1])**2+(b[l]-a.centre[2])**2;c<u&&(u=c,i=l)}let m=O(e,r[i]);return{rgb:m,hex:d(m),share:a.members.length/o,centre:{L:a.centre[0],a:a.centre[1],b:a.centre[2]},members:Uint32Array.from(a.members.map(l=>r[l])).sort()}}).sort((a,i)=>i.share-a.share||(a.hex<i.hex?-1:1))}function ce(e){let r=[];for(let t=0;t<e.width*e.height;t++)e.rgba[t*4+3]>=L&&r.push(t);return N(e,r,j)}function te(e,r){return N(e,[...r.members],J)}function le(e,r){return r.members.length>=ee&&te(e,r).length>1}function fe(e){let r=e.map(n=>n*100),t=r.map(Math.floor),o=Math.round(r.reduce((n,s)=>n+s,0))-t.reduce((n,s)=>n+s,0);return r.map((n,s)=>[n-Math.floor(n),s]).sort((n,s)=>s[0]-n[0]||n[1]-s[1]).forEach(([,n])=>{o-- >0&&(t[n]=t[n]+1)}),t}function he(e,r,t=24){let o=new Int32Array(e.width*e.height).fill(Z);r.forEach((a,i)=>{for(let u of a.members)o[u]=i});let n=e.width>=e.height,s=n?t:Math.max(1,Math.round(t*e.width/e.height)),b=n?Math.max(1,Math.round(t*e.height/e.width)):t;return Array.from({length:b},(a,i)=>Array.from({length:s},(u,m)=>{let l=Math.min(e.width-1,Math.floor((m+.5)*e.width/s)),f=Math.min(e.height-1,Math.floor((i+.5)*e.height/b))*e.width+l;return e.rgba[f*4+3]<L?K:o[f]}))}export{I as a,C as b,F as c,_ as d,D as e,x as f,B as g,se as h,ae as i,K as j,Z as k,ce as l,te as m,le as n,fe as o,he as p};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as Q,b as X,f as Y}from"./chunk-YBA6DJQ4.js";import{b as J,c as W,m as A,n as O,o as $,q,r as N,t as C,u as _,w as H,x as U,y as V}from"./chunk-UI4EUC3S.js";import{b as j}from"./chunk-QIMSNTKL.js";import{b as G}from"./chunk-ECA4PW5T.js";import{d as S}from"./chunk-QPUKPSPZ.js";import{a as L}from"./chunk-PISCJKIG.js";import{f as K,g as T,h as D}from"./chunk-FWVE3GNA.js";import{b as P}from"./chunk-UN5DSJE2.js";import{a as R}from"./chunk-CCNRNCRU.js";import{a as z}from"./chunk-FGR6QCG5.js";import{existsSync as ye}from"node:fs";import{existsSync as M}from"node:fs";import{basename as re,dirname as se,extname as ie,join as ae}from"node:path";var le={images:"an image",pdfs:"a PDF",documents:"a document",videos:"a video",audio:"audio",other:"a file Forge reads"};function ce(e){let t=Object.keys(e).filter(s=>e[s]);if(t.length===0)return"not supported";let o=t.map(s=>le[s]);return`not ${o.length===1?o[0]:`${o.slice(0,-1).join(", ")} or ${o.at(-1)}`}`}function fe(e){return e.kind==="document"?e.format==="pdf"?"no images to shrink":"nothing to compress":`${R[e.format].label} is lossless`}function de(e,t,o){if(e.kind!=="image")return{left:"images only"};let s=e,r=o===void 0?{}:{output:o};if(t.tool==="sharpen"||t.tool==="boost"){let l=t.tool==="sharpen"?1:t.scale??2;if(K(s.width,s.height,l))return{left:l===1?"too large":`too large for ${l}\xD7`};let[c]=J.plan([s],{scale:String(l),target:S(s),...r});return c?{job:c}:{left:"not supported"}}if(t.tool==="cutout"){let[l]=W.plan([s],{target:"png",...r});return l?{job:l}:{left:"not supported"}}if(t.tool==="rotate"){if(s.frames>1)return{left:"animated"};let[l]=H.plan([s],{turn:t.turn??90,...r});return l?{job:l}:{left:"not supported"}}if(t.tool==="deband"){if(s.frames>1)return{left:"animated"};let[l]=V.plan([s],{deband:t.level??T[D].id,target:S(s),...r});return l?{job:l}:{left:"not supported"}}if(t.tool==="dither"){if(!N(s))return{left:"animated"};let[l]=U.plan([s],{dither:t.colours??$[0],target:q(s),...r});return l?{job:l}:{left:"not supported"}}if(t.tool==="trim"&&s.frames>1)return{left:"animated"};let n=t.tool==="trim"?C:_,[i]=n.plan([s],{target:S(s),...t.resize?{resize:t.resize}:{},...r});return i?{job:i}:{left:"not supported"}}function ue(e,t,o){if(t.op==="edit")return de(e,t,o);if(e.kind==="media")return{left:"one at a time"};let s=o===void 0?{}:{destination:o};if(t.op==="compress"){if(!A.appliesTo([e]))return{left:fe(e)};if(t.targetBytes!==void 0&&e.bytes<=t.targetBytes)return{left:"already under that size"};let[i]=A.plan([e],{mode:t.targetBytes===void 0?"quality":"size",...t.quality===void 0?{}:{quality:t.quality},...s});return i?{job:i}:{left:"not supported"}}let r=t.answers[X(e)];if(!r)return{left:ce(t.answers)};if(e.format===r.target)return{left:`already ${R[r.target].label}`};if(!L(e).includes(r.target))return{left:`can\u2019t become ${R[r.target].label}`};let[n]=O.plan([e],{target:r.target,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:String(r.dpi)},pages:"all",...s});return n?.op==="convert"?{job:n}:{left:"not supported"}}function pe(e,t){if(!t(e))return e;let o=ie(e),s=re(e,o);for(let r=1;;r++){let n=ae(se(e),P(s,` (${r})${o}`));if(!t(n)&&!M(n))return n}}function me(e,t,o,s={}){let r=s.existing??"leave",n=ue(e,t,s.destination);if(!("job"in n))return n;let{job:i}=n,l=i.outputs.some(f=>M(f)&&!o.has(f));if(l&&r==="leave")return{left:t.op==="compress"?"already compressed":t.op==="edit"?"already edited":"already converted"};let c=r==="number"?f=>o.has(f)||M(f):f=>o.has(f);i.outputs=i.outputs.map(f=>pe(f,c));for(let f of i.outputs)o.add(f);return l&&r==="ask"?{job:i,taken:!0}:{job:i}}function F(e,t,o,s={}){let r=[],n=[],i=[];for(let l of e){let c=me(l,t,o,s);"job"in c?(r.push(c.job),c.taken&&i.push(c.job)):n.push({path:l.path,reason:c.left})}return{jobs:r,left:n,taken:i}}async function Z(e,t,o={}){let s=new Set,r=o.existing??"leave",{jobs:n,left:i}=F(e,t,s,{destination:o.destination,existing:r});return{outcome:await j(n,{force:r==="replace",...t.op==="compress"&&t.targetBytes!==void 0?{targetBytes:t.targetBytes}:{},...o.concurrency===void 0?{}:{concurrency:o.concurrency},...o.onEvent?{onEvent:o.onEvent}:{},...o.signal?{signal:o.signal}:{}}),left:i,claimed:s,jobs:n}}function ee(e,t){let{outcome:o,left:s}=t,r=new Map;for(let n of o.results){let i=n.job.sources[0].path;r.set(i,{path:i,state:"done",result:n})}for(let n of[...o.refusals,...o.failures])if(n.error.code==="cannot-compress-more"){let i=n.error.short==="nothing written"?"can\u2019t get smaller":"already under that size";r.set(n.path,{path:n.path,state:"left",reason:i})}else n.error.code==="nothing-to-trim"?r.set(n.path,{path:n.path,state:"left",reason:"no empty edges"}):n.error.code==="no-sound"?r.set(n.path,{path:n.path,state:"left",reason:"no sound"}):r.set(n.path,{path:n.path,state:"failed",reason:n.error.title.toLowerCase()});for(let n of o.unreachable){let i=n.job.sources[0].path;r.set(i,{path:i,state:"left",reason:`can\u2019t get below ${z(n.smallest)}`})}for(let n of s)r.set(n.path,{path:n.path,state:"left",reason:n.reason});return e.map(n=>r.get(n.path)??{path:n.path,state:"left",reason:o.cancelled?"stopped":"not run"})}import{watch as ge}from"node:fs";import{readdir as he,stat as te}from"node:fs/promises";import{join as be,resolve as k}from"node:path";function ne(e,t,o){let s=k(e),r=o.settleMs??1e3,n=o.pollMs??500,i=new Set([...t].map(u=>k(u))),l=new Map,c=new Map,f=!1,v=!1,x=!1,y=async()=>{if(!f){if(v){x=!0;return}v=!0;try{let u=await he(s,{withFileTypes:!0}).catch(()=>[]),d=new Set;for(let p of u){if(!p.isFile()||Q(p.name))continue;let g=be(s,p.name);if(d.add(g),i.has(g)||o.ignore?.(g))continue;let h=await te(g).catch(()=>{});if(!h||f)continue;let w=Date.now(),b=c.get(g);if(b){if(b.size===h.size&&b.mtimeMs===h.mtimeMs)continue;c.delete(g)}let m=l.get(g);if(!m||m.size!==h.size||m.mtimeMs!==h.mtimeMs){l.set(g,{size:h.size,mtimeMs:h.mtimeMs,since:w});continue}w-m.since<r||(l.delete(g),i.add(g),o.onFile(g))}for(let p of[...i,...l.keys(),...c.keys()])d.has(p)||(i.delete(p),l.delete(p),c.delete(p))}finally{v=!1,x&&!f&&(x=!1,y())}}},E=setInterval(()=>{y()},n),a;try{a=ge(s,{persistent:!1},()=>{y()}),a.on("error",()=>{})}catch{}return y(),{again(u){let d=k(u);f||!i.has(d)||te(d).then(p=>{f||!i.has(d)||(i.delete(d),c.set(d,{size:p.size,mtimeMs:p.mtimeMs}))}).catch(()=>{})},close(){f=!0,clearInterval(E),a?.close()}}}var I=e=>"op"in e&&(e.op==="convert"||e.op==="compress"||e.op==="edit")?e:{op:"convert",answers:e};function ve(e,t,o,s){let{jobs:r,left:n}=F(e,I(t),o,{destination:s});return{jobs:r,left:n}}async function Ge(e,t,o={}){return Z(e.sources,I(t),o)}var we=(e,t)=>e==="other"?t==="text"?"a text file":"not supported":"not yet supported";function Qe(e){let t=G(e.concurrency),o=I(e.answers),s=[],r=new Set,n=!1,i=e.holdMs??4e3,l=new Map,c=new Map,f=a=>{let u=c.get(a);u&&(clearTimeout(u.timer),c.delete(a),e.onEvent({type:"failed",path:a,error:u.error}))},v=(a,u)=>{E.again(a);let d=Math.max(0,(l.get(a)??0)+i-Date.now());c.set(a,{error:u,timer:setTimeout(()=>f(a),d)})},x=async a=>{let u=c.get(a);u?(clearTimeout(u.timer),c.delete(a)):e.onEvent({type:"arrived",path:a}),e.onEvent({type:"phase",path:a,phase:"reading"});let d=await Y(a);if(d.kind==="failed"){v(a,d.failure.error);return}if(d.kind!=="source"){e.onEvent({type:"left",path:a,reason:we(d.kind,d.sniffed)});return}let{jobs:p,left:g}=ve([d.source],o,e.claimed,e.destination),[h]=g;if(h){e.onEvent({type:"left",path:a,reason:h.reason});return}let w=await j(p,{force:!1,concurrency:1,...o.op==="compress"&&o.targetBytes!==void 0?{targetBytes:o.targetBytes}:{},onEvent:m=>{m.type==="job:phase"&&"phase"in m.progress&&m.progress.phase!=="page"&&m.progress.phase!=="time"&&m.progress.phase!=="tiles"&&e.onEvent({type:"phase",path:a,phase:m.progress.phase,job:m.job})}}),[b]=ee([d.source],{outcome:w,left:[],claimed:e.claimed,jobs:p});if(b?.result)e.onEvent({type:"converted",path:a,result:b.result});else if(b?.state==="left")e.onEvent({type:"left",path:a,reason:b.reason??""});else{let m=[...w.refusals,...w.failures][0];if(m){for(let B of p.flatMap(oe=>oe.outputs))ye(B)||e.claimed.delete(B);v(a,m.error)}}},y=()=>{for(;!n&&r.size<t&&s.length>0;){let a=s.shift(),u=x(a).catch(()=>{}).finally(()=>{r.delete(u),y()});r.add(u)}},E=ne(e.dir,e.known,{...e.settleMs===void 0?{}:{settleMs:e.settleMs},...e.pollMs===void 0?{}:{pollMs:e.pollMs},ignore:a=>e.claimed.has(a),onFile:a=>{l.set(a,Date.now()),s.push(a),y()}});return{async stop(){n=!0,E.close(),s.length=0,await Promise.all([...r]);for(let a of[...c.keys()])f(a)}}}export{F as a,ee as b,Ge as c,Qe as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as i,c as n}from"./chunk-PON65UTS.js";import{q as e,r}from"./chunk-UN5DSJE2.js";var o=0;async function a(t){o++;try{return await t}finally{o--}}function p(){return o>0||n()>0||e().length>0}function f(){i(),r()}export{a,p as b,f as c};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{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};
|
|
3
|
+
import{b as P}from"./chunk-KXKQDFHX.js";import{t as S,u as U}from"./chunk-CCNRNCRU.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-3DX3SROY.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-3DX3SROY.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};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as Mt}from"./chunk-KXKQDFHX.js";var ln=new RegExp("\\p{M}","u"),Ut=new RegExp("\\p{L}","u"),hn=new RegExp("\\p{Nd}","u");function Ft(t){let r=String.fromCodePoint(t);return ln.test(r)?"NSM":t>=1632&&t<=1641||t===1643||t===1644?"AN":hn.test(r)?"EN":t>=1424&&t<=1535||t>=64285&&t<=64335?Ut.test(r)?"R":"ON":t>=1536&&t<=1791||t>=1792&&t<=1983||t>=1872&&t<=1919||t>=2208&&t<=2303||t>=64336&&t<=65023||t>=65136&&t<=65279?Ut.test(r)?"AL":"ON":Ut.test(r)?"L":t===43||t===45?"ES":t===35||t===36||t===37||t===162||t===163||t===176?"ET":t===44||t===46||t===58||t===47||t===160?"CS":r===" "||r===" "||t===12288?"WS":"ON"}var dn={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","<":">",">":"<","\xAB":"\xBB","\xBB":"\xAB"};function kt(t){for(let r of t){let n=Ft(r.codePointAt(0)??0);if(n==="R"||n==="AL")return!0;if(n==="L")return!1}return!1}function gn(t){for(let r of t){let n=Ft(r.codePointAt(0)??0);if(n==="R"||n==="AL"||n==="AN")return!0}return!1}function Dt(t,r){let n=[...t];if(!r&&!gn(t))return t;let i=n.length,e=n.map(s=>Ft(s.codePointAt(0)??0)),o=r?1:0,a=o?"R":"L";for(let s=0;s<i;s++){e[s]==="NSM"&&(e[s]=s>0?e[s-1]??"ON":o?"R":"L");let l=e[s];l==="L"||l==="R"||l==="AL"?a=l:l==="EN"&&a==="AL"&&(e[s]="AN")}for(let s=0;s<i;s++)e[s]==="AL"&&(e[s]="R");for(let s=1;s<i-1;s++){let l=e[s],d=e[s-1],u=e[s+1];(l==="ES"||l==="CS")&&d==="EN"&&u==="EN"?e[s]="EN":l==="CS"&&d==="AN"&&u==="AN"&&(e[s]="AN")}for(let s=0;s<i;s++){if(e[s]!=="ET")continue;let l=s;for(;l<i&&e[l]==="ET";)l++;if(e[s-1]==="EN"||e[l]==="EN")for(let d=s;d<l;d++)e[d]="EN";s=l-1}for(let s=0;s<i;s++)(e[s]==="ES"||e[s]==="ET"||e[s]==="CS")&&(e[s]="ON");let c=o?"R":"L";for(let s=0;s<i;s++)e[s]==="L"||e[s]==="R"?c=e[s]:e[s]==="EN"&&c==="L"&&(e[s]="L");let f=s=>s==="L"?"L":s==="R"||s==="EN"||s==="AN"?"R":void 0;for(let s=0;s<i;s++){if(e[s]!=="WS"&&e[s]!=="ON")continue;let l=s;for(;l<i&&(e[l]==="WS"||e[l]==="ON");)l++;let d=s>0?f(e[s-1]):o?"R":"L",u=l<i?f(e[l]):o?"R":"L",b=d!==void 0&&d===u?d:o?"R":"L";for(let y=s;y<l;y++)e[y]=b;s=l-1}let h=e.map(s=>o===0?s==="R"?1:s==="EN"||s==="AN"?2:0:s==="L"||s==="EN"||s==="AN"?2:1),g=n.map((s,l)=>l),m=Math.max(...h),p=Math.min(...h.filter(s=>s%2===1),Number.POSITIVE_INFINITY);for(let s=m;s>=p&&s>0;s--)for(let l=0;l<i;l++){if((h[g[l]]??0)<s)continue;let d=l;for(;d<i&&(h[g[d]]??0)>=s;)d++;let u=g.slice(l,d).reverse();g.splice(l,d-l,...u),l=d-1}return g.map(s=>{let l=n[s];return(h[s]??0)%2===1?dn[l]??l:l}).join("")}var mn=[[65,90,"latin"],[97,122,"latin"],[170,170,"latin"],[186,186,"latin"],[192,591,"latin"],[7680,7935,"latin"],[11360,11391,"latin"],[42784,43007,"latin"],[65313,65338,"latin"],[65345,65370,"latin"],[880,1023,"greek"],[7936,8191,"greek"],[1024,1327,"cyrillic"],[7296,7311,"cyrillic"],[11744,11775,"cyrillic"],[42560,42655,"cyrillic"],[1328,1423,"armenian"],[1424,1535,"hebrew"],[64285,64335,"hebrew"],[1536,1791,"arabic"],[1872,1919,"arabic"],[2208,2303,"arabic"],[64336,65023,"arabic"],[65136,65279,"arabic"],[1792,1871,"syriac"],[1920,1983,"thaana"],[2304,2431,"devanagari"],[2432,2559,"bengali"],[2560,2687,"gurmukhi"],[2688,2815,"gujarati"],[2816,2943,"oriya"],[2944,3071,"tamil"],[3072,3199,"telugu"],[3200,3327,"kannada"],[3328,3455,"malayalam"],[3456,3583,"sinhala"],[3584,3711,"thai"],[3712,3839,"lao"],[3840,4095,"tibetan"],[4096,4255,"myanmar"],[4256,4351,"georgian"],[4352,4607,"hangul"],[4608,5023,"ethiopic"],[6016,6143,"khmer"],[6144,6319,"mongolian"],[12352,12447,"kana"],[12448,12543,"kana"],[12784,12799,"kana"],[65382,65439,"kana"],[110592,110959,"kana"],[12592,12687,"hangul"],[43360,43391,"hangul"],[44032,55295,"hangul"],[65440,65500,"hangul"],[11904,12255,"han"],[12288,12351,"han"],[12544,12591,"han"],[12704,12735,"han"],[12800,13311,"han"],[13312,19903,"han"],[19968,40959,"han"],[63744,64255,"han"],[65072,65103,"han"],[65281,65312,"han"],[65371,65381,"han"],[65504,65510,"han"],[131072,205743,"han"],[127744,129791,"emoji"],[9728,10175,"symbols"]];function Q(t){if(t<128)return t>=65&&t<=90||t>=97&&t<=122?"latin":void 0;for(let[r,n,i]of mn)if(t>=r&&t<=n)return i}var pn=new Set(["latin","greek","cyrillic","han","kana","hangul","armenian","georgian","ethiopic","emoji","symbols"]),It=new Set([...pn,"arabic","hebrew","thai","lao"]),bn={latin:"Latin",greek:"Greek",cyrillic:"Cyrillic",han:"Chinese",kana:"Japanese",hangul:"Korean",arabic:"Arabic",hebrew:"Hebrew",thai:"Thai",lao:"Lao",armenian:"Armenian",georgian:"Georgian",devanagari:"Devanagari",bengali:"Bengali",gurmukhi:"Gurmukhi",gujarati:"Gujarati",oriya:"Odia",tamil:"Tamil",telugu:"Telugu",kannada:"Kannada",malayalam:"Malayalam",sinhala:"Sinhala",tibetan:"Tibetan",myanmar:"Burmese",khmer:"Khmer",ethiopic:"Ethiopic",mongolian:"Mongolian",syriac:"Syriac",thaana:"Thaana",emoji:"emoji",symbols:"symbols"};function vt(t){return bn[t]}function xn(t){let r=new Set;for(let n of t){let i=Q(n.codePointAt(0)??0);i!==void 0&&r.add(i)}return[...r]}function Nt(t,r){let n=r?.toLowerCase().replace("_","-");if(n?.startsWith("ja"))return"ja";if(n?.startsWith("ko"))return"ko";if(n==="zh-tw"||n==="zh-hant"||n==="zh-hk")return"zh-TW";if(n?.startsWith("zh"))return"zh";let i=xn(t);return i.includes("kana")?"ja":i.includes("hangul")?"ko":"zh"}var yn={ja:"ja-JP",ko:"ko-KR",zh:"zh-CN","zh-TW":"zh-TW"},Sn={arabic:"ar-SA",hebrew:"he-IL",thai:"th-TH",lao:"lo-LA",devanagari:"hi-IN",bengali:"bn-IN",gurmukhi:"pa-IN",gujarati:"gu-IN",oriya:"or-IN",tamil:"ta-IN",telugu:"te-IN",kannada:"kn-IN",malayalam:"ml-IN",sinhala:"si-LK",khmer:"km-KH",myanmar:"my-MM",tibetan:"bo-CN",armenian:"hy-AM",georgian:"ka-GE",ethiopic:"am-ET",syriac:"syr-SY",thaana:"dv-MV"},An=new Set(["latin","greek","cyrillic","armenian","georgian","ethiopic","mongolian","emoji","symbols"]);function wn(t){return t===void 0?"neutral":t==="han"||t==="kana"||t==="hangul"?"eastAsia":An.has(t)?"latin":"complex"}var Un=new Set(["arabic","hebrew","syriac","thaana"]);function ke(t,r){let n=yn[Nt(t,r)],i=[],e="";for(let o of t){let a=Q(o.codePointAt(0)??0),c=wn(a);if(c==="neutral"){let m=i.at(-1);m?m.text+=o:e+=o;continue}let f=a!==void 0&&Un.has(a),h=c==="eastAsia"?n:c==="complex"&&a?Sn[a]:void 0,g=i.at(-1);g&&g.kind===c&&g.rtl===f&&g.lang===h?g.text+=o:i.push({text:e+o,kind:c,rtl:f,...h?{lang:h}:{}}),e=""}return e&&i.push({text:e,kind:"latin",rtl:!1}),i}import{existsSync as Jn,readFileSync as Xn}from"node:fs";import{dirname as qn,join as ct}from"node:path";import{fileURLToPath as Zn}from"node:url";import{gunzipSync as Qn}from"node:zlib";var tt=new Map;function Fn(){let t=new Map,r=[[64336,64511],[65152,65276]];for(let[n,i]of r)for(let e=n;e<=i;e++){let o=String.fromCodePoint(e).normalize("NFKD");if(o===String.fromCodePoint(e))continue;let a=t.get(o);a?a.push(e):t.set(o,[e])}for(let[n,i]of t)i.length===4?tt.set(n,{isolated:i[0]??0,final:i[1]??0,initial:i[2]??0,medial:i[3]??0}):i.length===2&&tt.set(n,{isolated:i[0]??0,final:i[1]??0,initial:0,medial:0})}Fn();var Ot=t=>t>=1611&&t<=1631||t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t===1767||t===1768||t>=1770&&t<=1773,jt=1604,kn=new Set([1570,1571,1573,1575]),_t=t=>tt.has(String.fromCodePoint(t)),zt=t=>(tt.get(String.fromCodePoint(t))?.initial??0)!==0;function Wt(t){for(let r of t)if(_t(r.codePointAt(0)??0))return!0;return!1}function $t(t,r=()=>!0){let n=[...t].map(o=>o.codePointAt(0)??0),i=[],e=!1;for(let o=0;o<n.length;o++){let a=n[o]??0;if(a===8204||a===8205){e=a===8205?e:!1,i.push(a);continue}if(Ot(a)){i.push(a);continue}let c=tt.get(String.fromCodePoint(a));if(!c){e=!1,i.push(a);continue}let f=n[o+1]??0;if(a===jt&&kn.has(f)){let s=tt.get(String.fromCodePoint(jt,f)),l=s?e?s.final:s.isolated:0;if(l!==0&&r(l)){i.push(l),e=!1,o++;continue}}let h=o+1;for(;h<n.length&&Ot(n[h]??0);)h++;let g=n[h]??0,m=zt(a)&&g!==8204&&(_t(g)||g===8205),p=e?m?c.medial:c.final:m?c.initial:c.isolated;i.push(p!==0&&r(p)?p:a),e=zt(a)}return String.fromCodePoint(...i)}function Ht(t){return String.fromCodePoint(t).normalize("NFKD")}import{execFile as vn}from"node:child_process";import{existsSync as On,readdirSync as jn,readFileSync as zn,statSync as _n}from"node:fs";import{homedir as Wn}from"node:os";import{posix as Rt,win32 as en}from"node:path";var E={charset:15,encoding:16,charStrings:17,private:18,subrs:19,ros:1230,fdArray:1236,fdSelect:1237};function J(t,r){let n=(t[r]??0)*256+(t[r+1]??0);if(n===0)return{items:[],end:r+2};let i=t[r+2]??1,e=[],o=r+3;for(let f=0;f<=n;f++){let h=0;for(let g=0;g<i;g++)h=h*256+(t[o+g]??0);e.push(h),o+=i}let a=o-1,c=[];for(let f=0;f<n;f++)c.push(t.subarray(a+(e[f]??0),a+(e[f+1]??0)));return{items:c,end:a+(e[n]??1)}}function X(t){if(t.length===0)return new Uint8Array([0,0]);let r=t.reduce((c,f)=>c+f.length,0)+1,n=r<256?1:r<65536?2:r<16777216?3:4,i=new Uint8Array(3+(t.length+1)*n+r-1);i[0]=t.length>>8,i[1]=t.length&255,i[2]=n;let e=1,o=3,a=c=>{for(let f=n-1;f>=0;f--)i[o++]=c>>8*f&255};a(e);for(let c of t)e+=c.length,a(e);for(let c of t)i.set(c,o),o+=c.length;return i}function Pt(t){let r=[],n=[],i=0,e=0;for(;e<t.length;){let o=t[e]??0;if(o<=21){let a=o;e++,o===12&&(a=1200+(t[e]??0),e++),r.push({op:a,operands:n,raw:t.subarray(i,e)}),n=[],i=e}else if(o===28)n.push(((t[e+1]??0)<<8|(t[e+2]??0))<<16>>16),e+=3;else if(o===29)n.push((t[e+1]??0)<<24|(t[e+2]??0)<<16|(t[e+3]??0)<<8|(t[e+4]??0)),e+=5;else if(o===30){for(e++;e<t.length&&((t[e]??0)&15)!==15&&(t[e]??0)>>4!==15;)e++;e++,n.push(0)}else o>=32&&o<=246?(n.push(o-139),e++):o>=247&&o<=250?(n.push((o-247)*256+(t[e+1]??0)+108),e+=2):o>=251&&o<=254?(n.push(-(o-251)*256-(t[e+1]??0)-108),e+=2):e++}return r}function Nn(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]}function Pn(t){return t>=1200?[12,t-1200]:[t]}function B(t,r){return Uint8Array.from([...r.flatMap(Nn),...Pn(t)])}function pt(t){let r=new Uint8Array(t.reduce((i,e)=>i+e.length,0)),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}var q=(t,r)=>t.find(n=>n.op===r);function Gt(t){return t<1240?107:t<33900?1131:32768}function Bt(t){let r=t[2]??4,n=J(t,r),i=J(t,n.end),e=J(t,i.end),o=J(t,e.end),a=Pt(i.items[0]??new Uint8Array),c=q(a,E.ros)!==void 0,f=q(a,E.charStrings)?.operands[0]??0,h=J(t,f),g=h.items.length,m=q(a,E.charset)?.operands[0]??0,p=new Array(g).fill(0);if(m<=2)for(let F=0;F<g;F++)p[F]=F;else{let F=t[m]??0,S=m+1,U=1;if(F===0)for(;U<g;U++,S+=2)p[U]=(t[S]??0)<<8|(t[S+1]??0);else for(;U<g;){let C=(t[S]??0)<<8|(t[S+1]??0),N=t[S+2]??0;S+=3,F===2&&(N=N<<8|(t[S]??0),S++);for(let D=0;D<=N&&U<g;D++,U++)p[U]=C+D}}let s=q(a,E.fdArray)?.operands[0],l=q(a,E.fdSelect)?.operands[0],d=s===void 0?[]:J(t,s).items.map(Pt),u=new Array(g).fill(0);if(l!==void 0)if((t[l]??0)===0)for(let S=0;S<g;S++)u[S]=t[l+1+S]??0;else{let S=(t[l+1]??0)<<8|(t[l+2]??0),U=l+3;for(let C=0;C<S;C++,U+=3){let N=(t[U]??0)<<8|(t[U+1]??0),D=(t[U+3]??0)<<8|(t[U+4]??0);for(let v=N;v<D&&v<g;v++)u[v]=t[U+2]??0}}let b=F=>{let[S,U]=q(F,E.private)?.operands??[];if(S===void 0||U===void 0)return{dict:[],subrs:[]};let C=Pt(t.subarray(U,U+S)),N=q(C,E.subrs)?.operands[0];return{dict:C,subrs:N===void 0?[]:J(t,U+N).items}},y=b(a),k=d.length>0?d.map(b):[y];return{cidKeyed:c,glyphCount:g,codeOf:F=>c?p[F]??0:F,subset(F){let S=new Set([0]);for(let x of F)x>=0&&x<g&&S.add(x);let U=Math.max(...S)+1,C=new Map;for(let x of S){let R=Tn(h.items[x]??new Uint8Array,(k[u[x]??0]??y).subrs,o.items);if(!R){C.clear();break}C.set(x,R)}let N=C.size===S.size,D=k.map(()=>new Set),v=new Set;if(!N)for(let x of S)Cn(h.items[x]??new Uint8Array,k[u[x]??0]??y,{local:D[u[x]??0]??new Set,global:v,gsubrs:o.items});let H=x=>N?C.get(x):h.items[x],K=new Uint8Array([14]),A=new Uint8Array([11]),w=c?[...S].sort((x,R)=>x-R):Array.from({length:U},(x,R)=>R),W=(x,R)=>{if(R.size===0)return[];let _=x.length>=33900?33900:x.length>=1240?1240:0,Y=Math.max(...R)+1;return x.slice(0,Math.max(Y,_)).map((ft,At)=>R.has(At)?ft:A)},L=X(N?[]:W(o.items,v)),$=X(w.map(x=>S.has(x)?H(x)??K:K)),T=Rn(w.map(x=>p[x]??0)),I=d.length>0?En(w.map(x=>u[x]??0)):void 0,G=k.map((x,R)=>{let _=X(N?[]:W(x.subrs,D[R]??new Set)),Y=x.dict.filter(wt=>wt.op!==E.subrs).map(wt=>wt.raw),ft=!N&&x.subrs.length>0,At=ft?B(E.subrs,[0]):new Uint8Array,un=pt([...Y]).length+At.length;return{dict:pt([...Y,...ft?[B(E.subrs,[un])]:[]]),subrs:ft?_:new Uint8Array}}),et=Uint8Array.from([1,0,4,4]),rt=X(n.items),it=X(e.items),ut=x=>{let R=[];for(let _ of a)_.op===E.charset?R.push(B(E.charset,[x.charset])):_.op===E.charStrings?R.push(B(E.charStrings,[x.charStrings])):_.op===E.fdArray?R.push(B(E.fdArray,[x.fdArray])):_.op===E.fdSelect?R.push(B(E.fdSelect,[x.fdSelect])):_.op===E.private?R.push(B(E.private,[...x.priv])):_.op===E.encoding?R.push(B(E.encoding,[0])):R.push(_.raw);return X([pt(R)])},lt=ut({charset:0,charStrings:0,fdArray:0,fdSelect:0,priv:[0,0]}).length,z=et.length+rt.length+lt+it.length+L.length,ht=z;z+=T.length;let dt=z;z+=I?.length??0;let gt=z;z+=$.length;let ot=x=>X(d.map((R,_)=>pt(R.map(Y=>Y.op===E.private?B(E.private,[...x[_]??[0,0]]):Y.raw)))),mt=z;z+=d.length>0?ot(d.map(()=>[0,0])).length:0;let P=[];for(let x of G)P.push([x.dict.length,z]),z+=x.dict.length+x.subrs.length;let O=ut({charset:ht,charStrings:gt,fdArray:mt,fdSelect:dt,priv:P[0]??[0,0]}),st=[et,rt,O,it,L,T,...I?[I]:[],$,...d.length>0?[ot(P)]:[],...G.flatMap(x=>[x.dict,x.subrs])],at=new Uint8Array(st.reduce((x,R)=>x+R.length,0)),V=0;for(let x of st)at.set(x,V),V+=x.length;return at}}}function Rn(t){let r=[2],n=1;for(;n<t.length;){let o=t[n]??0,a=0;for(;n+a+1<t.length&&(t[n+a+1]??0)===o+a+1;)a++;r.push(o>>8,o&255,a>>8,a&255),n+=a+1}let i=1+2*Math.max(0,t.length-1);if(r.length<=i)return Uint8Array.from(r);let e=[0];for(let o=1;o<t.length;o++)e.push((t[o]??0)>>8,(t[o]??0)&255);return Uint8Array.from(e)}function En(t){let r=[],n=-1,i=0;return t.forEach((e,o)=>{e!==n&&(r.push(o>>8,o&255,e),n=e,i++)}),Uint8Array.from([3,i>>8,i&255,...r,t.length>>8,t.length&255])}function Tn(t,r,n){let i=[],e=[],o=[],a=[],c=0,f=!1,h=()=>{e.length=0,o.length=0,a.length=0},g=(s,l)=>{e.push(i.length),o.push(l.length),a.push(s),i.push(...l)},m=(s,l)=>{if(l>10)return f=!0,!0;let d=0;for(;d<s.length&&!f;){let u=s[d]??0;if(d++,u===28){let b=[28,s[d]??0,s[d+1]??0];g(((s[d]??0)<<8|(s[d+1]??0))<<16>>16,b),d+=2}else if(u>=32&&u<=246)g(u-139,[u]);else if(u>=247&&u<=250)g((u-247)*256+(s[d]??0)+108,[u,s[d]??0]),d++;else if(u>=251&&u<=254)g(-(u-251)*256-(s[d]??0)-108,[u,s[d]??0]),d++;else if(u===255)g(0,[255,s[d]??0,s[d+1]??0,s[d+2]??0,s[d+3]??0]),d+=4;else if(u===10||u===29){let b=u===10?r:n,y=a.pop(),k=e.pop(),F=o.pop();if(y===void 0||k===void 0||F===void 0||k+F!==i.length)return f=!0,!0;let S=b[y+Gt(b.length)];if(S===void 0)return f=!0,!0;if(i.length=k,m(S,l+1))return!0}else{if(u===11)return!1;if(u===14)return i.push(14),!0;if(u===1||u===3||u===18||u===23)c+=a.length>>1,h(),i.push(u);else if(u===19||u===20){c+=a.length>>1,h();let b=c+7>>3;i.push(u,...Array.from(s.subarray(d,d+b))),d+=b}else if(u===12){let b=s[d++]??0;if(b>=34&&b<=37)h(),i.push(12,b);else return f=!0,!0}else h(),i.push(u)}}return!1},p=m(t,0);if(!f)return p||i.push(14),Uint8Array.from(i)}function Cn(t,r,n){let i=new Set,e=!1,o=0,a=[],c=(f,h)=>{if(h>10)return e=!0,!0;let g=0;for(;g<f.length;){let m=f[g]??0;if(g++,m>=32||m===28){m===28?(a.push(((f[g]??0)<<8|(f[g+1]??0))<<16>>16),g+=2):m<=246?a.push(m-139):m<=250?a.push((m-247)*256+(f[g++]??0)+108):m<=254?a.push(-(m-251)*256-(f[g++]??0)-108):(a.push(((f[g]??0)<<24|(f[g+1]??0)<<16|(f[g+2]??0)<<8|(f[g+3]??0))/65536),g+=4);continue}if(m===10||m===29){let p=m===10?r.subrs:n.gsubrs,s=a.pop();if(s===void 0)return e=!0,!0;let l=s+Gt(p.length),d=p[l];if(d===void 0)return e=!0,!0;let u=`${m}:${l}:${o}`;if(!i.has(u)&&(i.add(u),(m===10?n.local:n.global).add(l),c(d,h+1)))return!0;continue}if(m===11)return!1;if(m===14)return!0;if(m===1||m===3||m===18||m===23){o+=a.length>>1,a.length=0;continue}if(m===19||m===20){o+=a.length>>1,a.length=0,g+=o+7>>3;continue}if(m===12){let p=f[g++]??0;if(p>=34&&p<=37)a.length=0;else return e=!0,!0;continue}a.length=0}return!1};c(t,0),e&&(r.subrs.forEach((f,h)=>{n.local.add(h)}),n.gsubrs.forEach((f,h)=>{n.global.add(h)}))}var Vt=32,Yt=1,Jt=8,Xt=64,qt=128;function Zt(t){let r=new DataView(t.buffer,t.byteOffset,t.byteLength);return String.fromCharCode(...t.subarray(0,4))==="ttcf"?r.getUint32(8):1}function bt(t,r=0){let n=new DataView(t.buffer,t.byteOffset,t.byteLength),i=String.fromCharCode(...t.subarray(0,4))==="ttcf"?n.getUint32(12+r*4):0,e=new Map,o=n.getUint16(i+4);for(let A=0;A<o;A++){let w=i+12+A*16,W=String.fromCharCode(...t.subarray(w,w+4));e.set(W,{offset:n.getUint32(w+8),length:n.getUint32(w+12)})}let a=A=>{let w=e.get(A);if(!w)throw new Error(`font has no ${A} table`);return w},c=a("head").offset,f=n.getUint16(c+18),h=n.getInt16(c+50)===1,g=[n.getInt16(c+36),n.getInt16(c+38),n.getInt16(c+40),n.getInt16(c+42)],m=a("hhea").offset,p=n.getInt16(m+4),s=n.getInt16(m+6),l=n.getUint16(m+34),d=n.getUint16(a("maxp").offset+4),u=a("hmtx").offset,b=e.get("OS/2"),y=b&&n.getUint16(b.offset)>=2?n.getInt16(b.offset+88):Math.round(f*.714),k=Mn(n,a("cmap").offset),F=A=>n.getUint16(u+Math.min(A,l-1)*4),S=A=>A<l?n.getInt16(u+A*4+2):n.getInt16(u+l*4+(A-l)*2),U=A=>{let w=k(A);return w===void 0||w===0||w>=d?void 0:w},C=A=>{let w=a(A);return t.subarray(w.offset,w.offset+w.length)},N=e.get("CFF ");if(N){let A=Bt(t.subarray(N.offset,N.offset+N.length));return{unitsPerEm:f,ascent:p,descent:s,capHeight:y,bbox:g,outlines:"cff",variable:e.has("fvar"),cidKeyed:A.cidKeyed,glyphOf:U,codeOf:w=>A.codeOf(w),advance:F,subset:w=>({data:A.subset(w)})}}let D=a("loca").offset,v=a("glyf"),H=A=>h?[n.getUint32(D+A*4),n.getUint32(D+A*4+4)]:[n.getUint16(D+A*2)*2,n.getUint16(D+A*2+2)*2],K=A=>{let[w,W]=H(A);if(W<=w)return[];let L=v.offset+w;if(n.getInt16(L)>=0)return[];let $=[],T=L+10;for(;;){let I=n.getUint16(T);if($.push(n.getUint16(T+2)),T+=4+(I&Yt?4:2),I&Jt?T+=2:I&Xt?T+=4:I&qt&&(T+=8),!(I&Vt))break}return $};return{unitsPerEm:f,ascent:p,descent:s,capHeight:y,bbox:g,outlines:"glyf",variable:e.has("fvar"),cidKeyed:!1,glyphOf:U,codeOf:A=>A,advance:F,subset(A){let w=new Set,W=[0,...A];for(let P=W.pop();P!==void 0;P=W.pop())w.has(P)||(w.add(P),W.push(...K(P)));let L=[...w].sort((P,O)=>P-O),$=new Map(L.map((P,O)=>[P,O])),T=new Uint32Array(L.length+1),I=[],G=0;L.forEach((P,O)=>{T[O]=G;let[st,at]=H(P);if(at>st){let V=Uint8Array.from(t.subarray(v.offset+st,v.offset+at));new DataView(V.buffer).getInt16(0)<0&&Ln(V,$),I.push(V),G+=V.length;let x=(4-G%4)%4;x&&(I.push(new Uint8Array(x)),G+=x)}}),T[L.length]=G;let et=new Uint8Array(G),rt=0;for(let P of I)et.set(P,rt),rt+=P.length;let it=new Uint8Array((L.length+1)*4),ut=new DataView(it.buffer);T.forEach((P,O)=>{ut.setUint32(O*4,P)});let lt=new Uint8Array(L.length*4),z=new DataView(lt.buffer);L.forEach((P,O)=>{z.setUint16(O*4,F(P)),z.setInt16(O*4+2,S(P))});let ht=Uint8Array.from(t.subarray(c,c+a("head").length)),dt=new DataView(ht.buffer);dt.setUint32(8,0),dt.setInt16(50,1);let gt=Uint8Array.from(C("hhea"));new DataView(gt.buffer).setUint16(34,L.length);let ot=Uint8Array.from(C("maxp"));new DataView(ot.buffer).setUint16(4,L.length);let mt=new Uint16Array((L.at(-1)??0)+1);for(let[P,O]of $)mt[P]=O;return{data:In([["glyf",et],["head",ht],["hhea",gt],["hmtx",lt],["loca",it],["maxp",ot]]),cidToGid:mt}}}}function Ln(t,r){let n=new DataView(t.buffer,t.byteOffset,t.byteLength),i=10;for(;;){let e=n.getUint16(i);if(n.setUint16(i+2,r.get(n.getUint16(i+2))??0),i+=4+(e&Yt?4:2),e&Jt?i+=2:e&Xt?i+=4:e&qt&&(i+=8),!(e&Vt))break}}function Kt(t,r){let n=0,i=t.length-1,e=-1;for(;n<=i;){let o=n+i>>1;(t[o]??0)<=r?(e=o,n=o+1):i=o-1}return e}function Mn(t,r){let n=t.getUint16(r+2),i;for(let e=0;e<n;e++){let o=t.getUint16(r+4+e*8),a=t.getUint16(r+4+e*8+2),c=r+t.getUint32(r+4+e*8+4),f=t.getUint16(c);if(o===3&&(a===1||a===10)||o===0){if(f===12){let g=t.getUint32(c+12),m=new Uint32Array(g);for(let p=0;p<g;p++)m[p]=t.getUint32(c+16+p*12);return p=>{let s=Kt(m,p);if(s<0)return;let l=t.getUint32(c+16+s*12+4);if(!(p>l))return t.getUint32(c+16+s*12+8)+(p-(m[s]??0))}}if(f===4&&i===void 0){let g=t.getUint16(c+6)/2,m=c+14,p=m+g*2+2,s=p+g*2,l=s+g*2,d=new Uint32Array(g);for(let u=0;u<g;u++)d[u]=t.getUint16(p+u*2);i=u=>{if(u>65535)return;let b=Kt(d,u);if(b<0||u>t.getUint16(m+b*2))return;let y=t.getUint16(l+b*2);if(y===0)return u+t.getInt16(s+b*2)&65535;let k=t.getUint16(l+b*2+y+(u-(d[b]??0))*2);return k===0?void 0:k+t.getInt16(s+b*2)&65535}}}}if(i)return i;throw new Error("font has no Unicode cmap")}function Dn(t){let r=new Uint8Array(Math.ceil(t.length/4)*4);r.set(t);let n=new DataView(r.buffer),i=0;for(let e=0;e<r.length;e+=4)i=i+n.getUint32(e)>>>0;return i}function In(t){let r=[...t].sort(([f],[h])=>f<h?-1:1),n=12+r.length*16,i=r.reduce((f,[,h])=>f+Math.ceil(h.length/4)*4,n),e=new Uint8Array(i),o=new DataView(e.buffer);o.setUint32(0,65536),o.setUint16(4,r.length);let a=Math.floor(Math.log2(r.length));o.setUint16(6,2**a*16),o.setUint16(8,a),o.setUint16(10,r.length*16-2**a*16);let c=n;return r.forEach(([f,h],g)=>{let m=12+g*16;e.set(new TextEncoder().encode(f),m),o.setUint32(m+4,Dn(h)),o.setUint32(m+8,c),o.setUint32(m+12,h.length),e.set(h,c),c+=Math.ceil(h.length/4)*4}),e}var xt={platform:process.platform,env:process.env,home:Wn(),exists:t=>On(t),list:t=>{try{return jn(t)}catch{return[]}},run:(t,r)=>new Promise(n=>{vn(t,r,{timeout:5e3,windowsHide:!0,maxBuffer:4e6},(i,e)=>n(i?void 0:e))}),read:t=>{try{return _n(t).size>1e8?void 0:zn(t)}catch{return}}},$n={zh:[["msyh.ttc",0],["simsun.ttc",0],["simhei.ttf",0],["Deng.ttf",0],["arialuni.ttf",0]],"zh-TW":[["msjh.ttc",0],["mingliu.ttc",0],["msyh.ttc",0],["arialuni.ttf",0]],ja:[["YuGothR.ttc",0],["YuGothM.ttc",0],["meiryo.ttc",0],["msgothic.ttc",0],["msmincho.ttc",0],["arialuni.ttf",0]],ko:[["malgun.ttf",0],["gulim.ttc",0],["batang.ttc",0],["arialuni.ttf",0]],arabic:[["segoeui.ttf",0],["arial.ttf",0],["tahoma.ttf",0],["times.ttf",0],["arialuni.ttf",0]],hebrew:[["segoeui.ttf",0],["arial.ttf",0],["tahoma.ttf",0],["times.ttf",0],["arialuni.ttf",0]],thai:[["LeelawUI.ttf",0],["leelawad.ttf",0],["tahoma.ttf",0],["arialuni.ttf",0]],other:[["seguisym.ttf",0],["segoeui.ttf",0],["arial.ttf",0],["arialuni.ttf",0],["malgun.ttf",0],["msyh.ttc",0]]},Hn={zh:[["PingFang.ttc",0],["STHeiti Light.ttc",1],["Hiragino Sans GB.ttc",0],["Arial Unicode.ttf",0]],"zh-TW":[["PingFang.ttc",2],["STHeiti Light.ttc",0],["Hiragino Sans GB.ttc",0],["Arial Unicode.ttf",0]],ja:[["\u30D2\u30E9\u30AE\u30CE\u89D2\u30B4\u30B7\u30C3\u30AF W3.ttc",0],["Hiragino Sans GB.ttc",0],["AquaKana.ttc",0],["Arial Unicode.ttf",0]],ko:[["AppleSDGothicNeo.ttc",0],["Arial Unicode.ttf",0]],arabic:[["GeezaPro.ttc",0],["SFArabic.ttf",0],["Arial Unicode.ttf",0]],hebrew:[["ArialHB.ttc",0],["Arial Unicode.ttf",0]],thai:[["Thonburi.ttc",0],["Arial Unicode.ttf",0]],other:[["Arial Unicode.ttf",0],["Apple Symbols.ttf",0],["Arial.ttf",0]]},Qt={zh:[["NotoSansCJK-Regular.ttc",2],["NotoSansCJKsc-Regular.otf",0],["wqy-zenhei.ttc",0],["wqy-microhei.ttc",0],["DroidSansFallbackFull.ttf",0],["DroidSansFallback.ttf",0]],"zh-TW":[["NotoSansCJK-Regular.ttc",3],["NotoSansCJKtc-Regular.otf",0],["wqy-zenhei.ttc",0],["DroidSansFallbackFull.ttf",0]],ja:[["NotoSansCJK-Regular.ttc",0],["NotoSansCJKjp-Regular.otf",0],["DroidSansFallbackFull.ttf",0],["TakaoGothic.ttf",0]],ko:[["NotoSansCJK-Regular.ttc",1],["NotoSansCJKkr-Regular.otf",0],["NanumGothic.ttf",0],["DroidSansFallbackFull.ttf",0]],arabic:[["NotoSansArabic-Regular.ttf",0],["NotoNaskhArabic-Regular.ttf",0],["DejaVuSans.ttf",0],["FreeSans.ttf",0]],hebrew:[["NotoSansHebrew-Regular.ttf",0],["DejaVuSans.ttf",0],["FreeSans.ttf",0]],thai:[["NotoSansThai-Regular.ttf",0],["Garuda.ttf",0],["Loma.ttf",0],["DejaVuSans.ttf",0]],other:[["DejaVuSans.ttf",0],["NotoSansSymbols-Regular.ttf",0],["NotoSansSymbols2-Regular.ttf",0],["FreeSans.ttf",0],["LiberationSans-Regular.ttf",0]]},Gn={zh:"zh-cn","zh-TW":"zh-tw",ja:"ja",ko:"ko",arabic:"ar",hebrew:"he",thai:"th"};function Bn(t){return t.script==="han"||t.script==="kana"||t.script==="hangul"?t.script==="kana"?"ja":t.script==="hangul"?"ko":t.lang??"zh":t.script==="arabic"||t.script==="hebrew"||t.script==="thai"?t.script:"other"}var Et=t=>t.platform==="win32"?en:Rt;function Kn(t){let r=en.join,n=t.env.WINDIR??t.env.SystemRoot??"C:\\Windows";return[r(n,"Fonts"),...t.env.LOCALAPPDATA?[r(t.env.LOCALAPPDATA,"Microsoft","Windows","Fonts")]:[]]}function Vn(t){let r=Rt.join;return["/System/Library/Fonts","/System/Library/Fonts/Supplemental","/Library/Fonts",r(t.home,"Library","Fonts")]}function Yn(t){let r=Rt.join,n=t.env.XDG_DATA_HOME??r(t.home,".local","share");return["/usr/share/fonts","/usr/local/share/fonts","/usr/share/fonts/opentype/noto","/usr/share/fonts/truetype",r(n,"fonts"),r(t.home,".fonts")]}function rn(t,r,n,i=3){let{join:e}=Et(n),o=n.list(t),a=r.toLowerCase(),c=o.find(f=>f.toLowerCase()===a);if(c)return e(t,c);if(i!==0)for(let f of o){if(f.includes("."))continue;let h=rn(e(t,f),r,n,i-1);if(h)return h}}async function tn(t,r){let n=await r.run("fc-match",["-s","-f",`%{file} %{index}
|
|
4
|
+
`,t]);return n===void 0?[]:n.split(`
|
|
5
|
+
`).map(i=>i.split(" ")).filter(([i])=>i!==void 0&&i!=="").slice(0,8).map(([i,e])=>({path:i,index:(Number(e)||0)&65535}))}async function on(t,r=xt){let n=Bn(t),{join:i}=Et(r),e=[],o=c=>{c&&!e.some(f=>f.path===c.path&&f.index===c.index)&&e.push(c)};if(r.platform==="win32"||r.platform==="darwin"){let c=r.platform==="win32"?$n:Hn,f=r.platform==="win32"?Kn(r):Vn(r);for(let[h,g]of c[n]??c.other??[])for(let m of f){let p=i(m,h);if(r.exists(p)){o({path:p,index:g});break}}return e}let a=Gn[n];if(a)for(let c of await tn(`:lang=${a}`,r))o(c);else if(t.codePoint!==void 0)for(let c of await tn(`:charset=${t.codePoint.toString(16)}`,r))o(c);for(let[c,f]of Qt[n]??Qt.other??[])for(let h of Yn(r)){let g=rn(h,c,r);if(g){o({path:g,index:f});break}}return e}var nn=new WeakMap;function sn(t,r=xt){let n=nn.get(r)??new Map;nn.set(r,n);let i=`${t.path}#${t.index}`,e=Et(r).basename(t.path).replace(/\.[^.]+$/,""),o=n.get(i);if(o!==void 0)return o===null?void 0:{font:o,ref:t,name:e};try{let a=r.read(t.path);if(!a)throw new Error("unreadable");let c=bt(a,Math.min(t.index,Math.max(0,Zt(a)-1)));return n.set(i,c),{font:c,ref:t,name:e}}catch{n.set(i,null);return}}var te={width:595.28,height:841.89,margin:72},Z={size:11,leading:16,after:8},ne={size:20,leading:26,before:0,after:6},ee={size:15,leading:20,before:18,after:6},re=4,ie=24,M={size:10,leading:14,padX:6,padY:3},oe=12,yt=.114,se=.78,ae=.95,an={regular:"NotoSans-Regular.ttf.gz",bold:"NotoSans-Bold.ttf.gz"};function fe(t){return[ct(t,"fonts"),ct(t,"..","fonts"),ct(t,"..","..","assets","fonts")]}var St;function ce(){if(St)return St;let t=fe(qn(Zn(import.meta.url))).find(n=>Jn(ct(n,an.regular)));if(t===void 0)throw new Error("the PDF fonts are missing from this install");let r=n=>bt(Qn(Xn(ct(t,an[n]))));return St={regular:r("regular"),bold:r("bold")},St}var nt=class{constructor(r,n,i,e,o){this.font=r;this.resource=n;this.name=i;this.synthetic=e;this.isBold=o}font;resource;name;synthetic;isBold;used=new Map;widths=new Map;advance(r){let n=this.widths.get(r);return n===void 0&&(n=this.font.advance(r)/this.font.unitsPerEm,this.widths.set(r,n)),n}code(r,n){let i=this.font.codeOf(r);return this.used.has(i)||this.used.set(i,{gid:r,text:n}),i}},Ct=class{fonts=[];picks=new Map;count=0;missing=new Set;notdef;constructor(r){let n={regular:new nt(r.regular,this.next(),"NotoSans-Regular",!1,!1),bold:new nt(r.bold,this.next(),"NotoSans-Bold",!1,!0)};this.fonts.push(n),this.notdef=n}next(){return`F${++this.count}`}get primary(){return this.notdef.regular.font}all(){return this.fonts.flatMap(r=>[r.regular,r.bold])}add(r,n){this.fonts.push({regular:new nt(n,this.next(),r,!1,!1),bold:new nt(n,this.next(),r,!0,!0)}),this.picks.clear()}get fontCount(){return this.fonts.length}has(r){return this.fonts.some(n=>n.regular.font.glyphOf(r)!==void 0)}pick(r,n){let i=this.picks.get(r);if(i===void 0){i=null;for(let o=0;o<this.fonts.length;o++){let a=this.fonts[o]?.regular.font.glyphOf(r);if(a!==void 0){i=[o,a];break}}this.picks.set(r,i)}if(i===null)return this.missing.add(Q(r)??"other"),{pf:n?this.notdef.bold:this.notdef.regular,gid:0};let e=this.fonts[i[0]];return{pf:(n?e?.bold:e?.regular)??this.notdef.regular,gid:i[1]}}width(r,n,i){let e=0;for(let o of r){let{pf:a,gid:c}=this.pick(o.codePointAt(0)??0,i);e+=a.advance(c)}return e*n}runs(r,n){let i=[];for(let e of r){let o=e.codePointAt(0)??0,{pf:a,gid:c}=this.pick(o,n),f=c===0?"\uFFFD":o>=64336&&o<=65279?Ht(o):e,h=a.code(c,f).toString(16).padStart(4,"0"),g=i.at(-1);g&&g.pf===a?(g.hex+=h,g.width+=a.advance(c)):i.push({pf:a,hex:h,width:a.advance(c)})}return i}},ue=/[\u00AD\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2060\u2066-\u2069\uFEFF]/g,le=/[\t\u00A0\u2000-\u200A\u202F\u205F\u3000]/g,he=/[^\P{Cc}\n]/gu;function cn(t){return t.replace(le," ").replace(ue,"").replace(he,"").normalize("NFC")}function de(t,r){let n=cn(t);Wt(n)&&(n=$t(n,r)),n=n.replace(/[\u200C\u200D]/g,"");let i=[];for(let e of n){let o=e.codePointAt(0)??0;if(e===`
|
|
6
|
+
`||r(o)){i.push(e);continue}let a=e.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"");i.push(a!==""&&[...a].every(c=>r(c.codePointAt(0)??0))?a:e)}return i.join("")}var ge=new Set(["han","kana","hangul"]),me=new Set([12289,12290,65292,65294,65306,65307,65281,65311,65289,65341,65373,12309,12297,12299,12301,12303,12305,12313,12311,12319,8217,8221,8252,12540,12293,12539,8230,8229,37,12445,12446,12541,12542].map(t=>String.fromCodePoint(t))),pe=new Set([65288,65339,65371,12308,12296,12298,12300,12302,12304,12312,12310,12317,8216,8220].map(t=>String.fromCodePoint(t)));function Tt(t,r,n,i,e){let o=[],a=c=>r.width(c,i,n);for(let c of t.split(`
|
|
7
|
+
`)){let f="",h=0,g=a(" ");for(let m of c.split(" ").filter(Boolean)){let p=a(m),s=[...m].some(l=>ge.has(Q(l.codePointAt(0)??0)));if(p>e||s&&f!==""&&h+g+p>e){f!==""&&(h+g+a([...m][0]??"")<=e?(f+=" ",h+=g):(o.push(f),f="",h=0));for(let l of m){let d=a(l),u=[...f].at(-1),b=me.has(l)&&h+d<=e*1.15;h+d>e&&f!==""&&!b&&(u!==void 0&&pe.has(u)?(o.push([...f].slice(0,-1).join("")),f=u,h=a(u)):(o.push(f),f="",h=0)),f+=l,h+=d}}else f===""?(f=m,h=p):h+g+p<=e?(f+=` ${m}`,h+=g+p):(o.push(f),f=m,h=p)}o.push(f)}return o}var j=t=>(Math.round(t*100)/100).toString(),Lt=class{constructor(r,n){this.chain=r;this.margin=n.margin,this.pageHeight=n.height,this.textWidth=n.width-2*n.margin,this.textHeight=n.height-2*n.margin}chain;pages=[];ops=[];y=0;owed=0;margin;pageHeight;textWidth;textHeight;get remaining(){return this.textHeight-this.y}get atTop(){return this.y===0}newPage(){this.ops=[`${j(yt)} g ${j(yt)} G`],this.pages.push(this.ops),this.y=0,this.owed=0}gap(r){this.y>0&&(this.y+=Math.max(this.owed,r)),this.owed=0}bottom(r){this.owed=r}advance(r){this.y+=r}text(r,n,i,e,o,a,c){if(a==="")return;let{primary:f}=this.chain,h=(f.ascent-f.descent)*n/f.unitsPerEm,g=o+(i-h)/2+f.ascent*n/f.unitsPerEm,m=this.chain.runs(Dt(a,c),r),p=m.reduce((d,u)=>d+u.width,0)*n,s=this.margin+(c?e.left+e.width-p:e.left),l=j(this.pageHeight-this.margin-g);for(let d of m){let u=d.pf.synthetic?`2 Tr ${j(n*.035)} w `:"",b=d.pf.synthetic?" 0 Tr":"";this.ops.push(`BT /${d.pf.resource} ${j(n)} Tf ${u}${j(s)} ${l} Td <${d.hex}> Tj${b} ET`),s+=d.width*n}}rect(r,n,i,e,o){let a=`${j(this.margin+r)} ${j(this.pageHeight-this.margin-n-e)} ${j(i)} ${j(e)} re`;o==="fill"?this.ops.push(`${j(ae)} g ${a} f ${j(yt)} g`):this.ops.push(`${j(se)} G 0.5 w ${a} S ${j(yt)} G`)}lines(r,n,i,e,o,a){let c=kt(o),f=a?.indent??0,h={left:c?e.left:e.left+f,width:e.width-f};Tt(o,this.chain,r,n,h.width).forEach((g,m)=>{if(this.remaining<i&&this.newPage(),m===0&&a!==void 0){let p=this.chain.width(a.text,n,r),s=c?{left:e.left+e.width-p,width:p}:{left:h.left-p,width:p};this.text(r,n,i,s,this.y,a.text,!1)}this.text(r,n,i,h,this.y,g,c),this.advance(i)})}heading(r,n){let i=r===1?ne:ee,e=Tt(n,this.chain,!0,i.size,this.textWidth);this.gap(i.before),this.remaining<e.length*i.leading+i.after+2*Z.leading&&this.newPage(),this.lines(!0,i.size,i.leading,{left:0,width:this.textWidth},n),this.bottom(i.after)}paragraph(r){this.gap(0),this.lines(!1,Z.size,Z.leading,{left:0,width:this.textWidth},r),this.bottom(Z.after)}list(r,n){this.gap(0),n.forEach((i,e)=>{e>0&&this.advance(re);let o=r?`${e+1}. `:"\u2022 ";this.lines(!1,Z.size,Z.leading,{left:0,width:this.textWidth},i,{text:o,indent:ie})}),this.bottom(Z.after)}table(r){if(r.length===0)return;this.gap(0);let n=Math.max(...r.map(s=>s.length)),i=M.padX*2,e=Array(n).fill(0),o=Array(n).fill(0);for(let[s,l]of r.entries()){let d=s===0;for(let u=0;u<n;u++){let b=l[u]??"";e[u]=Math.max(e[u]??0,this.chain.width(b.replace(/\n/g," "),M.size,d)+i);let y=Math.max(0,...b.split(/\s+/).map(k=>Math.min(this.chain.width(k,M.size,d),M.size*3)));o[u]=Math.max(o[u]??0,y+i)}}let a=be(e,o,this.textWidth),c=a.map((s,l)=>a.slice(0,l).reduce((d,u)=>d+u,0)),f=s=>a.map((l,d)=>Tt(r[s]?.[d]??"",this.chain,s===0,M.size,l-i)),h=f(0),g=Math.max(...h.map(s=>s.length))*M.leading+2*M.padY,m=(s,l,d,u)=>{let b=u*M.leading+2*M.padY;for(let y=0;y<n;y++){let k=c[y]??0,F=a[y]??0;s===0&&this.rect(k,this.y,F,b,"fill"),this.rect(k,this.y,F,b,"stroke");let S=r[s]?.[y]??"",U=kt(S);(l[y]??[]).slice(d,d+u).forEach((C,N)=>{this.text(s===0,M.size,M.leading,{left:k+M.padX,width:F-i},this.y+M.padY+N*M.leading,C,U)})}this.advance(b)},p=s=>{this.newPage(),s>0&&g<this.textHeight/2&&m(0,h,0,Math.max(...h.map(l=>l.length)))};for(let s=0;s<r.length;s++){let l=s===0?h:f(s),d=Math.max(...l.map(b=>b.length)),u=0;for(;u<d;){let b=Math.floor((this.remaining-2*M.padY)/M.leading),y=(d-u)*M.leading+2*M.padY;if(b<1||b<d-u&&!this.atTop&&y<=this.textHeight-g){p(s);continue}let k=Math.min(d-u,b);m(s,l,u,k),u+=k,u<d&&p(s)}}this.bottom(oe)}};function be(t,r,n){let i=t.reduce((a,c)=>a+c,0);if(i<=n)return t.map(a=>a*n/i);let e=r.reduce((a,c)=>a+c,0);if(e>=n)return r.map(a=>a*n/e);let o=(n-e)/(i-e);return t.map((a,c)=>(r[c]??0)+(a-(r[c]??0))*o)}function xe(t){return t.flatMap(r=>r.flatMap(n=>n.kind==="heading"||n.kind==="paragraph"?[n.text]:n.kind==="list"?n.items:n.rows.flat()))}var fn=8;async function ye(t,r,n,i){let e=new Map;for(let c of new Set(r)){let f=c.codePointAt(0)??0;if(f<128||c===`
|
|
8
|
+
`||t.has(f)||f>=64336&&f<=65279)continue;let h=Q(f)??"other";if(h!=="other"&&h!=="symbols"&&h!=="emoji"&&!It.has(h)){t.missing.add(h);continue}e.set(h,[...e.get(h)??[],f])}let o=Nt(r,n),a=0;for(let[c,f]of e){let h=f,g={script:c,lang:o,codePoint:f[0]??0},m=[],p=s=>{let l=h.filter(d=>s.font.glyphOf(d)!==void 0);l.length!==0&&(t.add(s.name,s.font),a++,h=h.filter(d=>!l.includes(d)))};for(let s of await on(g,i)){if(h.length===0||a>=fn)break;let l=sn(s,i);l&&(l.font.variable?m.push(l):p(l))}for(let s of m){if(h.length===0||a>=fn)break;p(s)}}}function Ve(t){return{code:"missing-glyphs",message:`Some characters have no font: ${t.join(", ")}.`}}async function Ye(t,r){let{PDFDocument:n,PDFName:i,PDFString:e}=await Mt(),o=new Ct(ce()),a=xe(t).map(cn).join(`
|
|
9
|
+
`);await ye(o,a,r.lang,r.fonts??xt);let c=r.paper??te,f=new Lt(o,c),h=u=>de(u,b=>o.has(b)),g=u=>{u.kind==="heading"?f.heading(u.level,h(u.text)):u.kind==="paragraph"?f.paragraph(h(u.text)):u.kind==="list"?f.list(u.ordered,u.items.map(h)):f.table(u.rows.map(b=>b.map(h)))};for(let u of t.filter(b=>b.length>0)){f.newPage();for(let b of u)g(b)}f.pages.length===0&&f.newPage();let m=await n.create({updateMetadata:!1});m.setTitle(r.title),m.setProducer("Forge"),m.setCreator("Forge");let{context:p}=m,s=new Map,l=new Map,d=0;for(let u of o.all()){if(u.used.size===0)continue;let b=p.nextRef();s.set(u,b);let{font:y}=u,k=[...u.used.keys()].sort((T,I)=>T-I),F=k.map(T=>u.used.get(T)?.gid??0),S=u.synthetic?l.get(y):void 0,U=1e3/y.unitsPerEm,C=`F${String.fromCharCode(65+(d>>8)%26,65+(d>>4)%26,65+(d>>2)%26,65+d%26,65+d*7%26)}`;d++;let N=`${C}+${u.name.replace(/[^A-Za-z0-9-]/g,"")}`,{data:D,cidToGid:v}=y.subset(F),H=y.outlines==="cff",K=p.register(H?p.flateStream(D,{Subtype:"CIDFontType0C"}):p.flateStream(D,{Length1:D.length})),A=p.register(p.obj({Type:"FontDescriptor",FontName:N,Flags:4,FontBBox:y.bbox.map(T=>Math.round(T*U)),ItalicAngle:0,Ascent:Math.round(y.ascent*U),Descent:Math.round(y.descent*U),CapHeight:Math.round(y.capHeight*U),StemV:u.isBold?140:80,...H?{FontFile3:K}:{FontFile2:K}})),w=k.flatMap((T,I)=>[T,[Math.round(y.advance(F[I]??0)*U)]]),W=v?p.register(p.flateStream(new Uint8Array(new Uint16Array(Ae(v)).buffer))):void 0,L=p.register(p.obj({Type:"Font",Subtype:H?"CIDFontType0":"CIDFontType2",BaseFont:N,CIDSystemInfo:p.obj({Registry:e.of("Adobe"),Ordering:e.of("Identity"),Supplement:0}),FontDescriptor:A,DW:0,W:w,...H?{}:{CIDToGIDMap:W??"Identity"}})),$=p.register(p.flateStream(we(u.used)));p.assign(b,p.obj({Type:"Font",Subtype:"Type0",BaseFont:N,Encoding:"Identity-H",DescendantFonts:[L],ToUnicode:$})),u.synthetic||l.set(y,u)}for(let u of f.pages){let b=m.addPage([c.width,c.height]);for(let[y,k]of s)b.node.setFontDictionary(i.of(y.resource),k);b.node.set(i.of("Contents"),p.register(p.flateStream(u.join(`
|
|
10
|
+
`))))}return o.missing.size>0&&r.onMissing?.([...o.missing].map(Se)),Buffer.from(await m.save())}var Se=t=>t==="other"?"symbols":vt(t);function Ae(t){let r=new Uint16Array(t.length);for(let n=0;n<t.length;n++)r[n]=((t[n]??0)&255)<<8|(t[n]??0)>>8;return r}function we(t){let r=[...t].sort(([o],[a])=>o-a),n=o=>o.toString(16).padStart(4,"0"),i=o=>[...o].flatMap(a=>{let c=a.codePointAt(0)??65533;if(c<65536)return[n(c)];let f=c-65536;return[n(55296+(f>>10)),n(56320+(f&1023))]}).join(""),e=[];for(let o=0;o<r.length;o+=100){let a=r.slice(o,o+100);e.push(`${a.length} beginbfchar
|
|
11
|
+
${a.map(([c,f])=>`<${n(c)}> <${i(f.text)}>`).join(`
|
|
12
|
+
`)}
|
|
13
|
+
endbfchar`)}return["/CIDInit /ProcessSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def",`1 begincodespacerange
|
|
14
|
+
<0000> <FFFF>
|
|
15
|
+
endcodespacerange`,...e,"endcmap","CMapName currentdict /CMap defineresource pop","end","end"].join(`
|
|
16
|
+
`)}export{kt as a,ke as b,Ve as c,Ye as d};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as F}from"./chunk-PON65UTS.js";import{execFile as K,spawn as O}from"node:child_process";import{access as T,constants as C}from"node:fs/promises";import{dirname as $,join as L}from"node:path";import{promisify as D}from"node:util";function N(e){let[t,r]=(e??"").split("/").map(Number);return!t||!r?0:Math.round(t/r*100)/100}function I(e){let t=e.side_data_list?.find(n=>typeof n.rotation=="number")?.rotation,r=t!==void 0?-t:Number(e.tags?.rotate??0);return(Math.round(r/90)*90%360+360)%360}function A(e){let t=e,r=t.streams??[],n=r.find(o=>o.codec_type==="video"&&o.disposition?.attached_pic!==1),i=r.find(o=>o.codec_type==="audio"),s={duration:Number(t.format?.duration)||Math.max(0,...r.map(o=>Number(o.duration)||0))};if(n){let o=I(n),d=o===90||o===270,a=n.width??0,u=n.height??0;s.video={codec:n.codec_name??"",width:d?u:a,height:d?a:u,fps:N(n.avg_frame_rate)||N(n.r_frame_rate),rotation:o,hdr:n.color_transfer==="arib-std-b67"||n.color_transfer==="smpte2084"}}if(i){s.audio={codec:i.codec_name??"",channels:i.channels??0,sampleRate:Number(i.sample_rate)||0};let o=Number(i.bits_per_raw_sample)||i.bits_per_sample||0;o>0&&(s.audio.bits=o)}return s}var y=D(K);function G(e,t){let r=t.PATH??t.Path??"",n=e==="win32"?";":":",i=r.split(n).filter(Boolean);return e==="darwin"&&i.push("/opt/homebrew/bin","/usr/local/bin"),[...new Set(i)]}var k=e=>process.platform==="win32"?`${e}.exe`:e;async function B(e){try{return await T(e,C.X_OK),!0}catch{return!1}}function J(e){let t=new Set;for(let r of e.split(`
|
|
4
|
+
`)){let n=r.match(/^\s*[A-Z.|]{3,6}\s+(\S+)\s/);n?.[1]&&n[1]!=="="&&t.add(n[1])}return t}async function j(){try{let{installed:e}=await import("./paths-6OENILJ4.js");return(await e("video"))?.dir}catch{return}}async function q(){try{let{chosenPath:e}=await import("./own-5BD5BVE7.js"),t=await e("video");return t===void 0?void 0:$(t)}catch{return}}async function H(){try{let{removeForgeCopy:e}=await import("./own-5BD5BVE7.js");await e("video")}catch{}}async function V(){let e=await j(),t=await q(),r=[...t?[t]:[],...G(process.platform,process.env),...e?[e]:[]];for(let n of r){let i=L(n,k("ffmpeg")),f=L(n,k("ffprobe"));if(!await B(i)||!await B(f))continue;try{await y(i,["-hide_banner","-version"],{timeout:5e3})}catch{continue}let[s,o]=await Promise.all(["-encoders","-filters"].map(a=>y(i,["-hide_banner",a],{timeout:5e3,maxBuffer:4<<20}).then(({stdout:u})=>J(u)).catch(()=>{}))),d=s&&o?new Set([...s,...o]):void 0;return e!==void 0&&n!==e&&await H(),{ffmpeg:i,ffprobe:f,...d?{has:d}:{}}}}var h,w=null,P;function v(){return w?Promise.resolve(w.value):(h=(h??V()).then(t=>(t||(h=void 0),P=t,t)),h)}function oe(){return w?w.value:P}function ie(e){w=e===null?null:{value:e},h=void 0,P=void 0}async function se(e,t){let r=t??await v();if(!r)throw new Error("ffmpeg is not installed");let{stdout:n}=await y(r.ffprobe,["-v","error","-print_format","json","-show_format","-show_streams",e],{timeout:3e4,maxBuffer:16*1024*1024});return A(JSON.parse(n))}async function ae(e,t,r){let n=r??await v();if(!n)return;let i=async f=>{let{stdout:s}=await y(n.ffprobe,["-v","error","-select_streams","v:0","-show_packets","-show_entries","packet=pts_time,dts_time,flags","-of","csv=p=0","-read_intervals",`${f}%${t+.01}`,e],{timeout:3e4,maxBuffer:16777216});return X(s).filter(o=>o<=t+.001)};try{let f=Math.max(0,t-15),s=await i(f);return!s.length&&f>0&&(s=await i(0)),s.length?Math.max(...s):void 0}catch{return}}function X(e){let t=[];for(let r of e.split(`
|
|
5
|
+
`)){let[n,i,f]=r.split(",");if(!f?.includes("K"))continue;let s=Number.parseFloat(n??""),o=Number.isFinite(s)?s:Number.parseFloat(i??"");Number.isFinite(o)&&t.push(o)}return t}var R=4e3;async function fe(e,t,r,n={}){let i=n.tools??await v();if(!i)return null;let f=Math.max(1,Math.round(t*R)),s=Math.max(1,Math.ceil(f/r)),o=new Array(r).fill(0),d=0,a=Buffer.alloc(0);if(!await new Promise((p,c)=>{let m=F(O(i.ffmpeg,["-hide_banner","-nostdin","-loglevel","error","-i",e,"-map","0:a:0","-ac","1","-ar",String(R),"-f","s16le","-"],{stdio:["ignore","pipe","pipe"]})),b=()=>m.kill("SIGKILL");n.signal?.addEventListener("abort",b,{once:!0}),m.stdout.on("data",l=>{let _=a.length?Buffer.concat([a,l]):l,M=_.length-_.length%2;for(let x=0;x<M;x+=2){let E=Math.abs(_.readInt16LE(x)),S=Math.min(r-1,Math.floor(d/s));E>(o[S]??0)&&(o[S]=E),d++}a=_.subarray(M)}),m.stderr.resume(),m.on("error",c),m.on("close",l=>{n.signal?.removeEventListener("abort",b),n.signal?.aborted?c(n.signal.reason??new Error("aborted")):p(l===0&&d>0)})}))return null;let g=Math.max(1,...o);return o.map(p=>Math.sqrt(p/g))}async function de(e,t,r,n){await Q(["-ss",String(Math.max(0,t)),"-i",e,"-frames:v","1","-y",r],{tools:n})}function Z(e){let t;for(let r of e.matchAll(/out_time_us=(\d+)/g))t=Number(r[1])/1e6;return t}var z=4e3;async function Q(e,t={}){let{signal:r,onTime:n}=t;if(r?.aborted)throw r.reason??new Error("aborted");let i=t.tools??await v();if(!i)throw new Error("ffmpeg is not installed");let s=["-hide_banner","-nostdin","-loglevel",t.report?"info":"error","-progress","pipe:1","-nostats",...e];return new Promise((o,d)=>{let a=F(O(i.ffmpeg,s,{stdio:["ignore","pipe","pipe"]})),u="",g=()=>a.kill("SIGKILL");r?.addEventListener("abort",g,{once:!0}),a.stdout.setEncoding("utf8");let p="";a.stdout.on("data",c=>{let m=p+c,b=m.lastIndexOf(`
|
|
6
|
+
`);p=m.slice(b+1);let l=Z(m.slice(0,b+1));l!==void 0&&n?.(l)}),a.stderr.setEncoding("utf8"),a.stderr.on("data",c=>{u=(u+c).slice(-z)}),a.on("error",c=>{r?.removeEventListener("abort",g),d(c)}),a.on("close",c=>{r?.removeEventListener("abort",g),r?.aborted?d(r.reason??new Error("aborted")):c===0?o(u):d(new Error(u.trim()||`ffmpeg exited with ${c}`))})})}export{G as a,J as b,v as c,oe as d,ie as e,se as f,ae as g,X as h,fe as i,de as j,Z as k,Q as l};
|
|
@@ -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 d}from"./chunk-
|
|
3
|
+
import{b as d}from"./chunk-CCNRNCRU.js";var m=e=>/^[A-Za-z0-9][A-Za-z0-9-]*$/.test(e),u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),s=e=>typeof e=="number"&&Number.isInteger(e)&&e>0;function h(e){if(!(!u(e)||Object.keys(e).length!==1)){if(s(e.width))return{width:e.width};if(s(e.height))return{height:e.height};if(s(e.percent))return{percent:e.percent}}}function b(e){if(!u(e))return;let t={};if(e.to!==void 0){if(typeof e.to!="string"||!d(e.to))return;t.to=e.to}if(e.quality!==void 0){if(!s(e.quality)||e.quality>100)return;t.quality=e.quality}if(e.maxBytes!==void 0){if(!s(e.maxBytes))return;t.maxBytes=e.maxBytes}if(e.resize!==void 0){let i=h(e.resize);if(!i)return;t.resize=i}for(let i of["trim","sharpen","removeBackground"])if(e[i]!==void 0){if(typeof e[i]!="boolean")return;t[i]=e[i]}if(e.crop!==void 0){if(!u(e.crop)||!s(e.crop.w)||!s(e.crop.h))return;t.crop={w:e.crop.w,h:e.crop.h}}if(e.boost!==void 0){if(e.boost!==2&&e.boost!==3&&e.boost!==4)return;t.boost=e.boost}if(e.compress!==void 0){if(!u(e.compress)||typeof e.compress.dither!="boolean")return;t.compress={dither:e.compress.dither}}if(e.behind!==void 0){if(e.behind!=="white"&&e.behind!=="black")return;t.behind=e.behind}return t}function z(e){if(!u(e)||typeof e.name!="string"||!m(e.name)||typeof e.saveTo!="string"||e.saveTo.trim()==="")return;let t=b(e.steps);if(t)return{name:e.name,steps:t,saveTo:e.saveTo,...e.quickAction===!0?{quickAction:!0}:{}}}var l={white:"#ffffff",black:"#000000"};function x(e,t){let i=[];e.removeBackground&&i.push({kind:"cutout"}),e.boost?i.push({kind:"boost",scale:e.boost}):e.sharpen&&i.push({kind:"boost",scale:1});let o=[];e.trim&&o.push({kind:"cut",trim:!0}),e.crop&&o.push({kind:"cut",crop:e.crop});let c=e.to??t,n={kind:"encode",target:c};if(e.quality!==void 0&&(n.quality=e.quality),e.maxBytes&&(n.maxBytes=e.maxBytes),(e.compress||e.maxBytes)&&(n.compress=e.compress??{dither:!1}),e.resize&&(n.resize=e.resize),i.length===0){let r=o.pop();r?.kind==="cut"&&(r.trim&&(n.trim=!0),r.crop&&(n.crop=r.crop))}if(n.maxBytes&&(n.trim||n.crop||n.resize)){let{trim:r,crop:a,resize:p}=n;o.push({kind:"cut",...r?{trim:r}:{},...a?{crop:a}:{},...p?{resize:p}:{}}),delete n.trim,delete n.crop,delete n.resize}if(e.removeBackground&&!d(c)?.hasAlpha&&(n.background=l[e.behind??"white"]),o.length===0&&i.length===0&&Object.keys(n).length===2&&e.to===void 0)return[];let f=o.filter(r=>r.kind==="cut"&&r.resize);return[...o.filter(r=>!f.includes(r)),...i,...f,n]}export{m as a,z as b,x as c};
|