forge-terminal 0.3.7 → 0.4.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 +70 -10
- package/dist/chunks/{about-credits-IWMNY4YU.js → about-credits-6D6B2JTS.js} +1 -1
- package/dist/chunks/{available-QN6QAGCU.js → available-HYL2YE56.js} +1 -1
- package/dist/chunks/boot-IQ4NYHEG.js +3 -0
- package/dist/chunks/{catalog-O3V24DK7.js → catalog-U7IF2BH2.js} +1 -1
- package/dist/chunks/check-INHBJOBB.js +3 -0
- package/dist/chunks/{chunk-4QQEJ6YG.js → chunk-26NDEWOQ.js} +1 -1
- package/dist/chunks/chunk-2CK4RFPI.js +3 -0
- package/dist/chunks/chunk-3A43GEIR.js +4 -0
- package/dist/chunks/{chunk-SAWVMQAD.js → chunk-4LTI6JHW.js} +1 -1
- package/dist/chunks/chunk-5GJK5LP5.js +4 -0
- package/dist/chunks/chunk-6TERL22R.js +3 -0
- package/dist/chunks/chunk-6V6WEBUI.js +66 -0
- package/dist/chunks/chunk-6VOCIMXQ.js +3 -0
- package/dist/chunks/{chunk-32VJ2RDH.js → chunk-7ZI3PFFX.js} +1 -1
- package/dist/chunks/chunk-BLPVRO4J.js +19 -0
- package/dist/chunks/chunk-BXJ2HTKI.js +3 -0
- package/dist/chunks/{chunk-ZRP5CWIK.js → chunk-C2OZ5ERA.js} +1 -1
- package/dist/chunks/chunk-CBE73ZWA.js +3 -0
- package/dist/chunks/{chunk-TEO2EUS3.js → chunk-CLQHW4EF.js} +1 -1
- package/dist/chunks/chunk-D6JPP65L.js +3 -0
- package/dist/chunks/chunk-DW2EJIUX.js +3 -0
- package/dist/chunks/{chunk-3GVFOZ7M.js → chunk-EHARO6IS.js} +1 -1
- package/dist/chunks/{chunk-I6QBBRCE.js → chunk-FKPXXNKX.js} +1 -1
- package/dist/chunks/chunk-FWMFN36F.js +3 -0
- package/dist/chunks/chunk-HBDVKP3X.js +5 -0
- package/dist/chunks/chunk-HCN4BH2H.js +3 -0
- package/dist/chunks/chunk-ILWGG424.js +4 -0
- package/dist/chunks/chunk-IMC5NRDC.js +3 -0
- package/dist/chunks/chunk-JBSYGB3F.js +3 -0
- package/dist/chunks/chunk-MHW4OOQW.js +4 -0
- package/dist/chunks/chunk-OVILZLVA.js +3 -0
- package/dist/chunks/chunk-PGG2OTK6.js +3 -0
- package/dist/chunks/chunk-PSEIJXGT.js +3 -0
- package/dist/chunks/chunk-SS7HNRZ5.js +3 -0
- package/dist/chunks/chunk-SVDVVRVP.js +3 -0
- package/dist/chunks/chunk-XNNTF6FW.js +3 -0
- package/dist/chunks/{chunk-MBTGANIR.js → chunk-Z2LELLNV.js} +1 -1
- package/dist/chunks/chunk-ZONIA7SX.js +21 -0
- package/dist/chunks/clip-command-Q6SLD4U4.js +3 -0
- package/dist/chunks/colour-JPG24QYI.js +3 -0
- package/dist/chunks/config-command-R7QOBYF4.js +3 -0
- package/dist/chunks/execute-B7UL5RCU.js +3 -0
- package/dist/chunks/extensions-UR4GS47P.js +3 -0
- package/dist/chunks/{extensions-command-UGXZIFRI.js → extensions-command-AITZYSMM.js} +1 -1
- package/dist/chunks/image-KWRJIHQQ.js +3 -0
- package/dist/chunks/install-WBAFPZ2Q.js +3 -0
- package/dist/chunks/launch-RM5ZVXSU.js +4 -0
- package/dist/chunks/lock-GOOLFLSO.js +3 -0
- package/dist/chunks/manager-KZJ7WC34.js +4 -0
- package/dist/chunks/{paths-H2WS22BA.js → paths-KTXPDCDD.js} +1 -1
- package/dist/chunks/preferences-AUFJSKMJ.js +3 -0
- package/dist/chunks/preset-command-AXYFLVYA.js +3 -0
- package/dist/chunks/restart-TL76JEPU.js +3 -0
- package/dist/chunks/run-4Z6CRNHJ.js +4 -0
- package/dist/chunks/{server-EFG2SZ5S.js → server-RM4YA6UL.js} +16 -15
- package/dist/chunks/{theme-HDUI5UKP.js → theme-LR72ACFF.js} +1 -1
- package/dist/chunks/transcribe-command-6YTLVSMW.js +3 -0
- package/dist/chunks/update-command-2SHKIIQD.js +3 -0
- package/dist/chunks/update-note-UH2TQPJ6.js +3 -0
- package/dist/chunks/watch-command-NU7QY6QU.js +3 -0
- package/dist/helpers/forge-transcribe +0 -0
- package/dist/index.js +42 -33
- package/dist/third-party-licenses.txt +1 -1
- package/package.json +34 -1
- package/skills/forge/SKILL.md +7 -0
- package/dist/chunks/boot-ZLBUAZMD.js +0 -3
- package/dist/chunks/check-BRP6EKSA.js +0 -3
- package/dist/chunks/chunk-DVJAGA5L.js +0 -19
- package/dist/chunks/chunk-G5PN5NGT.js +0 -66
- package/dist/chunks/chunk-GGBNT4WI.js +0 -3
- package/dist/chunks/chunk-GNLE6JXL.js +0 -3
- package/dist/chunks/chunk-H2IUSPAK.js +0 -4
- package/dist/chunks/chunk-LW2QEXDT.js +0 -3
- package/dist/chunks/chunk-MMRDELHW.js +0 -3
- package/dist/chunks/chunk-TBC2FK5T.js +0 -4
- package/dist/chunks/chunk-WFD6OWQY.js +0 -3
- package/dist/chunks/chunk-X54KIHCN.js +0 -4
- package/dist/chunks/chunk-Y64NO6PF.js +0 -4
- package/dist/chunks/chunk-YILLB45O.js +0 -3
- package/dist/chunks/colour-E7GZMLKE.js +0 -3
- package/dist/chunks/config-command-TXQUYFA6.js +0 -3
- package/dist/chunks/execute-767547IA.js +0 -3
- package/dist/chunks/extensions-WJ43ETRG.js +0 -3
- package/dist/chunks/image-F5D73JPQ.js +0 -3
- package/dist/chunks/install-YG43OJ7P.js +0 -3
- package/dist/chunks/launch-ZUJSPYT3.js +0 -4
- package/dist/chunks/lock-6KTGUFBY.js +0 -3
- package/dist/chunks/manager-XN7WNMEW.js +0 -4
- package/dist/chunks/preferences-YL6SRNZR.js +0 -3
- package/dist/chunks/restart-RO6DM5N3.js +0 -3
- package/dist/chunks/run-XQYPVWFI.js +0 -4
- package/dist/chunks/update-command-6VNVMAYO.js +0 -3
- package/dist/chunks/update-note-QEGW3W2Z.js +0 -3
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ That puts `forge` on your `PATH`, so it works from any directory. Verify:
|
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
45
|
forge --version
|
|
46
|
-
# 0.
|
|
46
|
+
# 0.4.0
|
|
47
47
|
|
|
48
48
|
forge photo.jpg --to webp
|
|
49
49
|
```
|
|
@@ -226,9 +226,16 @@ forge *.jpg --max-size 1mb # a whole folder
|
|
|
226
226
|
has. `--quality` and `--max-size` are mutually exclusive — they ask the same
|
|
227
227
|
question two ways, and Forge will not guess which wins.
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
A PNG or GIF is compressed by cutting it to fewer colours, which is what
|
|
230
|
+
makes it lossy here: `/convert` keeps both lossless. The slider stops at three
|
|
231
|
+
points, 30 · 65 · 100, since a palette's size moves in steps; `--quality` takes
|
|
232
|
+
any number. Colours stay flat unless you press `d` for dithering, which looks
|
|
233
|
+
smoother and costs bytes. A GIF keeps every frame and its timing.
|
|
234
|
+
|
|
235
|
+
Compressing never writes a bigger file. A file another tool already squeezed,
|
|
236
|
+
or a JPEG asked for more quality than it was saved at, would grow, so Forge
|
|
237
|
+
says "Cannot compress more" and writes nothing. A TIFF is lossless with no
|
|
238
|
+
palette to cut; `/convert` it to WebP instead.
|
|
232
239
|
|
|
233
240
|
After compressing, if another format would be meaningfully smaller, Forge says
|
|
234
241
|
so — and it encodes a candidate to find out rather than guessing:
|
|
@@ -241,6 +248,59 @@ so — and it encodes a candidate to find out rather than guessing:
|
|
|
241
248
|
↵ convert another · c convert to WebP · o open · s show in finder · ctrl-c close app
|
|
242
249
|
```
|
|
243
250
|
|
|
251
|
+
## The clipboard
|
|
252
|
+
|
|
253
|
+
On a Mac, a copied image can be the file. Copy a screenshot (⌃⇧⌘4) or an
|
|
254
|
+
image in a browser, Figma or Preview, and home's field says `⌘V to paste from
|
|
255
|
+
clipboard`. ⌘V lands it as a card named **Copied image**; pick a mode as for
|
|
256
|
+
any file. There is no Save as: the result goes back on the clipboard, so the
|
|
257
|
+
next ⌘V — in Slack, GitHub, a chat — pastes it. On Done, `u` puts the original
|
|
258
|
+
back and `s` also saves the result to the default folder.
|
|
259
|
+
|
|
260
|
+
If your terminal sends nothing on ⌘V with only a picture copied, ctrl-v does
|
|
261
|
+
the same.
|
|
262
|
+
|
|
263
|
+
Forge never overwrites something you copied while it worked: the result is
|
|
264
|
+
saved to the default folder instead, and Done says so. A compression that
|
|
265
|
+
would come out larger is never put back.
|
|
266
|
+
|
|
267
|
+
From the command line:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
forge clip # compress the copied image, then ⌘V
|
|
271
|
+
forge clip --max-size 1mb # to fit
|
|
272
|
+
forge clip --to webp # convert it on the clipboard
|
|
273
|
+
forge clip --save ~/Desktop # and keep a file too
|
|
274
|
+
forge clip --undo # put the last original back
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Agents get the same as the MCP tool `forge_clip`.
|
|
278
|
+
|
|
279
|
+
## Watch a folder
|
|
280
|
+
|
|
281
|
+
Drop a folder on home in convert mode: it is one card, **FOLDER – its name**.
|
|
282
|
+
↵ asks what to convert to, as for a file, then converts every file in it and
|
|
283
|
+
keeps watching: any file you add afterwards is converted too, a row each,
|
|
284
|
+
until you press ↵. A folder holding several kinds of file (images, PDFs, …)
|
|
285
|
+
asks once per kind; ↵ on a kind opens a window to change its answer.
|
|
286
|
+
|
|
287
|
+
Files are read by their content once they stop changing, so a screenshot or a
|
|
288
|
+
download is never read half-written. Forge never picks up its own output, and
|
|
289
|
+
dropping the same folder again leaves what it already converted alone.
|
|
290
|
+
|
|
291
|
+
From the command line:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
forge watch ./images --to webp # convert what is there, then each new file
|
|
295
|
+
forge watch ./images --to webp -q 70 # at a quality
|
|
296
|
+
forge watch ./scans --to png --dpi 300 # PDFs, a page each
|
|
297
|
+
forge watch ./images --to webp -o ./dist # into another folder
|
|
298
|
+
forge watch ./images --to webp --new-only # only what lands from now on
|
|
299
|
+
forge watch ./images --to webp --json # one JSON document per line, per event
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
ctrl-c stops it and prints the totals.
|
|
303
|
+
|
|
244
304
|
## Resize and trim edges
|
|
245
305
|
|
|
246
306
|
Both need nothing extra, keep the file's own format unless `--to` says otherwise,
|
|
@@ -283,7 +343,7 @@ flags resize does, and is refused with the same ones — and with `--trim`: run
|
|
|
283
343
|
one, then the other. Cropping an animated image is refused; so is cropping one
|
|
284
344
|
that already has the shape, unless it is also resized, which then only warns.
|
|
285
345
|
`forge_convert` takes `crop: "1:1"` (any `W:H`), and then `to` is optional.
|
|
286
|
-
In the app, Crop to shape is an
|
|
346
|
+
In the app, Crop to shape is an Edit row with a preview you can move and
|
|
287
347
|
zoom.
|
|
288
348
|
|
|
289
349
|
## Boost resolution and remove background
|
|
@@ -327,7 +387,7 @@ while that extension is installed, and `--json` results report `op: "boost"` or
|
|
|
327
387
|
`op: "remove-background"`. `forge_convert` accepts `sharpen: true`, `boost: 2 | 3 | 4` and
|
|
328
388
|
`removeBackground: true`, with the same `extension-missing` tool error.
|
|
329
389
|
|
|
330
|
-
The shell's
|
|
390
|
+
The shell's edit Done shows the real pictures in iTerm2, WezTerm, Kitty and Ghostty (a half-block close-up elsewhere); `FORGE_INLINE_IMAGES=0` turns them off, `=1` forces them on (e.g. tmux with passthrough).
|
|
331
391
|
|
|
332
392
|
## PDF
|
|
333
393
|
|
|
@@ -933,7 +993,7 @@ photo.png · PNG · 122 KB · 2756×774
|
|
|
933
993
|
With `--json`:
|
|
934
994
|
|
|
935
995
|
```json
|
|
936
|
-
{"forge":"0.
|
|
996
|
+
{"forge":"0.4.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":[]}
|
|
937
997
|
```
|
|
938
998
|
|
|
939
999
|
`targets` and `actions` come from the engines' own capabilities, so they are
|
|
@@ -941,8 +1001,8 @@ always true for that file. `format` is read from the file's content, not its
|
|
|
941
1001
|
name. `actions` lists `convert` plus what else applies: `compress`,
|
|
942
1002
|
`split`, `extract`, `delete`, `rotate`; `merge` appears only when several
|
|
943
1003
|
PDFs are probed together. `compress` appears when quality or size can be
|
|
944
|
-
reduced: lossy images, and PDFs that contain compressible images
|
|
945
|
-
only `convert`). Run it as `--quality N` or `--max-size S` without `--to`;
|
|
1004
|
+
reduced: lossy images, PNG and GIF, and PDFs that contain compressible images
|
|
1005
|
+
(a TIFF has only `convert`). Run it as `--quality N` or `--max-size S` without `--to`;
|
|
946
1006
|
its `--json` result reports `op: "convert"`. The encrypted PDF above omits
|
|
947
1007
|
`compress` and `merge`; a plain PDF with images would also list `compress`.
|
|
948
1008
|
A probe has `width`/`height` for an image,
|
|
@@ -959,7 +1019,7 @@ succeeded) and `failures`. A conversion, compression or page operation adds
|
|
|
959
1019
|
|
|
960
1020
|
```jsonc
|
|
961
1021
|
{
|
|
962
|
-
"forge": "0.
|
|
1022
|
+
"forge": "0.4.0",
|
|
963
1023
|
"ok": false,
|
|
964
1024
|
"results": [
|
|
965
1025
|
{
|
|
@@ -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:"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 I({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 I({from:n=import.meta.url,list:t=async()=>(await import("./manager-KZJ7WC34.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-UR4GS47P.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{I as loadCredits};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as t}from"./chunk-
|
|
3
|
+
import{c as t}from"./chunk-C2OZ5ERA.js";import"./chunk-HON4OV7M.js";import{a as i}from"./chunk-SS7HNRZ5.js";import"./chunk-TMUK2DD3.js";async function l(){let e=await Promise.all(i.map(async n=>await t(n.id)?n.id:null));return new Set(e.filter(n=>n!==null))}export{l as installedExtensionIds};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{r as l}from"./chunk-MHW4OOQW.js";import{f as a}from"./chunk-5GJK5LP5.js";import"./chunk-HON4OV7M.js";import"./chunk-BXJ2HTKI.js";import"./chunk-TMUK2DD3.js";var i={loadPreferences:a,loadShell:()=>import("./launch-RM5ZVXSU.js")};async function p(e=i){let o=e.loadShell();o.catch(()=>{});let{prefs:t,warning:r}=await e.loadPreferences(),n=l(t.theme),{launchShell:s}=await o;await s({prefs:t,palette:n,...r===void 0?{}:{warning:r}})}export{p as bootShell};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e}from"./chunk-
|
|
3
|
+
import{a,b,c,d,e}from"./chunk-SS7HNRZ5.js";import"./chunk-TMUK2DD3.js";export{a as CATALOG,c as assetFor,b as catalogEntry,e as offeredHere,d as offeredOn};
|
|
@@ -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-ILWGG424.js";import"./chunk-5GJK5LP5.js";import"./chunk-HON4OV7M.js";import"./chunk-BXJ2HTKI.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,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as t}from"./chunk-
|
|
3
|
+
import{b as t}from"./chunk-4LTI6JHW.js";import{spawnSync as n}from"node:child_process";var r=!1;function c(){r=!0}function p(){return r}function u(){let e=t(process.argv[1]);if(e===void 0)return;let o=n(process.execPath,[...process.execArgv,e],{stdio:"inherit"});process.exitCode=o.status??0}export{c as a,p as b,u as c};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as M,b as j,e as S,i as P}from"./chunk-XNNTF6FW.js";import{a as E,c as w}from"./chunk-JBSYGB3F.js";import{watch as k}from"node:fs";import{readdir as I,stat as W}from"node:fs/promises";import{join as z,resolve as x}from"node:path";function A(e,o,n){let r=x(e),c=n.settleMs??1e3,d=n.pollMs??500,s=new Set([...o].map(m=>x(m))),l=new Map,t=!1,i=!1,g=!1,p=async()=>{if(!t){if(i){g=!0;return}i=!0;try{let m=await I(r,{withFileTypes:!0}).catch(()=>[]),h=new Set;for(let a of m){if(!a.isFile()||M(a.name))continue;let f=z(r,a.name);if(h.add(f),s.has(f)||n.ignore?.(f))continue;let y=await W(f).catch(()=>{});if(!y||t)continue;let F=Date.now(),b=l.get(f);if(!b||b.size!==y.size||b.mtimeMs!==y.mtimeMs){l.set(f,{size:y.size,mtimeMs:y.mtimeMs,since:F});continue}F-b.since<c||(l.delete(f),s.add(f),n.onFile(f))}for(let a of[...s,...l.keys()])h.has(a)||(s.delete(a),l.delete(a))}finally{i=!1,g&&!t&&(g=!1,p())}}},v=setInterval(()=>{p()},d),u;try{u=k(r,{persistent:!1},()=>{p()}),u.on("error",()=>{})}catch{}return p(),{close(){t=!0,clearInterval(v),u?.close()}}}function K(e,o,n,r){let c=[],d=[];for(let s of e){let l=o[j(s)];if(!l){d.push({path:s.path,reason:R(o)});continue}let t=P(s,l,n,r);"job"in t?c.push(t.job):d.push({path:s.path,reason:t.left})}return{jobs:c,left:d}}async function G(e,o,n={}){let r=new Set,{jobs:c,left:d}=K(e.sources,o,r,n.destination);return{outcome:await w(c,{force:!1,...n.concurrency===void 0?{}:{concurrency:n.concurrency},...n.onEvent?{onEvent:n.onEvent}:{},...n.signal?{signal:n.signal}:{}}),left:d,claimed:r,jobs:c}}var O={images:"an image",pdfs:"a PDF",documents:"a document",videos:"a video",audio:"audio",other:"a file Forge reads"};function R(e){let o=Object.keys(e).filter(r=>e[r]);if(o.length===0)return"not supported";let n=o.map(r=>O[r]);return`not ${n.length===1?n[0]:`${n.slice(0,-1).join(", ")} or ${n.at(-1)}`}`}var J=(e,o)=>e==="other"?o==="text"?"a text file":"not supported":"not yet supported";function H(e){let o=E(e.concurrency),n=[],r=new Set,c=!1,d=async t=>{e.onEvent({type:"arrived",path:t}),e.onEvent({type:"phase",path:t,phase:"reading"});let i=await S(t);if(i.kind==="failed"){e.onEvent({type:"failed",path:t,error:i.failure.error});return}if(i.kind!=="source"){e.onEvent({type:"left",path:t,reason:J(i.kind,i.sniffed)});return}let{jobs:g,left:p}=K([i.source],e.answers,e.claimed,e.destination),[v]=p;if(v){e.onEvent({type:"left",path:t,reason:v.reason});return}let u=await w(g,{force:!1,concurrency:1,onEvent:a=>{a.type==="job:phase"&&"phase"in a.progress&&a.progress.phase!=="page"&&e.onEvent({type:"phase",path:t,phase:a.progress.phase,job:a.job})}}),[m]=u.results,h=[...u.refusals,...u.failures][0];m?e.onEvent({type:"converted",path:t,result:m}):h&&e.onEvent({type:"failed",path:t,error:h.error})},s=()=>{for(;!c&&r.size<o&&n.length>0;){let t=n.shift(),i=d(t).catch(()=>{}).finally(()=>{r.delete(i),s()});r.add(i)}},l=A(e.dir,e.known,{...e.settleMs===void 0?{}:{settleMs:e.settleMs},...e.pollMs===void 0?{}:{pollMs:e.pollMs},ignore:t=>e.claimed.has(t),onFile:t=>{n.push(t),s()}});return{async stop(){c=!0,l.close(),n.length=0,await Promise.all([...r])}}}export{K as a,G as b,H as c};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as N,b as se,c as ne,d as ae,e as ie,k as ue,l as pe,m as ce,o as de,p as fe}from"./chunk-PGG2OTK6.js";import{e as C}from"./chunk-FWMFN36F.js";import{a as y}from"./chunk-6TERL22R.js";import{c as I}from"./chunk-JBSYGB3F.js";import{a as oe,b as E}from"./chunk-HCN4BH2H.js";import{e as Q}from"./chunk-CBE73ZWA.js";import{a as $,c as U,d as Y,e as F,f as K}from"./chunk-IMC5NRDC.js";import{e as X,f as Z,g as _,h as ee,i as te,j as re}from"./chunk-EHARO6IS.js";import{e as V}from"./chunk-6VOCIMXQ.js";import{n as H,p as L}from"./chunk-D6JPP65L.js";import{a as g}from"./chunk-MHW4OOQW.js";import{F as J,G as q,J as z,b as x,c as w,d as v,la as G,p as D,r as R,t as W,w as O}from"./chunk-DW2EJIUX.js";import{a as h,b as A}from"./chunk-J7FLFHQJ.js";import{a as k}from"./chunk-BXJ2HTKI.js";import{readFile as Be}from"node:fs/promises";import{dirname as ke,resolve as Se}from"node:path";async function le(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=$(o);if(!s.includes(e.target)){t.push({path:o.path,error:W(o,e.target,s)});continue}let n=E({sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)});r.push({op:"convert",sources:[o],outputs:[n],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Re}from"node:path";function $e(e,r=new Set){let t={path:Re(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:$(e).filter(n=>!o||F(n)),actions:de([e],r).filter(n=>!o||n.id===C.id).map(n=>n.id)};return e.kind==="image"?{...t,width:e.width,height:e.height,...s}:{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function me(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-HYL2YE56.js"),o=await t();return{probes:r.sources.map(s=>$e(s,o)),failures:r.failures}}import{dirname as Fe}from"node:path";var B=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function ge(e,r){let t=x(Fe(e),B(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function he(e,r){let{pct:t,direction:o}=A(e,r);return o==="same"?"same size":`${t}% ${o}`}function ye(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${ge(s[0],r)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let i of t.warnings)a.push("",`\u26A0 ${i.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${x(s[0],B(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${he(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function be(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${he(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${x(n,B(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function we(e,r={}){let t=e.results.flatMap(u=>u.job.outputs),o=t.map(u=>w(u)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":ge(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)a.push("",`\u26A0 ${u.message}`);return a}function S(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...G(o.error,{debug:r.debug}),"");return t}function Ie(){let e=new Set(U()),r=new Set(Y()),t=["Formats",""];for(let s of e){let n=k[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>k[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function Pe(e,r={}){let t=[k[e.format].label,h(e.bytes)];return e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${x(e.path,B(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as xe}from"node:readline";import{PassThrough as Ee}from"node:stream";function Ce(e){return new Promise(r=>{let t=xe({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function ve(e){if(e.stdin)return Ce(process.stdin);if(!process.stdin.isTTY)return;let r=new Ee,t=xe({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
|
|
4
|
+
`),t.close()}}function T(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function je(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw J("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:ue(o)};if(s.mode==="every-n")return{cuts:pe(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Oe(e,r){let t;return()=>r?(t??=ve({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Je(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:O(e.path)}};let i;try{i=await V(await Be(e.path),s)}catch{return{failure:{path:e.path,error:O(e.path,{attempted:!0})}}}i.destroy()}let n;try{n=C.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!v(i))throw i;return{failure:{path:e.path,error:i}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function j(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function Ne(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=ce.find(a=>a.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let a=fe(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:R(e.action,a)}])}let s;try{s=t.plan(r.sources,je(e,r.sources))}catch(a){if(!v(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function Te(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of t.sources){if(!N.appliesTo([i])){s.push({path:i.path,error:D(i)});continue}let u=e.output!==void 0&&!oe(e.output)?Se(e.output):void 0,c=e.output===void 0||u!==void 0?ke(i.path):ke(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:t.roots.get(i.path)})),[p]=N.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},destination:c});p?.op==="convert"&&(u!==void 0&&(p.outputs=[u]),e.dpi!==void 0&&(p.options.dpi=e.dpi),o.push(p))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:j(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function Me(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-KTXPDCDD.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:z(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:l,catalogEntry:f}=await import("./catalog-U7IF2BH2.js"),d=f("boost"),P=d&&l(d)?.version,M=L(e.scale,n.version,P);if(M)return b(t,[{path:"",error:M}])}let a=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?ne:ae,u=[],c=[];for(let l of a.sources){if(!i.appliesTo([l])){c.push({path:l.path,error:R(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let f=se(l,e.target);if(f){c.push({path:l.path,error:f});continue}u.push(...i.plan([l],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let p=u.length>1;p&&r.onProgress?.({completed:0,total:u.length});let m=await I(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:j(r,p)});return{kind:t,results:m.results,failures:[...a.failures,...c,...m.refusals,...m.failures],inputBytes:m.inputBytes,outputBytes:m.outputBytes}}async function Ae(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:Q(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[];for(let p of s.sources)p.kind==="image"?n.push(p):a.push({path:p.path,error:R(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let i=ie(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),u=i.length>1;u&&r.onProgress?.({completed:0,total:i.length});let c=await I(i,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:j(r,u)});return{kind:e.kind,results:c.results,failures:[...s.failures,...a,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function De(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=d=>d.kind==="document"&&d.format==="pdf",s=F(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(d=>!o(d)):t.sources,i=[],u=[],c=Oe(e.passwordStdin??!1,r.interactive??!0);for(let d of n){let P=await Je(d,e,c,t.roots.get(d.path));"failure"in P?u.push(P.failure):i.push(P.job)}let p=await le({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),m=[...p.jobs,...i],l=m.length>1;l&&r.onProgress?.({completed:0,total:m.length});let f=await I(m,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:j(r,l)});return{kind:"convert",results:f.results,failures:[...t.failures,...u,...p.failures,...f.refusals,...f.unreachable.map(d=>({path:d.job.sources[0].path,error:d.error})),...f.failures],inputBytes:f.inputBytes,outputBytes:f.outputBytes}}async function We(e,r={}){try{if(e.kind==="pageop")return await Ne(e);if(e.kind==="extension-op")return await Me(e,r);if(e.kind==="edit")return await Ae(e,r);if(e.kind==="preset"){let{runPresetCommand:t}=await import("./preset-command-AXYFLVYA.js");return await t(e)}return e.kind==="compress"?await Te(e,r):await De(e,r)}catch(t){if(!v(t))throw t;return b(e.kind,[{path:"",error:t}])}}function qe(e,r){let t=T(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(X(g,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?we(e):e.results.length===1?ye(e):be(e);return{exitCode:t,stdout:o,stderr:S(e.failures,{debug:r.debug})}}function ze(e,r){let t=[{path:"",error:e}],o=T(t);return r.json?{exitCode:o,stdout:[JSON.stringify(Z(g,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:S(t,{debug:r.debug})}}async function Ge(e,r){let{runConfig:t}=await import("./config-command-R7QOBYF4.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(te(g,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function Bt(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ge(e,t);if(e.kind==="clip"){let{runClipCommand:s}=await import("./clip-command-Q6SLD4U4.js");return await s(e,{...r,json:t,debug:o})}if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-2SHKIIQD.js"),n=await s(g,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:g,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-AITZYSMM.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(re(g,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(_(g,K()))],stderr:[]}:{exitCode:0,stdout:Ie(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await me(e.inputs),a=T(n);return t?{exitCode:a,stdout:[JSON.stringify(ee(g,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((i,u)=>[...u>0?[""]:[],...Pe(i)]),stderr:S(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-JPG24QYI.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}if(e.kind==="transcribe"){let{runTranscribeCommand:s}=await import("./transcribe-command-6YTLVSMW.js"),n=[],a=[];return{exitCode:await s(e,{out:u=>n.push(u),err:u=>a.push(u)}),stdout:n,stderr:a}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw J("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");return qe(await We(e,r),{json:t,debug:o})}catch(s){if(!v(s))throw s;return ze(s,{json:t,debug:o})}}export{me as a,he as b,T as c,We as d,qe as e,Bt as f};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{O as a,P as u,Q as l}from"./chunk-DW2EJIUX.js";import{spawn as x}from"node:child_process";import{existsSync as c,realpathSync as b}from"node:fs";import{dirname as h,join as E,win32 as d}from"node:path";function f(n,t=process.platform,e=c){if(n===void 0)return!1;if(t==="win32"){let r=/^(.*)[\\/]node_modules[\\/]forge-terminal[\\/]/.exec(n)?.[1];return r!==void 0&&e(d.join(r,"forge.cmd"))}return/\/lib\/node_modules\/forge-terminal\//.test(n)&&!n.includes("/_npx/")}function m(n){if(n!==void 0)try{return b(n)}catch{return n}}function P(n,t=c){let e=E(h(n),"npm");return t(e)?e:"npm"}function R(n,t=c){let e=d.join(d.dirname(n),"node_modules","npm","bin","npm-cli.js");return t(e)?e:void 0}var g=(n,t,e)=>new Promise(r=>{let o="",s=x(n,t,{stdio:["ignore","pipe","pipe"],...e?{signal:e}:{}});s.stdout.setEncoding("utf8").on("data",i=>{o+=i}),s.stderr.setEncoding("utf8").on("data",i=>{o+=i}),s.on("error",i=>r({code:null,output:`${o}
|
|
4
4
|
${i.message}`})),s.on("close",i=>r({code:i,output:o}))});function w(n){return n.split(`
|
|
5
5
|
`).map(e=>e.replace(/^npm (error|ERR!)\s*/,"").trim()).filter(e=>e!==""&&!/^(code|errno|syscall|path|dest|A complete log)/.test(e)).at(-1)??"npm exited without saying why"}async function _(n,t={}){let e=t.platform??process.platform;if(e==="win32")return S(n,t);let r=t.script??m(process.argv[1]);if(!f(r,e))throw a(n);let o=t.npm??P(process.execPath),s=t.run??g,{code:i,output:p}=await s(o,["install","--global",`forge-terminal@${n}`],t.signal);if(i!==0)throw/EACCES|EPERM|permission denied/i.test(p)?u(n,e):l(n,w(p))}async function S(n,t){let e=t.script??m(process.argv[1]);if(!f(e,"win32",t.exists))throw a(n);let r=R(process.execPath,t.exists);if(r===void 0)throw l(n,"npm was not found beside Node");let o=t.run??g,{code:s,output:i}=await o(process.execPath,[r,"install","--global",`forge-terminal@${n}`],t.signal);if(s!==0)throw/EACCES|EPERM|EBUSY|permission denied/i.test(i)?u(n,"win32"):l(n,w(i))}export{f as a,m as b,P as c,R as d,_ as e};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as k}from"./chunk-HON4OV7M.js";import{b as p}from"./chunk-BXJ2HTKI.js";import{mkdir as C,readFile as O,rename as T,unlink as D,writeFile as I}from"node:fs/promises";import{homedir as F}from"node:os";import{dirname as $,join as S}from"node:path";var B=e=>/^[A-Za-z0-9][A-Za-z0-9-]*$/.test(e),a=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),u=e=>typeof e=="number"&&Number.isInteger(e)&&e>0;function R(e){if(!(!a(e)||Object.keys(e).length!==1)){if(u(e.width))return{width:e.width};if(u(e.height))return{height:e.height};if(u(e.percent))return{percent:e.percent}}}function q(e){if(!a(e))return;let t={};if(e.to!==void 0){if(typeof e.to!="string"||!p(e.to))return;t.to=e.to}if(e.quality!==void 0){if(!u(e.quality)||e.quality>100)return;t.quality=e.quality}if(e.maxBytes!==void 0){if(!u(e.maxBytes))return;t.maxBytes=e.maxBytes}if(e.resize!==void 0){let n=R(e.resize);if(!n)return;t.resize=n}for(let n of["trim","sharpen","removeBackground"])if(e[n]!==void 0){if(typeof e[n]!="boolean")return;t[n]=e[n]}if(e.crop!==void 0){if(!a(e.crop)||!u(e.crop.w)||!u(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.behind!==void 0){if(e.behind!=="white"&&e.behind!=="black")return;t.behind=e.behind}return t}function b(e){if(!a(e)||typeof e.name!="string"||!B(e.name)||typeof e.saveTo!="string"||e.saveTo.trim()==="")return;let t=q(e.steps);if(t)return{name:e.name,steps:t,saveTo:e.saveTo}}var E={white:"#ffffff",black:"#000000"};function W(e,t){let n=[];e.removeBackground&&n.push({kind:"cutout"}),e.boost?n.push({kind:"boost",scale:e.boost}):e.sharpen&&n.push({kind:"boost",scale:1});let i=[];e.trim&&i.push({kind:"cut",trim:!0}),e.crop&&i.push({kind:"cut",crop:e.crop});let s=e.to??t,r={kind:"encode",target:s};if(e.quality!==void 0&&!e.maxBytes&&(r.quality=e.quality),e.maxBytes&&(r.maxBytes=e.maxBytes),e.resize&&(r.resize=e.resize),n.length===0){let o=i.pop();o?.kind==="cut"&&(o.trim&&(r.trim=!0),o.crop&&(r.crop=o.crop))}if(r.maxBytes&&(r.trim||r.crop||r.resize)){let{trim:o,crop:h,resize:y}=r;i.push({kind:"cut",...o?{trim:o}:{},...h?{crop:h}:{},...y?{resize:y}:{}}),delete r.trim,delete r.crop,delete r.resize}if(e.removeBackground&&!p(s)?.hasAlpha&&(r.background=E[e.behind??"white"]),i.length===0&&n.length===0&&Object.keys(r).length===2&&e.to===void 0)return[];let d=i.filter(o=>o.kind==="cut"&&o.resize);return[...i.filter(o=>!d.includes(o)),...n,...d,r]}import{execFileSync as N}from"node:child_process";import{homedir as x}from"node:os";import{join as P}from"node:path";var j={Desktop:"[Environment]::GetFolderPath('Desktop')",Downloads:"(Get-ItemProperty 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders').'{374DE290-123F-4565-9164-39C4925E467B}'"};function A(e){try{let n=N("powershell.exe",["-NoProfile","-NonInteractive","-Command",`[Console]::OutputEncoding=[Text.Encoding]::UTF8; ${j[e]}`],{encoding:"buffer",timeout:5e3,stdio:["ignore","pipe","ignore"]}).toString("utf8").trim();return n.length>0?n:void 0}catch{return}}var w=new Map;function l(e,t=process.platform,n=A){if(t!=="win32")return P(x(),e);let i=w.get(e);if(i!==void 0)return i;let r=n(e)?.replace(/%([^%]+)%/g,(g,o)=>process.env[o]??g),d=(r!==void 0&&!r.includes("%")?r:void 0)??P(x(),e);return w.set(e,d),d}var f={defaultOutput:"~/Desktop",quality:80};function m(){return S(k(),"forge","config.json")}function ee(e,t=process.platform){if(t==="win32"){if(e==="~/Desktop")return l("Desktop",t);if(e==="~/Downloads")return l("Downloads",t)}return e==="~"?F():e.startsWith("~/")?S(F(),e.slice(2)):e}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function K(e){let t={...f},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 i=e.quality;typeof i=="number"&&Number.isInteger(i)&&i>=1&&i<=100?t.quality=i:n.push("quality")}if(e.updateCheck!==void 0&&(typeof e.updateCheck=="boolean"?t.updateCheck=e.updateCheck:n.push("updateCheck")),e.lastOutput!==void 0&&(typeof e.lastOutput=="string"&&e.lastOutput.trim().length>0?t.lastOutput=e.lastOutput:n.push("lastOutput")),e.presets!==void 0)if(Array.isArray(e.presets)){let i=e.presets.map(b);t.presets=i.filter(s=>s!==void 0),t.presets.length<i.length&&n.push("presets")}else n.push("presets");return{prefs:t,rejected:n}}async function J(){let e;try{e=await O(m(),"utf8")}catch{return}try{let t=JSON.parse(e);return z(t)?t:void 0}catch{return}}async function te(){let e=m(),t;try{t=await O(e,"utf8")}catch(r){return r.code==="ENOENT"?{prefs:f}:{prefs:f,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let n;try{n=JSON.parse(t)}catch{return{prefs:f,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!z(n))return{prefs:f,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:i,rejected:s}=K(n);return s.length===0?{prefs:i}:{prefs:i,warning:`Ignored invalid config ${s.length===1?"setting":"settings"}: ${s.join(", ")}.`}}async function ne(e){let t=m();await C($(t),{recursive:!0});let i={...await J()??{}};for(let[r,c]of Object.entries(e))c!==void 0&&(i[r]=c);let s=`${t}.${process.pid}.tmp`;try{await I(s,`${JSON.stringify(i,null,2)}
|
|
4
|
+
`,"utf8"),await T(s,t)}catch(r){throw await D(s).catch(()=>{}),r}}export{W as a,l as b,f as c,m as d,ee as e,te as f,ne as g};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{i as Ht}from"./chunk-6VOCIMXQ.js";import{E as Ot,d as Tt,e as gt}from"./chunk-DW2EJIUX.js";import{a as wt}from"./chunk-BXJ2HTKI.js";import{c as et,e as xe}from"./chunk-TMUK2DD3.js";var it=et((zs,Qt)=>{"use strict";var Ut="[^\\\\/]",xr="(?=.)",Kt="[^/]",yt="(?:\\/|$)",Xt="(?:^|\\/)",Rt=`\\.{1,2}${yt}`,Cr="(?!\\.)",$r=`(?!${Xt}${Rt})`,Lr=`(?!\\.{0,1}${yt})`,vr=`(?!${Rt})`,wr="[^.\\/]",Tr=`${Kt}*?`,Or="/",jt={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:xr,QMARK:Kt,END_ANCHOR:yt,DOTS_SLASH:Rt,NO_DOT:Cr,NO_DOTS:$r,NO_DOT_SLASH:Lr,NO_DOTS_SLASH:vr,QMARK_NO_DOT:wr,STAR:Tr,START_ANCHOR:Xt,SEP:Or},Hr={...jt,SLASH_LITERAL:"[\\\\/]",QMARK:Ut,STAR:`${Ut}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},Ir={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};Qt.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Ir,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?Hr:jt}}});var ut=et(q=>{"use strict";var{REGEX_BACKSLASH:Pr,REGEX_REMOVE_BACKSLASH:kr,REGEX_SPECIAL_CHARS:Dr,REGEX_SPECIAL_CHARS_GLOBAL:Nr}=it();q.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);q.hasRegexChars=t=>Dr.test(t);q.isRegexChar=t=>t.length===1&&q.hasRegexChars(t);q.escapeRegex=t=>t.replace(Nr,"\\$1");q.toPosixSlashes=t=>t.replace(Pr,"/");q.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let t=navigator.platform.toLowerCase();return t==="win32"||t==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":!1};q.removeBackslashes=t=>t.replace(kr,r=>r==="\\"?"":r);q.escapeLast=(t,r,e)=>{let s=t.lastIndexOf(r,e);return s===-1?t:t[s-1]==="\\"?q.escapeLast(t,r,s-1):`${t.slice(0,s)}\\${t.slice(s)}`};q.removePrefix=(t,r={})=>{let e=t;return e.startsWith("./")&&(e=e.slice(2),r.prefix="./"),e};q.wrapOutput=(t,r={},e={})=>{let s=e.contains?"":"^",n=e.contains?"":"$",o=`${s}(?:${t})${n}`;return r.negated===!0&&(o=`(?:^(?!${o}).*$)`),o};q.basename=(t,{windows:r}={})=>{let e=t.split(r?/[\\/]/:"/"),s=e[e.length-1];return s===""?e[e.length-2]:s}});var re=et((Zs,ee)=>{"use strict";var zt=ut(),{CHAR_ASTERISK:St,CHAR_AT:Fr,CHAR_BACKWARD_SLASH:rt,CHAR_COMMA:Br,CHAR_DOT:_t,CHAR_EXCLAMATION_MARK:Et,CHAR_FORWARD_SLASH:te,CHAR_LEFT_CURLY_BRACE:bt,CHAR_LEFT_PARENTHESES:ft,CHAR_LEFT_SQUARE_BRACKET:Mr,CHAR_PLUS:Gr,CHAR_QUESTION_MARK:Yt,CHAR_RIGHT_CURLY_BRACE:Wr,CHAR_RIGHT_PARENTHESES:Zt,CHAR_RIGHT_SQUARE_BRACKET:qr}=it(),Vt=t=>t===te||t===rt,Jt=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},Ur=(t,r)=>{let e=r||{},s=t.length-1,n=e.parts===!0||e.tokens===!0||e.scanToEnd===!0,o=[],i=[],l=[],h=t,d=-1,g=0,A=0,S=!1,x=!1,y=!1,C=!1,H=!1,G=!1,_=!1,B=!1,j=!1,I=!1,w=0,L,R,m={value:"",depth:0,isGlob:!1},u=()=>d>=s,M=()=>h.charCodeAt(d+1),D=()=>(L=R,h.charCodeAt(++d));for(;d<s;){R=D();let $;if(R===rt){_=m.backslashes=!0,R=D(),R===bt&&(G=!0);continue}if(G===!0||R===bt){for(w++;u()!==!0&&(R=D());){if(R===rt){_=m.backslashes=!0,D();continue}if(R===bt){w++;continue}if(G!==!0&&R===_t&&(R=D())===_t){if(S=m.isBrace=!0,y=m.isGlob=!0,I=!0,n===!0)continue;break}if(G!==!0&&R===Br){if(S=m.isBrace=!0,y=m.isGlob=!0,I=!0,n===!0)continue;break}if(R===Wr&&(w--,w===0)){G=!1,S=m.isBrace=!0,I=!0;break}}if(n===!0)continue;break}if(R===te){if(o.push(d),i.push(m),m={value:"",depth:0,isGlob:!1},I===!0)continue;if(L===_t&&d===g+1){g+=2;continue}A=d+1;continue}if(e.noext!==!0&&(R===Gr||R===Fr||R===St||R===Yt||R===Et)===!0&&M()===ft){if(y=m.isGlob=!0,C=m.isExtglob=!0,I=!0,R===Et&&d===g&&(j=!0),n===!0){let U=0;for(;u()!==!0&&(R=D());){if(R===rt){_=m.backslashes=!0,D();continue}if(R===ft){U++;continue}if(R===Zt&&--U===0){I=!0;break}}continue}break}if(R===St){if(L===St&&(H=m.isGlobstar=!0),y=m.isGlob=!0,I=!0,n===!0)continue;break}if(R===Yt){if(y=m.isGlob=!0,I=!0,n===!0)continue;break}if(R===Mr){for(;u()!==!0&&($=D());){if($===rt){_=m.backslashes=!0,D();continue}if($===qr){x=m.isBracket=!0,y=m.isGlob=!0,I=!0;break}}if(n===!0)continue;break}if(e.nonegate!==!0&&R===Et&&d===g){B=m.negated=!0,g++;continue}if(e.noparen!==!0&&R===ft){if(y=m.isGlob=!0,n===!0){let W=1;for(;u()!==!0&&(R=D());){if(R===rt){_=m.backslashes=!0,D();continue}if(R===ft){W++;continue}if(R===Zt&&--W===0){I=!0;break}}continue}break}if(y===!0){if(I=!0,n===!0)continue;break}}e.noext===!0&&(C=!1,y=!1);let P=h,c="",a="";g>0&&(c=h.slice(0,g),h=h.slice(g),A-=g),P&&y===!0&&A>0?(P=h.slice(0,A),a=h.slice(A)):y===!0?(P="",a=h):P=h,P&&P!==""&&P!=="/"&&P!==h&&Vt(P.charCodeAt(P.length-1))&&(P=P.slice(0,-1)),e.unescape===!0&&(a&&(a=zt.removeBackslashes(a)),P&&_===!0&&(P=zt.removeBackslashes(P)));let X={prefix:c,input:t,start:g,base:P,glob:a,isBrace:S,isBracket:x,isGlob:y,isExtglob:C,isGlobstar:H,negated:B,negatedExtglob:j};if(e.tokens===!0&&(X.maxDepth=0,Vt(R)||i.push(m),X.tokens=i),e.parts===!0||e.tokens===!0){let $;for(let N=0;N<o.length;N++){let J=$!==void 0?$+1:g,ot=o[N],Y=t.slice(J,ot);e.tokens&&(N===0&&g!==0?(i[N].isPrefix=!0,i[N].value=c):i[N].value=Y,Jt(i[N]),X.maxDepth+=i[N].depth),ot>=g&&(l.push(Y),$=ot)}let W=$!==void 0?$+1:g,U=t.slice(W);l.push(U),e.tokens&&$&&$+1<t.length&&(i[i.length-1].value=U,Jt(i[i.length-1]),X.maxDepth+=i[i.length-1].depth),X.slashes=o,X.parts=l}return X};ee.exports=Ur});var ie=et((Vs,oe)=>{"use strict";var at=it(),K=ut(),{MAX_LENGTH:ht,POSIX_REGEX_SOURCE:Kr,REGEX_NON_SPECIAL_CHARS:Xr,REGEX_SPECIAL_CHARS_BACKREF:jr,REPLACEMENTS:se}=at,Qr=(t,r)=>{if(typeof r.expandRange=="function")return r.expandRange(...t,r);t.sort();let e=`[${t.join("-")}]`;try{new RegExp(e)}catch{return t.map(n=>K.escapeRegex(n)).join("..")}return e},st=(t,r)=>`Missing ${t}: "${r}" - use "\\\\${r}" to match literal characters`,ne=t=>{let r=[],e=0,s=0,n=0,o="",i=!1;for(let l of t){if(i===!0){o+=l,i=!1;continue}if(l==="\\"){o+=l,i=!0;continue}if(l==='"'){n=n===1?0:1,o+=l;continue}if(n===0){if(l==="[")e++;else if(l==="]"&&e>0)e--;else if(e===0){if(l==="(")s++;else if(l===")"&&s>0)s--;else if(l==="|"&&s===0){r.push(o),o="";continue}}}o+=l}return r.push(o),r},zr=t=>{let r=!1;for(let e of t){if(r===!0){r=!1;continue}if(e==="\\"){r=!0;continue}if(/[?*+@!()[\]{}]/.test(e))return!1}return!0},xt=t=>{let r=t.trim(),e=!0;for(;e===!0;)e=!1,/^@\([^\\()[\]{}|]+\)$/.test(r)&&(r=r.slice(2,-1),e=!0);if(zr(r))return r.replace(/\\(.)/g,"$1")},Yr=t=>{let r=t.map(xt).filter(Boolean);for(let e=0;e<r.length;e++)for(let s=e+1;s<r.length;s++){let n=r[e],o=r[s],i=n[0];if(!(!i||n!==i.repeat(n.length)||o!==i.repeat(o.length))&&(n===o||n.startsWith(o)||o.startsWith(n)))return!0}return!1},mt=(t,r=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let e=0,s=0,n=0,o=!1;for(let i=1;i<t.length;i++){let l=t[i];if(o===!0){o=!1;continue}if(l==="\\"){o=!0;continue}if(l==='"'){n=n===1?0:1;continue}if(n!==1){if(l==="["){e++;continue}if(l==="]"&&e>0){e--;continue}if(!(e>0)){if(l==="("){s++;continue}if(l===")"&&(s--,s===0))return r===!0&&i!==t.length-1?void 0:{type:t[0],body:t.slice(2,i),end:i}}}}},Zr=t=>`${t.length===1?K.escapeRegex(t[0]):`[${t.map(e=>K.escapeRegex(e)).join("")}]`}*`,Vr=t=>{let r=0,e=[];for(;r<t.length;){let s=mt(t.slice(r),!1);if(!s||s.type!=="*")return;let n=ne(s.body).map(i=>i.trim());if(n.length!==1)return;let o=xt(n[0]);if(!o||o.length!==1)return;e.push(o),r+=s.end+1}if(!(e.length<1))return e},Jr=t=>{let r=0,e=t.trim(),s=mt(e);for(;s;)r++,e=s.body.trim(),s=mt(e);return r},ts=(t,r)=>{if(r.maxExtglobRecursion===!1)return{risky:!1};let e=typeof r.maxExtglobRecursion=="number"?r.maxExtglobRecursion:at.DEFAULT_MAX_EXTGLOB_RECURSION,s=ne(t).map(l=>l.trim());if(s.length>1&&(s.some(l=>l==="")||s.some(l=>/^[*?]+$/.test(l))||Yr(s)))return{risky:!0};let n=[],o=!1,i=!0;for(let l of s){let h=Vr(l);if(h){o=!0,n.push(...h);continue}let d=xt(l);if(d&&d.length===1){n.push(d);continue}if(i=!1,Jr(l)>e)return{risky:!0}}return o?i?{risky:!0,safeOutput:Zr([...new Set(n)])}:{risky:!0}:{risky:!1}},Ct=(t,r)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=se[t]||t;let e={...r},s=typeof e.maxLength=="number"?Math.min(ht,e.maxLength):ht,n=t.length;if(n>s)throw new SyntaxError(`Input length: ${n}, exceeds maximum allowed length: ${s}`);let o={type:"bos",value:"",output:e.prepend||""},i=[o],l=e.capture?"":"?:",h=at.globChars(e.windows),d=at.extglobChars(h),{DOT_LITERAL:g,PLUS_LITERAL:A,SLASH_LITERAL:S,ONE_CHAR:x,DOTS_SLASH:y,NO_DOT:C,NO_DOT_SLASH:H,NO_DOTS_SLASH:G,QMARK:_,QMARK_NO_DOT:B,STAR:j,START_ANCHOR:I}=h,w=f=>`(${l}(?:(?!${I}${f.dot?y:g}).)*?)`,L=e.dot?"":C,R=e.dot?_:B,m=e.bash===!0?w(e):j;e.capture&&(m=`(${m})`),typeof e.noext=="boolean"&&(e.noextglob=e.noext);let u={input:t,index:-1,start:0,dot:e.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};t=K.removePrefix(t,u),n=t.length;let M=[],D=[],P=[],c=o,a,X=()=>u.index===n-1,$=u.peek=(f=1)=>t[u.index+f],W=u.advance=()=>t[++u.index]||"",U=()=>t.slice(u.index+1),N=(f="",O=0)=>{u.consumed+=f,u.index+=O},J=f=>{u.output+=f.output!=null?f.output:f.value,N(f.value)},ot=()=>{let f=1;for(;$()==="!"&&($(2)!=="("||$(3)==="?");)W(),u.start++,f++;return f%2===0?!1:(u.negated=!0,u.start++,!0)},Y=f=>{u[f]++,P.push(f)},z=f=>{u[f]--,P.pop()},E=f=>{if(c.type==="globstar"){let O=u.braces>0&&(f.type==="comma"||f.type==="brace"),p=f.extglob===!0||M.length&&(f.type==="pipe"||f.type==="paren");f.type!=="slash"&&f.type!=="paren"&&!O&&!p&&(u.output=u.output.slice(0,-c.output.length),c.type="star",c.value="*",c.output=m,u.output+=c.output)}if(M.length&&f.type!=="paren"&&(M[M.length-1].inner+=f.value),(f.value||f.output)&&J(f),c&&c.type==="text"&&f.type==="text"){c.output=(c.output||c.value)+f.value,c.value+=f.value;return}f.prev=c,i.push(f),c=f},lt=(f,O)=>{let p={...d[O],conditions:1,inner:""};p.prev=c,p.parens=u.parens,p.output=u.output,p.startIndex=u.index,p.tokensIndex=i.length;let b=(e.capture?"(":"")+p.open;Y("parens"),E({type:f,value:O,output:u.output?"":x}),E({type:"paren",extglob:!0,value:W(),output:b}),M.push(p)},me=f=>{let O=t.slice(f.startIndex,u.index+1),p=t.slice(f.startIndex+2,u.index),b=ts(p,e);if((f.type==="plus"||f.type==="star")&&b.risky){let v=b.safeOutput?(f.output?"":x)+(e.capture?`(${b.safeOutput})`:b.safeOutput):void 0,Q=i[f.tokensIndex];Q.type="text",Q.value=O,Q.output=v||K.escapeRegex(O);for(let Z=f.tokensIndex+1;Z<i.length;Z++)i[Z].value="",i[Z].output="",delete i[Z].suffix;u.output=f.output+Q.output,u.backtrack=!0,E({type:"paren",extglob:!0,value:a,output:""}),z("parens");return}let T=f.close+(e.capture?")":""),F;if(f.type==="negate"){let v=m;if(f.inner&&f.inner.length>1&&f.inner.includes("/")&&(v=w(e)),(v!==m||X()||/^\)+$/.test(U()))&&(T=f.close=`)$))${v}`),f.inner.includes("*")&&(F=U())&&/^\.[^\\/.]+$/.test(F)){let Q=Ct(F,{...r,fastpaths:!1}).output;T=f.close=`)${Q})${v})`}f.prev.type==="bos"&&(u.negatedExtglob=!0)}E({type:"paren",extglob:!0,value:a,output:T}),z("parens")};if(e.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let f=!1,O=t.replace(jr,(p,b,T,F,v,Q)=>F==="\\"?(f=!0,p):F==="?"?b?b+F+(v?_.repeat(v.length):""):Q===0?R+(v?_.repeat(v.length):""):_.repeat(T.length):F==="."?g.repeat(T.length):F==="*"?b?b+F+(v?m:""):m:b?p:`\\${p}`);return f===!0&&(e.unescape===!0?O=O.replace(/\\/g,""):O=O.replace(/\\+/g,p=>p.length%2===0?"\\\\":p?"\\":"")),O===t&&e.contains===!0?(u.output=t,u):(u.output=K.wrapOutput(O,u,r),u)}for(;!X();){if(a=W(),a==="\0")continue;if(a==="\\"){let p=$();if(p==="/"&&e.bash!==!0||p==="."||p===";")continue;if(!p){a+="\\",E({type:"text",value:a});continue}let b=/^\\+/.exec(U()),T=0;if(b&&b[0].length>2&&(T=b[0].length,u.index+=T,T%2!==0&&(a+="\\")),e.unescape===!0?a=W():a+=W(),u.brackets===0){E({type:"text",value:a});continue}}if(u.brackets>0&&(a!=="]"||c.value==="["||c.value==="[^")){if(e.posix!==!1&&a===":"){let p=c.value.slice(1);if(p.includes("[")&&(c.posix=!0,p.includes(":"))){let b=c.value.lastIndexOf("["),T=c.value.slice(0,b),F=c.value.slice(b+2),v=Kr[F];if(v){c.value=T+v,u.backtrack=!0,W(),!o.output&&i.indexOf(c)===1&&(o.output=x);continue}}}(a==="["&&$()!==":"||a==="-"&&$()==="]")&&(a=`\\${a}`),a==="]"&&(c.value==="["||c.value==="[^")&&(a=`\\${a}`),e.posix===!0&&a==="!"&&c.value==="["&&(a="^"),c.value+=a,J({value:a});continue}if(u.quotes===1&&a!=='"'){a=K.escapeRegex(a),c.value+=a,J({value:a});continue}if(a==='"'){u.quotes=u.quotes===1?0:1,e.keepQuotes===!0&&E({type:"text",value:a});continue}if(a==="("){Y("parens"),E({type:"paren",value:a});continue}if(a===")"){if(u.parens===0&&e.strictBrackets===!0)throw new SyntaxError(st("opening","("));let p=M[M.length-1];if(p&&u.parens===p.parens+1){me(M.pop());continue}E({type:"paren",value:a,output:u.parens?")":"\\)"}),z("parens");continue}if(a==="["){if(e.nobracket===!0||!U().includes("]")){if(e.nobracket!==!0&&e.strictBrackets===!0)throw new SyntaxError(st("closing","]"));a=`\\${a}`}else Y("brackets");E({type:"bracket",value:a});continue}if(a==="]"){if(e.nobracket===!0||c&&c.type==="bracket"&&c.value.length===1){E({type:"text",value:a,output:`\\${a}`});continue}if(u.brackets===0){if(e.strictBrackets===!0)throw new SyntaxError(st("opening","["));E({type:"text",value:a,output:`\\${a}`});continue}z("brackets");let p=c.value.slice(1);if(c.posix!==!0&&p[0]==="^"&&!p.includes("/")&&(a=`/${a}`),c.value+=a,J({value:a}),e.literalBrackets===!1||K.hasRegexChars(p))continue;let b=K.escapeRegex(c.value);if(u.output=u.output.slice(0,-c.value.length),e.literalBrackets===!0){u.output+=b,c.value=b;continue}c.value=`(${l}${b}|${c.value})`,u.output+=c.value;continue}if(a==="{"&&e.nobrace!==!0){Y("braces");let p={type:"brace",value:a,output:"(",outputIndex:u.output.length,tokensIndex:u.tokens.length};D.push(p),E(p);continue}if(a==="}"){let p=D[D.length-1];if(e.nobrace===!0||!p){E({type:"text",value:a,output:a});continue}let b=")";if(p.dots===!0){let T=i.slice(),F=[];for(let v=T.length-1;v>=0&&(i.pop(),T[v].type!=="brace");v--)T[v].type!=="dots"&&F.unshift(T[v].value);b=Qr(F,e),u.backtrack=!0}if(p.comma!==!0&&p.dots!==!0){let T=u.output.slice(0,p.outputIndex),F=u.tokens.slice(p.tokensIndex);p.value=p.output="\\{",a=b="\\}",u.output=T;for(let v of F)u.output+=v.output||v.value}E({type:"brace",value:a,output:b}),z("braces"),D.pop();continue}if(a==="|"){M.length>0&&M[M.length-1].conditions++,E({type:"text",value:a});continue}if(a===","){let p=a,b=D[D.length-1];b&&P[P.length-1]==="braces"&&(b.comma=!0,p="|"),E({type:"comma",value:a,output:p});continue}if(a==="/"){if(c.type==="dot"&&u.index===u.start+1){u.start=u.index+1,u.consumed="",u.output="",i.pop(),c=o;continue}E({type:"slash",value:a,output:S});continue}if(a==="."){if(u.braces>0&&c.type==="dot"){c.value==="."&&(c.output=g);let p=D[D.length-1];c.type="dots",c.output+=a,c.value+=a,p.dots=!0;continue}if(u.braces+u.parens===0&&c.type!=="bos"&&c.type!=="slash"){E({type:"text",value:a,output:g});continue}E({type:"dot",value:a,output:g});continue}if(a==="?"){if(!(c&&c.value==="(")&&e.noextglob!==!0&&$()==="("&&$(2)!=="?"){lt("qmark",a);continue}if(c&&c.type==="paren"){let b=$(),T=a;(c.value==="("&&!/[!=<:]/.test(b)||b==="<"&&!/<([!=]|\w+>)/.test(U()))&&(T=`\\${a}`),E({type:"text",value:a,output:T});continue}if(e.dot!==!0&&(c.type==="slash"||c.type==="bos")){E({type:"qmark",value:a,output:B});continue}E({type:"qmark",value:a,output:_});continue}if(a==="!"){if(e.noextglob!==!0&&$()==="("&&($(2)!=="?"||!/[!=<:]/.test($(3)))){lt("negate",a);continue}if(e.nonegate!==!0&&u.index===0){ot();continue}}if(a==="+"){if(e.noextglob!==!0&&$()==="("&&$(2)!=="?"){lt("plus",a);continue}if(c&&c.value==="("||e.regex===!1){E({type:"plus",value:a,output:A});continue}if(c&&(c.type==="bracket"||c.type==="paren"||c.type==="brace")||u.parens>0){E({type:"plus",value:a});continue}E({type:"plus",value:A});continue}if(a==="@"){if(e.noextglob!==!0&&$()==="("&&$(2)!=="?"){E({type:"at",extglob:!0,value:a,output:""});continue}E({type:"text",value:a});continue}if(a!=="*"){(a==="$"||a==="^")&&(a=`\\${a}`);let p=Xr.exec(U());p&&(a+=p[0],u.index+=p[0].length),E({type:"text",value:a});continue}if(c&&(c.type==="globstar"||c.star===!0)){c.type="star",c.star=!0,c.value+=a,c.output=m,u.backtrack=!0,u.globstar=!0,N(a);continue}let f=U();if(e.noextglob!==!0&&/^\([^?]/.test(f)){lt("star",a);continue}if(c.type==="star"){if(e.noglobstar===!0){N(a);continue}let p=c.prev,b=p.prev,T=p.type==="slash"||p.type==="bos",F=b&&(b.type==="star"||b.type==="globstar");if(e.bash===!0&&(!T||f[0]&&f[0]!=="/")){E({type:"star",value:a,output:""});continue}let v=u.braces>0&&(p.type==="comma"||p.type==="brace"),Q=M.length&&(p.type==="pipe"||p.type==="paren");if(!T&&p.type!=="paren"&&!v&&!Q){E({type:"star",value:a,output:""});continue}for(;f.slice(0,3)==="/**";){let tt=t[u.index+4];if(tt&&tt!=="/")break;f=f.slice(3),N("/**",3)}let Z=X()||u.parens>0&&f===")".repeat(u.parens)&&!M.some(tt=>tt.type==="negate");if(p.type==="bos"&&X()){c.type="globstar",c.value+=a,c.output=w(e),u.output=c.output,u.globstar=!0,N(a);continue}if(p.type==="slash"&&p.prev.type!=="bos"&&!F&&Z){u.output=u.output.slice(0,-(p.output+c.output).length),p.output=`(?:${p.output}`,c.type="globstar",c.output=w(e)+(e.strictSlashes?")":"|$)"),c.value+=a,u.globstar=!0,u.output+=p.output+c.output,N(a);continue}if(p.type==="slash"&&p.prev.type!=="bos"&&f[0]==="/"){let tt=f[1]!==void 0?"|$":"";u.output=u.output.slice(0,-(p.output+c.output).length),p.output=`(?:${p.output}`,c.type="globstar",c.output=`${w(e)}${S}|${S}${tt})`,c.value+=a,u.output+=p.output+c.output,u.globstar=!0,N(a+W()),E({type:"slash",value:"/",output:""});continue}if(p.type==="bos"&&f[0]==="/"){c.type="globstar",c.value+=a,c.output=`(?:^|${S}|${w(e)}${S})`,u.output=c.output,u.globstar=!0,N(a+W()),E({type:"slash",value:"/",output:""});continue}u.output=u.output.slice(0,-c.output.length),c.type="globstar",c.output=w(e),c.value+=a,u.output+=c.output,u.globstar=!0,N(a);continue}let O={type:"star",value:a,output:m};if(e.bash===!0){O.output=".*?",(c.type==="bos"||c.type==="slash")&&(O.output=L+O.output),E(O);continue}if(c&&(c.type==="bracket"||c.type==="paren")&&e.regex===!0){O.output=a,E(O);continue}(u.index===u.start||c.type==="slash"||c.type==="dot")&&(c.type==="dot"?(u.output+=H,c.output+=H):e.dot===!0?(u.output+=G,c.output+=G):(u.output+=L,c.output+=L),$()!=="*"&&(u.output+=x,c.output+=x)),E(O)}for(;u.brackets>0;){if(e.strictBrackets===!0)throw new SyntaxError(st("closing","]"));u.output=K.escapeLast(u.output,"["),z("brackets")}for(;u.parens>0;){if(e.strictBrackets===!0)throw new SyntaxError(st("closing",")"));u.output=K.escapeLast(u.output,"("),z("parens")}for(;u.braces>0;){if(e.strictBrackets===!0)throw new SyntaxError(st("closing","}"));u.output=K.escapeLast(u.output,"{"),z("braces")}if(e.strictSlashes!==!0&&(c.type==="star"||c.type==="bracket")&&E({type:"maybe_slash",value:"",output:`${S}?`}),u.backtrack===!0){u.output="";for(let f of u.tokens)u.output+=f.output!=null?f.output:f.value,f.suffix&&(u.output+=f.suffix)}return u};Ct.fastpaths=(t,r)=>{let e={...r},s=typeof e.maxLength=="number"?Math.min(ht,e.maxLength):ht,n=t.length;if(n>s)throw new SyntaxError(`Input length: ${n}, exceeds maximum allowed length: ${s}`);t=se[t]||t;let{DOT_LITERAL:o,SLASH_LITERAL:i,ONE_CHAR:l,DOTS_SLASH:h,NO_DOT:d,NO_DOTS:g,NO_DOTS_SLASH:A,STAR:S,START_ANCHOR:x}=at.globChars(e.windows),y=e.dot?g:d,C=e.dot?A:d,H=e.capture?"":"?:",G={negated:!1,prefix:""},_=e.bash===!0?".*?":S;e.capture&&(_=`(${_})`);let B=L=>L.noglobstar===!0?_:`(${H}(?:(?!${x}${L.dot?h:o}).)*?)`,j=L=>{switch(L){case"*":return`${y}${l}${_}`;case".*":return`${o}${l}${_}`;case"*.*":return`${y}${_}${o}${l}${_}`;case"*/*":return`${y}${_}${i}${l}${C}${_}`;case"**":return y+B(e);case"**/*":return`(?:${y}${B(e)}${i})?${C}${l}${_}`;case"**/*.*":return`(?:${y}${B(e)}${i})?${C}${_}${o}${l}${_}`;case"**/.*":return`(?:${y}${B(e)}${i})?${o}${l}${_}`;default:{let R=/^(.*?)\.(\w+)$/.exec(L);if(!R)return;let m=j(R[1]);return m?m+o+R[2]:void 0}}},I=K.removePrefix(t,G),w=j(I);return w&&e.strictSlashes!==!0&&(w+=`${i}?`),w};oe.exports=Ct});var ce=et((Js,ae)=>{"use strict";var es=re(),$t=ie(),ue=ut(),rs=it(),ss=t=>t&&typeof t=="object"&&!Array.isArray(t),k=(t,r,e=!1)=>{if(Array.isArray(t)){let g=t.map(S=>k(S,r,e));return S=>{for(let x of g){let y=x(S);if(y)return y}return!1}}let s=ss(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!s)throw new TypeError("Expected pattern to be a non-empty string");let n=r||{},o=n.windows,i=s?k.compileRe(t,r):k.makeRe(t,r,!1,!0),l=i.state;delete i.state;let h=()=>!1;if(n.ignore){let g={...r,ignore:null,onMatch:null,onResult:null};h=k(n.ignore,g,e)}let d=(g,A=!1)=>{let{isMatch:S,match:x,output:y}=k.test(g,i,r,{glob:t,posix:o}),C={glob:t,state:l,regex:i,posix:o,input:g,output:y,match:x,isMatch:S};return typeof n.onResult=="function"&&n.onResult(C),S===!1?(C.isMatch=!1,A?C:!1):h(g)?(typeof n.onIgnore=="function"&&n.onIgnore(C),C.isMatch=!1,A?C:!1):(typeof n.onMatch=="function"&&n.onMatch(C),A?C:!0)};return e&&(d.state=l),d};k.test=(t,r,e,{glob:s,posix:n}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let o=e||{},i=o.format||(n?ue.toPosixSlashes:null),l=t===s,h=l&&i?i(t):t;return l===!1&&(h=i?i(t):t,l=h===s),(l===!1||o.capture===!0)&&(o.matchBase===!0||o.basename===!0?l=k.matchBase(t,r,e,n):l=r.exec(h)),{isMatch:!!l,match:l,output:h}};k.matchBase=(t,r,e,s=e&&e.windows)=>(r instanceof RegExp?r:k.makeRe(r,e)).test(ue.basename(t,{windows:s}));k.isMatch=(t,r,e)=>k(r,e)(t);k.parse=(t,r)=>Array.isArray(t)?t.map(e=>k.parse(e,r)):$t(t,{...r,fastpaths:!1});k.scan=(t,r)=>es(t,r);k.compileRe=(t,r,e=!1,s=!1)=>{if(e===!0)return t.output;let n=r||{},o=n.contains?"":"^",i=n.contains?"":"$",l=`${o}(?:${t.output})${i}`;t&&t.negated===!0&&(l=`^(?!${l}).*$`);let h=k.toRegex(l,r);return s===!0&&(h.state=t),h};k.makeRe=(t,r={},e=!1,s=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let n={negated:!1,fastpaths:!0};return r.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(n.output=$t.fastpaths(t,r)),n.output||(n=$t(t,r)),k.compileRe(n,r,e,s)};k.toRegex=(t,r)=>{try{let e=r||{};return new RegExp(t,e.flags||(e.nocase?"i":""))}catch(e){if(r&&r.debug===!0)throw e;return/$^/}};k.constants=rs;ae.exports=k});var he=et((tn,fe)=>{"use strict";var le=ce(),ns=ut();function pe(t,r,e=!1){return r&&(r.windows===null||r.windows===void 0)&&(r={...r,windows:ns.isWindows()}),le(t,r,e)}Object.assign(pe,le);fe.exports=pe});import{existsSync as ks}from"node:fs";import{stat as Ds}from"node:fs/promises";import{resolve as Ee}from"node:path";import{readdir as os,readdirSync as is,realpath as us,realpathSync as as,stat as cs,statSync as ls}from"fs";import{isAbsolute as ps,posix as V,resolve as fs}from"path";import{fileURLToPath as hs}from"url";import{createRequire as Ce}from"module";import{basename as $e,dirname as dt,normalize as Le,relative as ve,resolve as we,sep as kt}from"path";import*as Te from"fs";var It=Ce(import.meta.url);function Oe(t){let r=Le(t);return r.length>1&&r[r.length-1]===kt&&(r=r.substring(0,r.length-1)),r}var He=/[\\/]/g;function Dt(t,r){return t.replace(He,r)}var Ie=/^[a-z]:[\\/]$/i;function Pe(t){return t==="/"||Ie.test(t)}function At(t,r){let{resolvePaths:e,normalizePath:s,pathSeparator:n}=r,o=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(e&&(t=we(t)),(s||o)&&(t=Oe(t)),t===".")return"";let i=t[t.length-1]!==n;return Dt(i?t+n:t,n)}function Nt(t,r){return r+t}function ke(t,r){return function(e,s){return s.startsWith(t)?s.slice(t.length)+e:Dt(ve(t,s),r.pathSeparator)+r.pathSeparator+e}}function De(t){return t}function Ne(t,r,e){return r+t+e}function Fe(t,r){let{relativePaths:e,includeBasePath:s}=r;return e&&t?ke(t,r):s?Nt:De}function Be(t){return function(r,e){e.push(r.substring(t.length)||".")}}function Me(t){return function(r,e,s){let n=r.substring(t.length)||".";s.every(o=>o(n,!0))&&e.push(n)}}var Ge=(t,r)=>{r.push(t||".")},We=(t,r,e)=>{let s=t||".";e.every(n=>n(s,!0))&&r.push(s)},qe=()=>{};function Ue(t,r){let{includeDirs:e,filters:s,relativePaths:n}=r;return e?n?s&&s.length?Me(t):Be(t):s&&s.length?We:Ge:qe}var Ke=(t,r,e,s)=>{s.every(n=>n(t,!1))&&e.files++},Xe=(t,r,e,s)=>{s.every(n=>n(t,!1))&&r.push(t)},je=(t,r,e,s)=>{e.files++},Qe=(t,r)=>{r.push(t)},ze=()=>{};function Ye(t){let{excludeFiles:r,filters:e,onlyCounts:s}=t;return r?ze:e&&e.length?s?Ke:Xe:s?je:Qe}var Ze=t=>t,Ve=()=>[""].slice(0,0);function Je(t){return t.group?Ve:Ze}var tr=(t,r,e)=>{t.push({directory:r,files:e,dir:r})},er=()=>{};function rr(t){return t.group?tr:er}var sr=function(t,r,e){let{queue:s,fs:n,options:{suppressErrors:o}}=r;s.enqueue(),n.realpath(t,(i,l)=>{if(i)return s.dequeue(o?null:i,r);n.stat(l,(h,d)=>{if(h)return s.dequeue(o?null:h,r);if(d.isDirectory()&&Ft(t,l,r))return s.dequeue(null,r);e(d,l),s.dequeue(null,r)})})},nr=function(t,r,e){let{queue:s,fs:n,options:{suppressErrors:o}}=r;s.enqueue();try{let i=n.realpathSync(t),l=n.statSync(i);if(l.isDirectory()&&Ft(t,i,r))return;e(l,i)}catch(i){if(!o)throw i}};function or(t,r){return!t.resolveSymlinks||t.excludeSymlinks?null:r?nr:sr}function Ft(t,r,e){if(e.options.useRealPaths)return ir(r,e);let s=dt(t),n=1;for(;s!==e.root&&n<2;){let o=e.symlinks.get(s);!!o&&(o===r||o.startsWith(r)||r.startsWith(o))?n++:s=dt(s)}return e.symlinks.set(t,r),n>1}function ir(t,r){return r.visited.includes(t+r.options.pathSeparator)}var ur=t=>t.counts,ar=t=>t.groups,cr=t=>t.paths,lr=t=>t.paths.slice(0,t.options.maxFiles),pr=(t,r,e)=>(pt(r,e,t.counts,t.options.suppressErrors),null),fr=(t,r,e)=>(pt(r,e,t.paths,t.options.suppressErrors),null),hr=(t,r,e)=>(pt(r,e,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),gr=(t,r,e)=>(pt(r,e,t.groups,t.options.suppressErrors),null);function pt(t,r,e,s){r(t&&!s?t:null,e)}function Ar(t,r){let{onlyCounts:e,group:s,maxFiles:n}=t;return e?r?ur:pr:s?r?ar:gr:n?r?lr:hr:r?cr:fr}var Bt={withFileTypes:!0},dr=(t,r,e,s,n)=>{if(t.queue.enqueue(),s<0)return t.queue.dequeue(null,t);let{fs:o}=t;t.visited.push(r),t.counts.directories++,o.readdir(r||".",Bt,(i,l=[])=>{n(l,e,s),t.queue.dequeue(t.options.suppressErrors?null:i,t)})},yr=(t,r,e,s,n)=>{let{fs:o}=t;if(s<0)return;t.visited.push(r),t.counts.directories++;let i=[];try{i=o.readdirSync(r||".",Bt)}catch(l){if(!t.options.suppressErrors)throw l}n(i,e,s)};function Rr(t){return t?yr:dr}var Sr=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,r){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,r),t&&(r.controller.abort(),this.onQueueEmpty=void 0))}},_r=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},Er=class{aborted=!1;abort(){this.aborted=!0}},Mt=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(t,r,e){this.isSynchronous=!e,this.callbackInvoker=Ar(r,this.isSynchronous),this.root=At(t,r),this.state={root:Pe(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new _r,options:r,queue:new Sr((s,n)=>this.callbackInvoker(n,s,e)),symlinks:new Map,visited:[""].slice(0,0),controller:new Er,fs:r.fs||Te},this.joinPath=Fe(this.root,r),this.pushDirectory=Ue(this.root,r),this.pushFile=Ye(r),this.getArray=Je(r),this.groupFiles=rr(r),this.resolveSymlink=or(r,this.isSynchronous),this.walkDirectory=Rr(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(t,r,e)=>{let{paths:s,options:{filters:n,resolveSymlinks:o,excludeSymlinks:i,exclude:l,maxFiles:h,signal:d,useRealPaths:g,pathSeparator:A},controller:S}=this.state;if(S.aborted||d&&d.aborted||h&&s.length>h)return;let x=this.getArray(this.state.paths);for(let y=0;y<t.length;++y){let C=t[y];if(C.isFile()||C.isSymbolicLink()&&!o&&!i){let H=this.joinPath(C.name,r);this.pushFile(H,x,this.state.counts,n)}else if(C.isDirectory()){let H=Ne(C.name,r,this.state.options.pathSeparator);if(l&&l(C.name,H))continue;this.pushDirectory(H,s,n),this.walkDirectory(this.state,H,H,e-1,this.walk)}else if(this.resolveSymlink&&C.isSymbolicLink()){let H=Nt(C.name,r);this.resolveSymlink(H,this.state,(G,_)=>{if(G.isDirectory()){if(_=At(_,this.state.options),l&&l(C.name,g?_:H+A))return;this.walkDirectory(this.state,_,g?_:H+A,e-1,this.walk)}else{_=g?_:H;let B=$e(_),j=At(dt(_),this.state.options);_=this.joinPath(B,j),this.pushFile(_,x,this.state.counts,n)}})}}this.groupFiles(this.state.groups,r,x)}};function br(t,r){return new Promise((e,s)=>{Gt(t,r,(n,o)=>{if(n)return s(n);e(o)})})}function Gt(t,r,e){new Mt(t,r,e).start()}function mr(t,r){return new Mt(t,r).start()}var Pt=class{constructor(t,r){this.root=t,this.options=r}withPromise(){return br(this.root,this.options)}withCallback(t){Gt(this.root,this.options,t)}sync(){return mr(this.root,this.options)}},Wt=null;try{It.resolve("picomatch"),Wt=It("picomatch")}catch{}var qt=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:kt,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new Pt(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,r){return this.options={...this.options,...r},new Pt(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...r){let e=this.globFunction||Wt;if(!e)throw new Error("Please specify a glob function to use glob matching.");var s=this.globCache[t.join("\0")];return s||(s=e(t,...r),this.globCache[t.join("\0")]=s),this.options.filters.push(n=>s(n)),this}};var nt=xe(he(),1),gs=Array.isArray,ye=/\\/g,As=/^[A-Za-z]:$/,Re=process.platform==="win32",ds=/^(\/?\.\.)+$/;function ys(t,r={}){let e=t.length,s=Array(e),n=Array(e),o,i;for(o=0;o<e;o++){let l=Se(t[o]);s[o]=l;let h=l.length,d=Array(h);for(i=0;i<h;i++)d[i]=(0,nt.default)(l[i],r);n[o]=d}return l=>{let h=l.split("/");if(h[0]===".."&&ds.test(l))return!0;for(o=0;o<e;o++){let d=s[o],g=n[o],A=h.length,S=Math.min(A,d.length);for(i=0;i<S;){let x=d[i];if(x.includes("/"))return!0;if(!g[i](h[i]))break;if(!r.noglobstar&&x==="**")return!0;i++}if(i===A)return!0}return!1}}var Rs=/^[A-Z]:\/$/i,Ss=Re?t=>Rs.test(t):t=>t==="/";function ge(t,r,e){if(t===r||r.startsWith(`${t}/`)){if(e){let n=t.length+ +!Ss(t);return(o,i)=>o.slice(n,i?-1:void 0)||"."}let s=r.slice(t.length+1);return s?(n,o)=>{if(n===".")return s;let i=`${s}/${n}`;return o?i.slice(0,-1):i}:(n,o)=>o&&n!=="."?n.slice(0,-1):n}return e?s=>V.relative(t,s)||".":s=>V.relative(t,`${r}/${s}`)||"."}function _s(t,r){if(r.startsWith(`${t}/`)){let e=r.slice(t.length+1);return s=>`${e}/${s}`}return e=>{let s=V.relative(t,`${r}/${e}`);return e[e.length-1]==="/"&&s!==""?`${s}/`:s||"."}}function Ae(t){return t.replace(As,r=>`${r}/`)}var Es={parts:!0};function Se(t){var r;let e=nt.default.scan(t,Es);return!((r=e.parts)===null||r===void 0)&&r.length?e.parts:[t]}var bs=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,ms=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,xs=t=>t.replace(bs,"\\$&"),Cs=t=>t.replace(ms,"\\$&"),$s=Re?Cs:xs;function Ls(t,r){if(r?.caseSensitiveMatch===!1)return!0;let e=nt.default.scan(t);return e.isGlob||e.negated}function ct(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function _e(t){return typeof t=="string"?[t]:t??[]}var vs=/^(\/?\.\.)+/,ws=/\\(?=[()[\]{}!*+?@|])/g;function Lt(t,r,e,s){var n;let o=r.cwd,i=t;t[t.length-1]==="/"&&(i=t.slice(0,-1)),i[i.length-1]!=="*"&&r.expandDirectories&&(i+="/**");let l=$s(o);i=ps(i.replace(ws,""))?V.relative(l,i):V.normalize(i);let h=(n=vs.exec(i))===null||n===void 0?void 0:n[0],d=Se(i);if(h){let A=(h.length+1)/3,S=0,x=l.split("/");for(;S<A&&d[S+A]===x[x.length+S-A];)i=i.slice(0,(A-S-1)*3)+i.slice((A-S)*3+d[S+A].length+1)||".",S++;let y=V.join(o,h.slice(S*3));y[0]!=="."&&e.root.length>y.length&&(e.root=Ae(y),e.depthOffset=-A+S)}if(!s&&e.depthOffset>=0){var g;(g=e.commonPath)!==null&&g!==void 0||(e.commonPath=d);let A=[],S=Math.min(e.commonPath.length,d.length);for(let x=0;x<S;x++){let y=d[x];if(y==="**"&&!d[x+1]){A.pop();break}if(x===d.length-1||y!==e.commonPath[x]||Ls(y))break;A.push(y)}e.depthOffset=A.length,e.commonPath=A,e.root=Ae(A.length>0?V.join(o,...A):o)}return i}function Ts(t,r,e){let s=[],n=[];for(let o of t.ignore)o&&(o[0]!=="!"||o[1]==="(")&&n.push(Lt(o,t,e,!0));for(let o of r)o&&(o[0]!=="!"||o[1]==="("?s.push(Lt(o,t,e,!1)):(o[1]!=="!"||o[2]==="(")&&n.push(Lt(o.slice(1),t,e,!0)));return{match:s,ignore:n}}function Os(t,r){let e=t.cwd,s={root:e,depthOffset:0},n=Ts(t,r,s);t.debug&&ct("internal processing patterns:",n);let{absolute:o,caseSensitiveMatch:i,debug:l,dot:h,followSymbolicLinks:d,onlyDirectories:g}=t,A=s.root.replace(ye,""),S={dot:h,nobrace:t.braceExpansion===!1,nocase:!i,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},x=(0,nt.default)(n.match,S),y=(0,nt.default)(n.ignore,S),C=ys(n.match,S),H=ge(e,A,o),G=o?H:ge(e,A,!0),_=(I,w)=>{let L=G(w,!0);return L!=="."&&!C(L)||y(L)},B;t.deep!==void 0&&(B=Math.round(t.deep-s.depthOffset));let j=new qt({filters:[l?(I,w)=>{let L=H(I,w),R=x(L)&&!y(L);return R&&ct(`matched ${L}`),R}:(I,w)=>{let L=H(I,w);return x(L)&&!y(L)}],exclude:l?(I,w)=>{let L=_(I,w);return ct(`${L?"skipped":"crawling"} ${w}`),L}:_,fs:t.fs,pathSeparator:"/",relativePaths:!o,resolvePaths:o,includeBasePath:o,resolveSymlinks:d,excludeSymlinks:!d,excludeFiles:g,includeDirs:g||!t.onlyFiles,maxDepth:B,signal:t.signal}).crawl(A);return t.debug&&ct("internal properties:",{...s,root:A}),[j,e!==A&&!o&&_s(e,A)]}function Hs(t,r){if(r)for(let e=t.length-1;e>=0;e--)t[e]=r(t[e]);return t}var de={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function Is(t){let r=Object.assign({},t);for(let e in de)r[e]===void 0&&Object.assign(r,{[e]:de[e]});return r.cwd=(r.cwd instanceof URL?hs(r.cwd):fs(r.cwd||process.cwd())).replace(ye,"/"),r.ignore=_e(r.ignore),r.fs&&(r.fs={readdir:r.fs.readdir||os,readdirSync:r.fs.readdirSync||is,realpath:r.fs.realpath||us,realpathSync:r.fs.realpathSync||as,stat:r.fs.stat||cs,statSync:r.fs.statSync||ls}),r.debug&&ct("globbing with options:",r),r}function Ps(t,r={}){var e;if(t&&r?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");let s=gs(t)||typeof t=="string",n=_e((e=s?t:t.patterns)!==null&&e!==void 0?e:"**/*"),o=Is(s?r:t);return n.length>0?Os(o,n):[]}async function vt(t,r){let[e,s]=Ps(t,r);return e?Hs(await e.withPromise(),s):[]}var be=Object.values(wt).flatMap(t=>t.extensions).map(t=>t.slice(1));function Ns(t){return/[*?[\]{}]/.test(t)}async function Fs(t,r){let e=r?`**/*.{${be.join(",")}}`:`*.{${be.join(",")}}`;return(await vt([e],{cwd:t,absolute:!0,onlyFiles:!0,caseSensitiveMatch:!1})).sort()}async function Bs(t,r,e,s){let n=await Fs(t,r);if(n.length===0){e.push({path:t,error:Ot(t)});return}for(let o of n)await s(o,t,!1)}async function gn(t,r){let e=[],s=[],n=new Map,o=new Set,i=async(l,h,d)=>{let g=Ee(l);if(!o.has(g)){o.add(g);try{e.push(await Ht(g)),h&&n.set(g,h)}catch(A){if(Tt(A))s.push({path:g,error:A});else if(d)throw A}}};for(let l of t){let h=Ee(l);if(Ns(l)&&!ks(h)){let g=(r.platform??process.platform)==="win32"?l.replaceAll("\\","/"):l,A=await vt([g],{absolute:!0,onlyFiles:!0});A.length===0&&s.push({path:h,error:gt(h)});for(let S of A.sort())await i(S,void 0,!1);continue}let d;try{d=await Ds(h)}catch{s.push({path:h,error:gt(h)});continue}if(d.isDirectory()){await Bs(h,r.recursive,s,i);continue}await i(h,void 0,!0)}return{sources:e,failures:s,roots:n}}export{gn as a};
|